diff --git a/pom.xml b/pom.xml index 57604df4c4..f509d8f26e 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,6 @@ spring-cloud-contract-tools spring-cloud-contract-stub-runner-boot tests - samples diff --git a/samples/pom.xml b/samples/pom.xml deleted file mode 100644 index ed33e91774..0000000000 --- a/samples/pom.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - 4.0.0 - - - org.springframework.cloud - spring-cloud-contract-parent - 4.2.0-SNAPSHOT - .. - - - spring-cloud-contract-samples - pom - 4.2.0-SNAPSHOT - Spring Cloud Contract Samples - Spring Cloud Contract Samples - - - ${basedir}/.. - - - - - org.springframework.cloud - spring-cloud-contract-stub-runner - test - - - org.springframework.cloud - spring-cloud-contract-maven-plugin - test - - - org.springframework.cloud - spring-cloud-contract-gradle-plugin - test - - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - - - - - integration - - - - - org.apache.maven.plugins - maven-invoker-plugin - 3.2.2 - - src/it/settings.xml - standalone - ${skipTests} - true - - integration - - - contracts/pom.xml - */pom.xml - dsl/pom.xml - restdocs/pom.xml - webclient/pom.xml - - - clean - install - - - - - integration - - run - - - - - - - - - windows - - - - - org.apache.maven.plugins - maven-invoker-plugin - 3.2.2 - - src/it/settings.xml - standalone - ${skipTests} - true - - windows - - - */pom.xml - - - clean - install - - - - - integration - - run - - - - - - - - - - diff --git a/samples/src/it/settings.xml b/samples/src/it/settings.xml deleted file mode 100644 index 5329c60576..0000000000 --- a/samples/src/it/settings.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - integration - - true - - - - it-repo - - true - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - diff --git a/samples/standalone/.mvn/jvm.config b/samples/standalone/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/README.adoc b/samples/standalone/README.adoc deleted file mode 100644 index 6e391725a3..0000000000 --- a/samples/standalone/README.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= Spring Cloud Contract Verifier Samples - -Projects that contain different samples of Spring Cloud Contract Verifier. - -Below you can find a list of samples: - -include::contracts/README.adoc[] - -include::dsl/http-server/README.adoc[] - -include::dsl/http-client/README.adoc[] - -include::messaging/stream-sink/README.adoc[] - -include::messaging/stream-source/README.adoc[] - -include::restdocs/http-server/README.adoc[] - -include::restdocs/http-client/README.adoc[] - diff --git a/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c6feb8bb6f..0000000000 Binary files a/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 6637cedb28..0000000000 --- a/samples/standalone/contracts/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -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 diff --git a/samples/standalone/contracts/README.adoc b/samples/standalone/contracts/README.adoc deleted file mode 100644 index d5daaa6fef..0000000000 --- a/samples/standalone/contracts/README.adoc +++ /dev/null @@ -1,68 +0,0 @@ -= Common contracts repo - -This repo contains all contracts for apps in the system. - -== As a consumer - -You are working offline in order to play around with the API of the producer. -What you need to do is to have the producer's stubs installed locally. To do that -you have to (from the root of the repo) - -[source,bash] ----- -cd com/example/server/ -mvn clean install -DskipTests ----- - -Then if you do `ls ./target` you'll see `server-0.0.1-SNAPSHOT-stubs.jar`. This jar will - contain the stubs generated from your contracts. That way you -can reference the `com.example:server:+:stubs` dependency in your consumer tests. - -== As a producer - -Assuming that the consumers have filed a PR with the proposed contract the producers -can work offline to generate tests and stubs. To work offline, as a producer you just have -to go to the root folder of the contracts and: - -[source,bash] ----- -./mvnw clean install -DskipTests ----- - -Then if you do `ls ./target` you'll see `contracts-0.0.1-SNAPSHOT.jar`. This file contains -all DSL contracts, for all applications. - -Now the producer can include the `contracts-0.0.1-SNAPSHOT.jar` from your local maven repository. -You can achieve that by setting the proper flag in plugin properties. - -Example for Maven - -[source,xml] ----- - - org.springframework.cloud - spring-cloud-contract-maven-plugin - - LOCAL - - com.example.standalone - contracts - - - ----- - -and for Gradle: - -[source,groovy] ----- -contracts { - testFramework ='Spock' - testMode = 'JaxRsClient' - baseClassForTests = 'org.springframework.cloud.MvcSpec' - stubsMode = 'LOCAL' - contractDependency { - stringNotation = "com.example:contracts" - } -} ----- \ No newline at end of file diff --git a/samples/standalone/contracts/com/example/server/client1/expectation.groovy b/samples/standalone/contracts/com/example/server/client1/expectation.groovy deleted file mode 100644 index ba3850f752..0000000000 --- a/samples/standalone/contracts/com/example/server/client1/expectation.groovy +++ /dev/null @@ -1,82 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - request { // (1) - method 'PUT' // (2) - url '/fraudcheck' // (3) - body([ // (4) - clientId : $(regex('[0-9]{10}')), - loanAmount: 99999 - ]) - headers { // (5) - contentType('application/vnd.fraud.v1+json') - } - } - response { // (6) - status OK() // (7) - body([ // (8) - fraudCheckStatus: "FRAUD", - rejectionReason : "Amount too high" - ]) - headers { // (9) - contentType('application/vnd.fraud.v1+json') - } - } -} - -/* -Since we don't want to force on the user to hardcode values of fields that are dynamic -(timestamps, database ids etc.), one can parametrize those entries. If you wrap your field's - value in a `$(...)` or `value(...)` and provide a dynamic value of a field then - the concrete value will be generated for you. If you want to be really explicit about - which side gets which value you can do that by using the `value(consumer(...), producer(...))` notation. - That way what's present in the `consumer` section will end up in the produced stub. What's - there in the `producer` will end up in the autogenerated test. If you provide only the - regular expression side without the concrete value then Spring Cloud Contract will generate one for you. - -From the Consumer perspective, when shooting a request in the integration test: - -(1) - If the consumer sends a request -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the response will be sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` - -From the Producer perspective, in the autogenerated producer-side test: - -(1) - A request will be sent to the producer -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that will have a generated value that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the test will assert if the response has been sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` matching `application/vnd.fraud.v1+json.*` - */ diff --git a/samples/standalone/contracts/com/example/server/client2/expectation.groovy b/samples/standalone/contracts/com/example/server/client2/expectation.groovy deleted file mode 100644 index bd1ad7b711..0000000000 --- a/samples/standalone/contracts/com/example/server/client2/expectation.groovy +++ /dev/null @@ -1,83 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - request { // (1) - method 'PUT' // (2) - url '/fraudcheck2' // (3) - body([ // (4) - clientId : value(consumer(regex('[0-9]{10}'))), - loanAmount: 99999 - ]) - headers { // (5) - header('Content-Type', 'application/vnd.fraud.v1+json') - } - } - response { // (6) - status OK() // (7) - body([ // (8) - fraudCheckStatus: "FRAUD", - rejectionReason : "Amount too high" - ]) - headers { // (9) - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } -} - -/* -Since we don't want to force on the user to hardcode values of fields that are dynamic -(timestamps, database ids etc.), one can provide parametrize those entries by using the -`value(consumer(...), producer(...))` method. That way what's present in the `consumer` -section will end up in the produced stub. What's there in the `producer` will end up in the -autogenerated test. If you provide only the regular expression side without the concrete -value then Spring Cloud Contract will generate one for you. - -From the Consumer perspective, when shooting a request in the integration test: - -(1) - If the consumer sends a request -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the response will be sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` - -From the Producer perspective, in the autogenerated producer-side test: - -(1) - A request will be sent to the producer -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that will have a generated value that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the test will assert if the response has been sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` matching `application/vnd.fraud.v1+json.*` - */ diff --git a/samples/standalone/contracts/com/example/server/client3/expectation.groovy b/samples/standalone/contracts/com/example/server/client3/expectation.groovy deleted file mode 100644 index 1a850d19c2..0000000000 --- a/samples/standalone/contracts/com/example/server/client3/expectation.groovy +++ /dev/null @@ -1,83 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - request { // (1) - method 'PUT' // (2) - url '/fraudcheck3' // (3) - body([ // (4) - clientId : value(consumer(regex('[0-9]{10}'))), - loanAmount: 99999 - ]) - headers { // (5) - header('Content-Type', 'application/vnd.fraud.v1+json') - } - } - response { // (6) - status OK() // (7) - body([ // (8) - fraudCheckStatus: "FRAUD", - rejectionReason : "Amount too high" - ]) - headers { // (9) - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } -} - -/* -Since we don't want to force on the user to hardcode values of fields that are dynamic -(timestamps, database ids etc.), one can provide parametrize those entries by using the -`value(consumer(...), producer(...))` method. That way what's present in the `consumer` -section will end up in the produced stub. What's there in the `producer` will end up in the -autogenerated test. If you provide only the regular expression side without the concrete -value then Spring Cloud Contract will generate one for you. - -From the Consumer perspective, when shooting a request in the integration test: - -(1) - If the consumer sends a request -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the response will be sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` - -From the Producer perspective, in the autogenerated producer-side test: - -(1) - A request will be sent to the producer -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that will have a generated value that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the test will assert if the response has been sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` matching `application/vnd.fraud.v1+json.*` - */ diff --git a/samples/standalone/contracts/com/example/server/pom.xml b/samples/standalone/contracts/com/example/server/pom.xml deleted file mode 100644 index fc0d3e2cf3..0000000000 --- a/samples/standalone/contracts/com/example/server/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - 4.0.0 - - com.example - server - 0.0.1 - - Server Stubs - POM used to install locally stubs for consumer side - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - true - - - - - - org.springframework.cloud - spring-cloud-contract-maven-plugin - ${spring-cloud-contract.version} - true - - - ${project.basedir} - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - diff --git a/samples/standalone/contracts/mvnw b/samples/standalone/contracts/mvnw deleted file mode 100755 index 63fcc8f0fc..0000000000 --- a/samples/standalone/contracts/mvnw +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -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 - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, 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 - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -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) - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - wdir=$(cd "$wdir/.."; pwd) - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CMD_LINE_ARGS - diff --git a/samples/standalone/contracts/mvnw.cmd b/samples/standalone/contracts/mvnw.cmd deleted file mode 100644 index 66e928bd13..0000000000 --- a/samples/standalone/contracts/mvnw.cmd +++ /dev/null @@ -1,145 +0,0 @@ -@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% diff --git a/samples/standalone/contracts/pom.xml b/samples/standalone/contracts/pom.xml deleted file mode 100644 index b2cc286f73..0000000000 --- a/samples/standalone/contracts/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - - com.example.standalone - contracts - 0.0.1 - - Contracts - Contains all the Spring Cloud Contracts, well, contracts. JAR used by the - producers to generate tests and stubs - - - - UTF-8 - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - contracts - prepare-package - - single - - - true - ${basedir}/src/assembly/contracts.xml - - false - - - - - - - - diff --git a/samples/standalone/contracts/src/assembly/contracts.xml b/samples/standalone/contracts/src/assembly/contracts.xml deleted file mode 100644 index 478cdc59d1..0000000000 --- a/samples/standalone/contracts/src/assembly/contracts.xml +++ /dev/null @@ -1,23 +0,0 @@ - - project - - jar - - false - - - ${project.basedir} - / - true - - **/${project.build.directory}/** - mvnw - mvnw.cmd - .mvn/** - src/** - - - - diff --git a/samples/standalone/dsl/http-client/.gitignore b/samples/standalone/dsl/http-client/.gitignore deleted file mode 100644 index b05ba7bd6d..0000000000 --- a/samples/standalone/dsl/http-client/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ - -target/ - -.gradle -build/ - diff --git a/samples/standalone/dsl/http-client/.mvn/jvm.config b/samples/standalone/dsl/http-client/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/dsl/http-client/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/dsl/http-client/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/dsl/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/dsl/http-client/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/dsl/http-client/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/README.adoc b/samples/standalone/dsl/http-client/README.adoc deleted file mode 100644 index cdcb0e4a56..0000000000 --- a/samples/standalone/dsl/http-client/README.adoc +++ /dev/null @@ -1,26 +0,0 @@ -= Http Client - -== Prerequisites - -First you have to publish to Maven Local the stubs of the *http-server* module - -== How to run it? - -Run - -[source=groovy] --------- -./gradlew clean build --------- - -or - --------- -./mvnw clean package --------- - -To - -- build the app -- use spring-cloud-contract-stub-runner-spring[Stub Runner Spring] to download the stub of `Http Server` -- run the tests against stubbed server \ No newline at end of file diff --git a/samples/standalone/dsl/http-client/build.gradle b/samples/standalone/dsl/http-client/build.gradle deleted file mode 100644 index 2cc4918bc6..0000000000 --- a/samples/standalone/dsl/http-client/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -plugins { - id "groovy" - id "org.springframework.boot" - id "io.spring.dependency-management" - id "maven-publish" -} - -group = 'com.example' -version = '0.0.1' - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:$verifierVersion" - mavenBom "org.springframework.cloud:spring-cloud-stream-dependencies:$springCloudStreamVersion" - } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.cloud:spring-cloud-starter-stream-rabbit") - - testImplementation(group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-binder') - testImplementation "org.springframework.cloud:spring-cloud-starter-contract-stub-runner" - testImplementation "org.springframework.cloud:spring-cloud-starter-contract-verifier" - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } -} - -test { - useJUnitPlatform() - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/dsl/http-client/gradle.properties b/samples/standalone/dsl/http-client/gradle.properties deleted file mode 100644 index 0b984780b3..0000000000 --- a/samples/standalone/dsl/http-client/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -springCloudStreamVersion=4.1.4-SNAPSHOT -bootVersion=3.2.7 diff --git a/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index c1962a79e2..0000000000 Binary files a/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index c30b486a89..0000000000 --- a/samples/standalone/dsl/http-client/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/dsl/http-client/gradlew b/samples/standalone/dsl/http-client/gradlew deleted file mode 100755 index aeb74cbb43..0000000000 --- a/samples/standalone/dsl/http-client/gradlew +++ /dev/null @@ -1,245 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/dsl/http-client/gradlew.bat b/samples/standalone/dsl/http-client/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/dsl/http-client/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/dsl/http-client/mvnw b/samples/standalone/dsl/http-client/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/dsl/http-client/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/dsl/http-client/mvnw.cmd b/samples/standalone/dsl/http-client/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/dsl/http-client/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/dsl/http-client/pom.xml b/samples/standalone/dsl/http-client/pom.xml deleted file mode 100644 index 16b23051a6..0000000000 --- a/samples/standalone/dsl/http-client/pom.xml +++ /dev/null @@ -1,242 +0,0 @@ - - - 4.0.0 - - com.example - http-client-dsl - 0.0.1 - - Spring Cloud Contract Verifier Http Client Sample - Spring Cloud Contract Verifier Http Client Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - 4.1.4-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.apache.httpcomponents.client5 - httpclient5 - - - org.slf4j - slf4j-api - - - - - org.springframework.cloud - spring-cloud-starter-stream-rabbit - - - - org.springframework.cloud - spring-cloud-stream-test-binder - test - - - - - org.springframework.cloud - spring-cloud-starter-contract-stub-runner - test - - - - - - org.springframework.cloud - spring-cloud-starter-contract-verifier - test - - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-deploy-plugin - 2.8.2 - - true - - - - org.apache.maven.plugins - maven-clean-plugin - 3.0.0 - - - - build - - - target - - - - - - maven-surefire-plugin - - true - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - integration - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - gradlew.bat - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - - diff --git a/samples/standalone/dsl/http-client/settings.gradle b/samples/standalone/dsl/http-client/settings.gradle deleted file mode 100644 index b125e54194..0000000000 --- a/samples/standalone/dsl/http-client/settings.gradle +++ /dev/null @@ -1,14 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - gradlePluginPortal() - } - plugins { - id "org.springframework.boot" version "${bootVersion}" - id "io.spring.dependency-management" version "1.1.3" - } -} - -rootProject.name = 'http-client-dsl-gradle' diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Application.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Application.java deleted file mode 100644 index 6e1c77d277..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Application.java +++ /dev/null @@ -1,29 +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 com.example.loan; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Listener.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Listener.java deleted file mode 100644 index 51f6cd3015..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/Listener.java +++ /dev/null @@ -1,41 +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 com.example.loan; - -import java.util.function.Consumer; - -import org.springframework.stereotype.Component; - -@Component("listener") -class Listener implements Consumer { - - int count = 0; - - public void logSensorData(SensorData data) { - System.out.println(data); - this.count = this.count + 1; - } - - public int getCount() { - return this.count; - } - - @Override - public void accept(SensorData sensorData) { - this.logSensorData(sensorData); - } -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/LoanApplicationService.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/LoanApplicationService.java deleted file mode 100644 index ad400366fb..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/LoanApplicationService.java +++ /dev/null @@ -1,126 +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 com.example.loan; - -import com.example.loan.model.FraudCheckStatus; -import com.example.loan.model.FraudServiceRequest; -import com.example.loan.model.FraudServiceResponse; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import com.example.loan.model.Response; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private final RestTemplate restTemplate; - - private int port = 6565; - - private String prefix = ""; - - @Autowired - public LoanApplicationService(RestTemplateBuilder builder) { - this.restTemplate = builder.build(); - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - - // tag::client_call_server[] - ResponseEntity response = restTemplate.exchange( - "http://localhost:" + port + fraudCheck(), HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - // end::client_call_server[] - - return response.getBody(); - } - - private String fraudCheck() { - return "/" + prefix + "fraudcheck"; - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public int countAllFrauds() { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - ResponseEntity response = restTemplate.exchange( - "http://localhost:" + port + "/" + prefix + "frauds", HttpMethod.GET, - new HttpEntity<>(httpHeaders), Response.class); - return response.getBody().getCount(); - } - - public int countDrunks() { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - ResponseEntity response = restTemplate.exchange( - "http://localhost:" + port + "/"+ prefix + "drunks", HttpMethod.GET, - new HttpEntity<>(httpHeaders), Response.class); - return response.getBody().getCount(); - } - - public String getCookies() { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add("Cookie", "name=foo"); - httpHeaders.add("Cookie", "name2=bar"); - ResponseEntity response = restTemplate.exchange( - "http://localhost:" + port + "/" + prefix + "frauds/name", HttpMethod.GET, - new HttpEntity<>(httpHeaders), String.class); - return response.getBody(); - } - - public void setPort(int port) { - this.port = port; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/SensorData.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/SensorData.java deleted file mode 100644 index c2f496de97..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/SensorData.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016-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 com.example.loan; - -/** - * @author Marius Bogoevici - */ -public class SensorData { - - private Long id; - - private Double temperature; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Double getTemperature() { - return temperature; - } - - public void setTemperature(Double temperature) { - this.temperature = temperature; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Client.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Client.java deleted file mode 100644 index 8fac47b2fd..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Client.java +++ /dev/null @@ -1,38 +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 com.example.loan.model; - -public class Client { - - private String pesel; - - public Client() { - } - - public Client(String pesel) { - this.pesel = pesel; - } - - public String getPesel() { - return pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java deleted file mode 100644 index 01f2969113..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java deleted file mode 100644 index 2933acb39d..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java +++ /dev/null @@ -1,54 +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 com.example.loan.model; - -import java.math.BigDecimal; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FraudServiceRequest { - - @JsonProperty("client.id") - private String clientId; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientId = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java deleted file mode 100644 index 1847a12483..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java +++ /dev/null @@ -1,47 +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 com.example.loan.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - @JsonProperty("rejection.reason") - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplication.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplication.java deleted file mode 100644 index e2f4aa2513..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplication.java +++ /dev/null @@ -1,61 +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 com.example.loan.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public LoanApplication() { - } - - public LoanApplication(Client client, double amount) { - this.client = client; - this.amount = BigDecimal.valueOf(amount); - } - - public Client getClient() { - return client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java deleted file mode 100644 index 73501084bb..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +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 com.example.loan.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java deleted file mode 100644 index 5afde21afc..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Response.java b/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Response.java deleted file mode 100644 index 37ea6013e5..0000000000 --- a/samples/standalone/dsl/http-client/src/main/java/com/example/loan/model/Response.java +++ /dev/null @@ -1,38 +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 com.example.loan.model; - -public class Response { - - private int count; - - public Response(int count) { - this.count = count; - } - - public Response() { - } - - public int getCount() { - return this.count; - } - - public void setCount(int count) { - this.count = count; - } - -} diff --git a/samples/standalone/dsl/http-client/src/main/resources/application.yml b/samples/standalone/dsl/http-client/src/main/resources/application.yml deleted file mode 100644 index 2de2007e6b..0000000000 --- a/samples/standalone/dsl/http-client/src/main/resources/application.yml +++ /dev/null @@ -1,7 +0,0 @@ -server.port: 8090 -spring: - cloud: - function: - definition: listener - stream: - bindings.listener-in-0.destination: sensor_data \ No newline at end of file diff --git a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/GoodbyeWorldTests.java b/samples/standalone/dsl/http-client/src/test/java/com/example/loan/GoodbyeWorldTests.java deleted file mode 100644 index 1328eba404..0000000000 --- a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/GoodbyeWorldTests.java +++ /dev/null @@ -1,55 +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 com.example.loan; - -import org.junit.jupiter.api.Test; - - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerPort; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties; - -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -// tag::autoconfigure_stubrunner[] - -@SpringBootTest(webEnvironment = WebEnvironment.NONE) -@AutoConfigureStubRunner(ids = { - "com.example:http-server-dsl"}, - repositoryRoot = "stubs://classpath:contractsAtRuntime/", - stubsMode = StubRunnerProperties.StubsMode.LOCAL, - generateStubs = true) -public class GoodbyeWorldTests { - // end::autoconfigure_stubrunner[] - - @StubRunnerPort("http-server-dsl") - int port; - - @Test - public void shouldGenerateStubsAtRuntime() { - // when: - String response = new RestTemplate().getForObject("http://localhost:" + this.port + "/goodbye", String.class); - // then: - assertThat(response) - .isEqualTo("Goodbye World!"); - } - -} diff --git a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceContextPathTests.java b/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceContextPathTests.java deleted file mode 100644 index f30cac7186..0000000000 --- a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceContextPathTests.java +++ /dev/null @@ -1,70 +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 com.example.loan; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties; - - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = "server.context-path=/app") -@AutoConfigureStubRunner(ids = { - "com.example:http-server-dsl:0.0.1:stubs:6565" }, stubsMode = StubRunnerProperties.StubsMode.LOCAL) -public class LoanApplicationServiceContextPathTests { - - @Autowired - private LoanApplicationService service; - - @Test - public void shouldSuccessfullyApplyForLoan() { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} diff --git a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java b/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java deleted file mode 100644 index 2d419b6a02..0000000000 --- a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java +++ /dev/null @@ -1,228 +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 com.example.loan; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.time.Duration; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.JsonPath; -import io.restassured.RestAssured; -import io.restassured.response.ResponseOptions; -import io.restassured.specification.RequestSpecification; -import org.assertj.core.api.BDDAssertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerPort; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties; -import org.springframework.http.RequestEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; - -import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson; -import static org.assertj.core.api.Assertions.assertThat; - -// tag::autoconfigure_stubrunner[] - -@SpringBootTest(webEnvironment = WebEnvironment.NONE) -@AutoConfigureStubRunner(ids = { - "com.example:http-server-dsl:0.0.1:stubs"}, stubsMode = StubRunnerProperties.StubsMode.LOCAL) -public class LoanApplicationServiceTests { - - // end::autoconfigure_stubrunner[] - - @StubRunnerPort("com.example:http-server-dsl") - private int stubPort; - - @Autowired - private LoanApplicationService service; - - @BeforeEach - public void setup() { - this.service.setPrefix(""); - this.service.setPort(this.stubPort); - } - - @Test - public void shouldSuccessfullyApplyForLoan() { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - // tag::client_tdd[] - @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - // end::client_tdd[] - - @Test - public void shouldSuccessfullyGetAllFrauds() { - // when: - int count = service.countAllFrauds(); - // then: - assertThat(count).isGreaterThanOrEqualTo(200); - } - - @Test - public void shouldSuccessfullyGetAllDrunks() { - // when: - int count = service.countDrunks(); - // then: - assertThat(count).isEqualTo(100); - } - - // metadata - @Test - public void shouldFailToSuccessfullyGetAllDrunksDueToTimeout() { - LoanApplicationService service = new LoanApplicationService(new RestTemplateBuilder().setReadTimeout(Duration.ofSeconds(1))); - service.setPort(this.stubPort); - // when: - BDDAssertions.thenThrownBy(service::countDrunks).hasMessageContaining("Read timed out"); - } - - @Test - public void shouldSuccessfullyGetCookies() { - // when: - String cookies = service.getCookies(); - // then: - assertThat(cookies).isEqualTo("foo bar"); - } - - @Test - public void shouldSuccessfullyWorkWithMultipart() { - // given: - RequestSpecification request = RestAssured.given() - .baseUri("http://localhost:" + stubPort + "/") - .header("Content-Type", "multipart/form-data") - .multiPart("file1", "filename1", "content1".getBytes()) - .multiPart("file2", "filename1", "content2".getBytes()).multiPart("test", - "filename1", "{\n \"status\": \"test\"\n}".getBytes(), - "application/json"); - - // when: - ResponseOptions response = RestAssured.given().spec(request).post("/tests"); - - // then: - assertThat(response.statusCode()).isEqualTo(200); - assertThat(response.header("Content-Type")).matches("application/json.*"); - // and: - DocumentContext parsedJson = JsonPath.parse(response.getBody().asString()); - assertThatJson(parsedJson).field("['status']").isEqualTo("ok"); - } - - @Test - public void shouldSuccessfullyWorkWithBinary() throws IOException { - // given: - File request = new File(LoanApplicationServiceTests.class - .getResource("/binary/request.pdf").getFile()); - File response = new File(LoanApplicationServiceTests.class - .getResource("/binary/response.pdf").getFile()); - - // when: - ResponseEntity exchange = new RestTemplate() - .exchange( - RequestEntity.put(URI.create("http://localhost:" + stubPort + "/1")) - .header("Content-Type", "application/octet-stream") - .body(Files.readAllBytes(request.toPath())), - byte[].class); - - // then: - assertThat(exchange.getStatusCodeValue()).isEqualTo(200); - assertThat(exchange.getHeaders().get("Content-Type").get(0)) - .isEqualTo("application/octet-stream"); - // and: - assertThat(exchange.getBody()).isEqualTo(Files.readAllBytes(response.toPath())); - } - - - @Test - public void shouldSuccessfullyApplyForLoanForYaml() { - this.service.setPrefix("yaml"); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - public void shouldBeRejectedDueToAbnormalLoanAmountForYaml() { - this.service.setPrefix("yaml"); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - - @Test - public void shouldSuccessfullyGetAllFraudsForYaml() { - this.service.setPrefix("yaml"); - // when: - int count = service.countAllFrauds(); - // then: - assertThat(count).isGreaterThanOrEqualTo(200); - } - - // metadata - @Test - public void shouldFailToSuccessfullyGetAllDrunksDueToTimeoutForYaml() { - LoanApplicationService service = new LoanApplicationService(new RestTemplateBuilder().setReadTimeout(Duration.ofSeconds(1))); - service.setPort(this.stubPort); - service.setPrefix("yaml"); - // when: - BDDAssertions.thenThrownBy(service::countAllFrauds).hasMessageContaining("Read timed out"); - } - -} \ No newline at end of file diff --git a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/MessageConsumedTests.java b/samples/standalone/dsl/http-client/src/test/java/com/example/loan/MessageConsumedTests.java deleted file mode 100644 index a581f3da18..0000000000 --- a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/MessageConsumedTests.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2016-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 com.example.loan; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.cloud.contract.stubrunner.StubTrigger; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties; -import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Marius Bogoevici - */ -@SpringBootTest(webEnvironment = WebEnvironment.NONE, properties = "spring.cloud.stream.bindings.input.destination=sensor-data", classes = {MessageConsumedTests.Config.class, Application.class}) -@AutoConfigureStubRunner(ids = "com.example:http-server-dsl:0.0.1", stubsMode = StubRunnerProperties.StubsMode.LOCAL) -public class MessageConsumedTests { - - @Autowired - StubTrigger stubTrigger; - - @Autowired - Listener listener; - - @Test - public void testMessageConsumed() throws Exception { - int count = this.listener.getCount(); - stubTrigger.trigger("sensor1"); - assertThat(this.listener.getCount()).isEqualTo(count + 1); - } - - @TestConfiguration - @ImportAutoConfiguration(TestChannelBinderConfiguration.class) - static class Config { - - } -} diff --git a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/TestControllerTests.java b/samples/standalone/dsl/http-client/src/test/java/com/example/loan/TestControllerTests.java deleted file mode 100644 index 01f0ff4b41..0000000000 --- a/samples/standalone/dsl/http-client/src/test/java/com/example/loan/TestControllerTests.java +++ /dev/null @@ -1,55 +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 com.example.loan; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerPort; -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties; -import org.springframework.http.ResponseEntity; - -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -// tag::autoconfigure_stubrunner[] - -@SpringBootTest(webEnvironment = WebEnvironment.NONE) -@AutoConfigureStubRunner(ids = { - "com.example:http-server-dsl:0.0.1:stubs:6565"}, stubsMode = StubRunnerProperties.StubsMode.LOCAL) -@Disabled("TODO: Need to fix java parsing") -public class TestControllerTests { - // end::autoconfigure_stubrunner[] - - @StubRunnerPort("http-server-dsl") - int port; - - @Test - public void should_work_with_java_dsl() { - // when: - ResponseEntity response = new RestTemplate() - .getForEntity("http://localhost:" + this.port + "/example", String.class); - // then: - assertThat(response.getStatusCodeValue()).isEqualTo(200); - } - -} diff --git a/samples/standalone/dsl/http-client/src/test/resources/application-gradle.yaml b/samples/standalone/dsl/http-client/src/test/resources/application-gradle.yaml deleted file mode 100644 index 3de9f8be98..0000000000 --- a/samples/standalone/dsl/http-client/src/test/resources/application-gradle.yaml +++ /dev/null @@ -1,3 +0,0 @@ -stubrunner: - stubs-mode: local - stubs.ids: 'com.example:http-server-dsl-gradle:+:stubs:6565' diff --git a/samples/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml b/samples/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml deleted file mode 100644 index 512cbc68e7..0000000000 --- a/samples/standalone/dsl/http-client/src/test/resources/application-test-repo.yaml +++ /dev/null @@ -1,3 +0,0 @@ -stubrunner: - ids: 'com.example:http-server-dsl:+:stubs:8080' - repositoryRoot: https://repo.spring.io/libs-snapshot diff --git a/samples/standalone/dsl/http-client/src/test/resources/application.yaml b/samples/standalone/dsl/http-client/src/test/resources/application.yaml deleted file mode 100644 index 78a78e6fa6..0000000000 --- a/samples/standalone/dsl/http-client/src/test/resources/application.yaml +++ /dev/null @@ -1,5 +0,0 @@ -server: - port: 6565 -logging: - level: - org.springframework.cloud.contract: debug diff --git a/samples/standalone/dsl/http-client/src/test/resources/binary/request.pdf b/samples/standalone/dsl/http-client/src/test/resources/binary/request.pdf deleted file mode 100644 index 69503635d8..0000000000 Binary files a/samples/standalone/dsl/http-client/src/test/resources/binary/request.pdf and /dev/null differ diff --git a/samples/standalone/dsl/http-client/src/test/resources/binary/response.pdf b/samples/standalone/dsl/http-client/src/test/resources/binary/response.pdf deleted file mode 100644 index c3b233056b..0000000000 Binary files a/samples/standalone/dsl/http-client/src/test/resources/binary/response.pdf and /dev/null differ diff --git a/samples/standalone/dsl/http-client/src/test/resources/contractsAtRuntime/goodbyeWorld.groovy b/samples/standalone/dsl/http-client/src/test/resources/contractsAtRuntime/goodbyeWorld.groovy deleted file mode 100644 index c432ed21e9..0000000000 --- a/samples/standalone/dsl/http-client/src/test/resources/contractsAtRuntime/goodbyeWorld.groovy +++ /dev/null @@ -1,28 +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. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - url("/goodbye") - method(GET()) - } - response { - status(OK()) - body("Goodbye World!") - } -} diff --git a/samples/standalone/dsl/http-server/.gitignore b/samples/standalone/dsl/http-server/.gitignore deleted file mode 100644 index b05ba7bd6d..0000000000 --- a/samples/standalone/dsl/http-server/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ - -target/ - -.gradle -build/ - diff --git a/samples/standalone/dsl/http-server/.mvn/jvm.config b/samples/standalone/dsl/http-server/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/dsl/http-server/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/dsl/http-server/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/dsl/http-server/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/dsl/http-server/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/dsl/http-server/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/dsl/http-server/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/dsl/http-server/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/dsl/http-server/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/dsl/http-server/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/dsl/http-server/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/dsl/http-server/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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-server/README.adoc b/samples/standalone/dsl/http-server/README.adoc deleted file mode 100644 index 2fd3fbc40d..0000000000 --- a/samples/standalone/dsl/http-server/README.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= Http Server - -Run - -[source=groovy] --------- -./gradlew clean build publishToMavenLocal --------- - -or - --------- -./mvnw clean install --------- - -To - -- build the app -- generate and run Spring Cloud Contract Verifier tests -- publish the fatJar and the stubs to Maven Local \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/build.gradle b/samples/standalone/dsl/http-server/build.gradle deleted file mode 100644 index ee8ee3d41a..0000000000 --- a/samples/standalone/dsl/http-server/build.gradle +++ /dev/null @@ -1,95 +0,0 @@ -plugins { - id "java" - id "org.springframework.boot" - id "io.spring.dependency-management" - id "org.springframework.cloud.contract" - id "maven-publish" -} - -group = 'com.example' -version = '0.0.1' - -// tag::deps_repos[] -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} -// end::deps_repos[] - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:$verifierVersion" - mavenBom "org.springframework.cloud:spring-cloud-stream-dependencies:$springCloudStreamVersion" - } -} - -contracts { - packageWithBaseClasses = 'com.example.fraud' -// convertToYaml = true - contractsDslDir = file("src/test/resources/contracts") -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.cloud:spring-cloud-starter-stream-rabbit") - - testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-verifier' - testImplementation(group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-binder') - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude(group: 'org.junit.vintage', module: 'junit-vintage-engine') - } -} - -contractTest { - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -publishing { - publications { - maven(MavenPublication) { - artifact bootJar - artifact verifierStubsJar - - // https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273 - versionMapping { - usage("java-api") { - fromResolutionOf("runtimeClasspath") - } - usage("java-runtime") { - fromResolutionResult() - } - } - } - } -} - -clean.doFirst { - delete "~/.m2/repository/com/example/http-server-dsl-gradle" -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/dsl/http-server/gradle.properties b/samples/standalone/dsl/http-server/gradle.properties deleted file mode 100644 index 7ae982c8ff..0000000000 --- a/samples/standalone/dsl/http-server/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -springCloudStreamVersion=4.1.4-SNAPSHOT -bootVersion=3.2.7 \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c49..0000000000 Binary files a/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ac72c34e8a..0000000000 --- a/samples/standalone/dsl/http-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/dsl/http-server/gradlew b/samples/standalone/dsl/http-server/gradlew deleted file mode 100755 index 0adc8e1a53..0000000000 --- a/samples/standalone/dsl/http-server/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/dsl/http-server/gradlew.bat b/samples/standalone/dsl/http-server/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/dsl/http-server/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/dsl/http-server/mvnw b/samples/standalone/dsl/http-server/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/dsl/http-server/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/dsl/http-server/mvnw.cmd b/samples/standalone/dsl/http-server/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/dsl/http-server/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/dsl/http-server/pom.xml b/samples/standalone/dsl/http-server/pom.xml deleted file mode 100644 index 745278a1df..0000000000 --- a/samples/standalone/dsl/http-server/pom.xml +++ /dev/null @@ -1,333 +0,0 @@ - - - 4.0.0 - - com.example - http-server-dsl - 0.0.1 - - Spring Cloud Contract Verifier Http Server Sample - Spring Cloud Contract Verifier Http Server Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - 4.1.4-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - org.springframework.cloud - spring-cloud-starter-stream-rabbit - - - - org.springframework.cloud - spring-cloud-stream-test-binder - test - - - - - org.springframework.cloud - spring-cloud-starter-contract-verifier - test - - - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.springframework.cloud - spring-cloud-contract-maven-plugin - ${spring-cloud-contract.version} - true - - com.example.fraud - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - org.apache.maven.plugins - maven-clean-plugin - 3.0.0 - - - - build - - - target - - - - - - maven-surefire-plugin - - true - - - - org.apache.maven.plugins - maven-antrun-plugin - 3.1.0 - - - process-test-resources - - - - - - - - - - - - - - - - - - - - - - - - - run - - - - - - ant-contrib - ant-contrib - 20020829 - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.springframework.cloud - spring-cloud-contract-maven-plugin - - - [${spring-cloud-contract.version},) - - - convert - generateTests - - - - - - - - - - - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - - integration - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -x - contractTest - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - gradlew.bat - - clean - build - publishToMavenLocal - - -x - test - - -x - contractTest - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - diff --git a/samples/standalone/dsl/http-server/settings.gradle b/samples/standalone/dsl/http-server/settings.gradle deleted file mode 100644 index ec18a29444..0000000000 --- a/samples/standalone/dsl/http-server/settings.gradle +++ /dev/null @@ -1,24 +0,0 @@ -// tag::repos[] -pluginManagement { - repositories { - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - gradlePluginPortal() - } -// end::repos[] - plugins { - id "org.springframework.boot" version "${bootVersion}" - id "io.spring.dependency-management" version "1.1.3" - } - resolutionStrategy { - eachPlugin { - // protects us in case the gradle-portal-plugin hasn't yet been published by Maven - if (requested.id.id == 'org.springframework.cloud.contract') { - useModule("org.springframework.cloud:spring-cloud-contract-gradle-plugin:${verifierVersion}") - } - } - } -} - -rootProject.name = 'http-server-dsl-gradle' diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/Application.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/Application.java deleted file mode 100644 index b4562bfce3..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/Application.java +++ /dev/null @@ -1,29 +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 com.example.fraud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FooController.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FooController.java deleted file mode 100644 index 168967c6f2..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FooController.java +++ /dev/null @@ -1,33 +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 com.example.fraud; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Marcin Grzejszczak - */ -@RestController -class FooController { - - @GetMapping("/foo") - void foo() { - - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java deleted file mode 100644 index bf84fc94ba..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudDetectionController.java +++ /dev/null @@ -1,63 +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 com.example.fraud; - -import java.math.BigDecimal; - -import com.example.fraud.model.FraudCheck; -import com.example.fraud.model.FraudCheckResult; -import com.example.fraud.model.FraudCheckStatus; - -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -@RestController -public class FraudDetectionController { - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - // tag::server_api[] - @RequestMapping(value = "/fraudcheck", method = PUT) - public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) { - // end::server_api[] - // tag::new_impl[] - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FraudCheckStatus.FRAUD, AMOUNT_TOO_HIGH); - } - // end::new_impl[] - // tag::initial_impl[] - return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON); - // end::initial_impl[] - } - - @RequestMapping(value = "/yamlfraudcheck", method = PUT) - public FraudCheckResult yamlFraudCheck(@RequestBody FraudCheck fraudCheck) { - return fraudCheck(fraudCheck); - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudNameController.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudNameController.java deleted file mode 100644 index 3b638e5b7d..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudNameController.java +++ /dev/null @@ -1,122 +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 com.example.fraud; - -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -interface FraudVerifier { - - boolean isFraudByName(String name); - -} - -/** - * @author Marcin Grzejszczak - */ -@RestController -class FraudNameController { - - private final FraudVerifier fraudVerifier; - - FraudNameController(FraudVerifier fraudVerifier) { - this.fraudVerifier = fraudVerifier; - } - - @PutMapping(value = "/frauds/name") - public NameResponse checkByName(@RequestBody NameRequest request) { - boolean fraud = this.fraudVerifier.isFraudByName(request.getName()); - if (fraud) { - return new NameResponse("Sorry " + request.getName() + " but you're a fraud"); - } - return new NameResponse( - "Don't worry " + request.getName() + " you're not a fraud"); - } - - @GetMapping(value = "/frauds/name") - public String checkByName(@CookieValue("name") String value, - @CookieValue("name2") String value2) { - return value + " " + value2; - } - - @PutMapping(value = "/yamlfrauds/name") - public NameResponse yamlCheckByName(@RequestBody NameRequest request) { - return checkByName(request); - } - - @GetMapping(value = "/yamlfrauds/name") - public String yamlCheckByName(@CookieValue("name") String value, - @CookieValue("name2") String value2) { - return checkByName(value, value2); - } - -} - -class NameRequest { - - private String name; - - public NameRequest(String name) { - this.name = name; - } - - public NameRequest() { - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - -} - -class NameResponse { - - private String result; - - public NameResponse(String result) { - this.result = result; - } - - public NameResponse() { - } - - public String getResult() { - return this.result; - } - - public void setResult(String result) { - this.result = result; - } - -} - -@Component -class DefaultFraudVerifier implements FraudVerifier { - - @Override - public boolean isFraudByName(String name) { - return true; - } -} \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudStatsController.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudStatsController.java deleted file mode 100644 index c8b7f11ca7..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/FraudStatsController.java +++ /dev/null @@ -1,94 +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 com.example.fraud; - -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -enum FraudType { - - DRUNKS, ALL - -} - -interface StatsProvider { - - int count(FraudType fraudType); - -} - -@RestController -public class FraudStatsController { - - private final StatsProvider statsProvider; - - public FraudStatsController(StatsProvider statsProvider) { - this.statsProvider = statsProvider; - } - - @GetMapping(value = "/frauds") - public Response countAllFrauds() { - return new Response(this.statsProvider.count(FraudType.ALL)); - } - - @GetMapping(value = "/yamlfrauds") - public Response countAllYamlFrauds() { - return countAllFrauds(); - } - - @GetMapping(value = "/drunks") - public Response countAllDrunks() { - return new Response(this.statsProvider.count(FraudType.DRUNKS)); - } - - @GetMapping(value = "/yamldrunks") - public Response countAllYamlDrunks() { - return countAllDrunks(); - } - -} - -class Response { - - private int count; - - public Response(int count) { - this.count = count; - } - - public Response() { - } - - public int getCount() { - return this.count; - } - - public void setCount(int count) { - this.count = count; - } - -} - -@Component -class DefaultStatsProvider implements StatsProvider { - - @Override - public int count(FraudType fraudType) { - return 0; - } -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessageSender.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessageSender.java deleted file mode 100644 index 9de0b3c5a1..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessageSender.java +++ /dev/null @@ -1,64 +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 com.example.fraud; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.cloud.stream.function.StreamBridge; -import org.springframework.stereotype.Component; - -@Component -class MessageSender { - - private static final Logger log = LoggerFactory.getLogger(MessageSender.class); - - private final StreamBridge streamBridge; - - private final byte[] expectedOutput; - - MessageSender(StreamBridge streamBridge) { - this.streamBridge = streamBridge; - this.expectedOutput = forFile("/contracts/messaging/output.pdf"); - } - - public void emit() { - log.info("Emitting the message"); - this.streamBridge.send("sensor_data-out-0", "{\"id\":\"99\",\"temperature\":\"123.45\"}"); - } - - public void emitBytes() { - log.info("Emitting the message"); - this.streamBridge.send("my_output-out-0", this.expectedOutput); - } - - private byte[] forFile(String relative) { - URL resource = MessageSender.class.getResource(relative); - try { - return Files.readAllBytes(new File(resource.toURI()).toPath()); - } - catch (IOException | URISyntaxException ex) { - throw new IllegalStateException(ex); - } - } -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessagingConfiguration.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessagingConfiguration.java deleted file mode 100644 index bfcc6f6e83..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/MessagingConfiguration.java +++ /dev/null @@ -1,39 +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 com.example.fraud; - -import java.util.function.Supplier; - -import reactor.core.publisher.EmitterProcessor; -import reactor.core.publisher.Flux; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -class MessagingConfiguration { - - @Bean - EmitterProcessor sensorDataEmitter() { - return EmitterProcessor.create(); - } - - @Bean(name = "sensor_data") - Supplier> sensorData(EmitterProcessor processor) { - return () -> processor; - } -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/TestController.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/TestController.java deleted file mode 100644 index a52d073eeb..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/TestController.java +++ /dev/null @@ -1,97 +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 com.example.fraud; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.util.Arrays; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -@RestController -public class TestController { - - private final byte[] request; - - private final byte[] response; - - public TestController() { - this.request = toByte( - TestController.class.getResource("/contracts/binary/request.pdf")); - this.response = toByte( - TestController.class.getResource("/contracts/binary/response.pdf")); - } - - private byte[] toByte(URL url) { - try { - return Files.readAllBytes(new File(url.toURI()).toPath()); - } - catch (URISyntaxException | IOException ex) { - throw new IllegalStateException(ex); - } - } - - @PostMapping("/tests") - public Test createNew(@RequestPart MultipartFile file1, - @RequestPart MultipartFile file2, @RequestPart Test test) { - return new Test("ok"); - } - - @GetMapping("/example") - public void example() { - } - - @PutMapping(value = "/1", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) - public byte[] response(@RequestBody byte[] requestBody) { - if (!Arrays.equals(this.request, requestBody)) { - throw new IllegalStateException("Invalid request body"); - } - return this.response; - } - -} - -class Test { - - private String status; - - public Test(String status) { - this.status = status; - } - - public Test() { - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheck.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheck.java deleted file mode 100644 index d0e348db27..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheck.java +++ /dev/null @@ -1,49 +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 com.example.fraud.model; - -import java.math.BigDecimal; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FraudCheck { - - @JsonProperty("client.id") - private String clientId; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java deleted file mode 100644 index c908038d0a..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java +++ /dev/null @@ -1,52 +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 com.example.fraud.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - @JsonProperty("rejection.reason") - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java b/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java deleted file mode 100644 index a43b649f5c..0000000000 --- a/samples/standalone/dsl/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.fraud.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/dsl/http-server/src/main/resources/application.properties b/samples/standalone/dsl/http-server/src/main/resources/application.properties deleted file mode 100644 index 506b4f78c1..0000000000 --- a/samples/standalone/dsl/http-server/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -spring.cloud.function.definition=my_output;sensor_data -spring.cloud.stream.bindings.sensor_data-out-0.destination=sensor_data -spring.cloud.stream.bindings.my_output-out-0.contentType=application/octet-stream -spring.cloud.stream.bindings.my_output-out-0.destination=bytes_output -server.port=0 diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/BinaryBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/BinaryBase.java deleted file mode 100644 index bfcd40f7c4..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/BinaryBase.java +++ /dev/null @@ -1,29 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class BinaryBase { - - @BeforeEach - public void setUp() throws Exception { - RestAssuredMockMvc.standaloneSetup(new TestController()); - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudBase.java deleted file mode 100644 index 3e462aa229..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudBase.java +++ /dev/null @@ -1,46 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class FraudBase { - - @BeforeEach - public void setup() { - RestAssuredMockMvc.standaloneSetup(new FraudDetectionController(), - new FraudStatsController(stubbedStatsProvider())); - } - - private StatsProvider stubbedStatsProvider() { - return fraudType -> { - switch (fraudType) { - case DRUNKS: - return 100; - case ALL: - return 200; - } - return 0; - }; - } - - public void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudnameBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudnameBase.java deleted file mode 100644 index f38066f2bb..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/FraudnameBase.java +++ /dev/null @@ -1,33 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class FraudnameBase { - - private static final String FRAUD_NAME = "fraud"; - - FraudVerifier fraudVerifier = FRAUD_NAME::equals; - - @BeforeEach - public void setup() { - RestAssuredMockMvc.standaloneSetup(new FraudNameController(this.fraudVerifier)); - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MessagingBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MessagingBase.java deleted file mode 100644 index aa08e66bfe..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MessagingBase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016-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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier; -import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.context.WebApplicationContext; - -/** - * Base class for sensor autogenerated tests (used by Spring Cloud Contract). - * - * This bootstraps the Spring Boot application code. - * - * @author Marius Bogoevici - */ - -@SpringBootTest(classes = {MessagingBase.Config.class, Application.class}) -@AutoConfigureMessageVerifier -public abstract class MessagingBase { - - @Autowired - MessageSender messageSender; - - @Autowired - WebApplicationContext context; - - @BeforeEach - public void setup() { - RestAssuredMockMvc.webAppContextSetup(this.context); - } - - public void createSensorData() { - messageSender.emit(); - } - - public void createBinaryPayload() { - messageSender.emitBytes(); - } - - @Configuration - @ImportAutoConfiguration(TestChannelBinderConfiguration.class) - static class Config { - - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MultipartBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MultipartBase.java deleted file mode 100644 index fa82da0402..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/MultipartBase.java +++ /dev/null @@ -1,29 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class MultipartBase { - - @BeforeEach - public void setUp() throws Exception { - RestAssuredMockMvc.standaloneSetup(new TestController()); - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/TestBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/TestBase.java deleted file mode 100644 index 6a1c81d89e..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/TestBase.java +++ /dev/null @@ -1,29 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class TestBase { - - @BeforeEach - public void setUp() throws Exception { - RestAssuredMockMvc.standaloneSetup(new TestController()); - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudBase.java deleted file mode 100644 index 4e46c07838..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudBase.java +++ /dev/null @@ -1,46 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class YmlFraudBase { - - @BeforeEach - public void setup() { - RestAssuredMockMvc.standaloneSetup(new FraudDetectionController(), - new FraudStatsController(stubbedStatsProvider())); - } - - private StatsProvider stubbedStatsProvider() { - return fraudType -> { - switch (fraudType) { - case DRUNKS: - return 100; - case ALL: - return 200; - } - return 0; - }; - } - - public void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudnameBase.java b/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudnameBase.java deleted file mode 100644 index abe32e3f04..0000000000 --- a/samples/standalone/dsl/http-server/src/test/java/com/example/fraud/YmlFraudnameBase.java +++ /dev/null @@ -1,33 +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 com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; - -public class YmlFraudnameBase { - - private static final String FRAUD_NAME = "fraud"; - - FraudVerifier fraudVerifier = FRAUD_NAME::equals; - - @BeforeEach - public void setup() { - RestAssuredMockMvc.standaloneSetup(new FraudNameController(this.fraudVerifier)); - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/request.pdf b/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/request.pdf deleted file mode 100644 index 69503635d8..0000000000 Binary files a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/request.pdf and /dev/null differ diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/response.pdf b/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/response.pdf deleted file mode 100644 index c3b233056b..0000000000 Binary files a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/response.pdf and /dev/null differ diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/shouldWorkWithBinaryPayload.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/shouldWorkWithBinaryPayload.groovy deleted file mode 100644 index 494ddd7cd4..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/binary/shouldWorkWithBinaryPayload.groovy +++ /dev/null @@ -1,37 +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 contracts - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - url("/1") - method(PUT()) - headers { - contentType(applicationOctetStream()) - } - body(fileAsBytes("request.pdf")) - } - response { - status 200 - body(fileAsBytes("response.pdf")) - headers { - contentType(applicationOctetStream()) - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy deleted file mode 100644 index d056ad13f6..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsFraud.groovy +++ /dev/null @@ -1,73 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - request { // (1) - method 'PUT' // (2) - url '/fraudcheck' // (3) - body([ // (4) - "client.id": $(regex('[0-9]{10}')), - loanAmount : 99999 - ]) - headers { // (5) - contentType('application/json') - } - } - response { // (6) - status OK() // (7) - body([ // (8) - fraudCheckStatus : "FRAUD", - "rejection.reason": "Amount too high" - ]) - headers { // (9) - contentType('application/json') - } - } -} - -/* -From the Consumer perspective, when shooting a request in the integration test: - -(1) - If the consumer sends a request -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `client.id` that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/json` -(6) - then the response will be sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` equal to `application/json` - -From the Producer perspective, in the autogenerated producer-side test: - -(1) - A request will be sent to the producer -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `client.id` that will have a generated value that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/json` -(6) - then the test will assert if the response has been sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` matching `application/json.*` - */ diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsNotFraud.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsNotFraud.groovy deleted file mode 100644 index e84c69038e..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldMarkClientAsNotFraud.groovy +++ /dev/null @@ -1,49 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "client.id":"${ - value(consumer(regex('[0-9]{10}')), producer('1234567890')) - }", - "loanAmount":123.123 - } - """ - ) - headers { - contentType("application/json") - } - - } - response { - status OK() - body( - fraudCheckStatus: "OK", - "rejection.reason": $(consumer(null), - producer(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - contentType("application/json") - } - } - -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldReturnFraudStats.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldReturnFraudStats.groovy deleted file mode 100644 index c84fe3ef5a..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraud/shouldReturnFraudStats.groovy +++ /dev/null @@ -1,66 +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 contracts - -import org.springframework.cloud.contract.spec.Contract - -[ - Contract.make { - request { - name "should count all frauds" - method GET() - url '/frauds' - } - response { - status OK() - body([ - count: $(regex("[2-9][0-9][0-9]").asInteger()) - ]) - headers { - contentType("application/json") - } - } - }, - // tag::metadata[] - Contract.make { - request { - method GET() - url '/drunks' - } - response { - status OK() - body([ - count: 100 - ]) - headers { - contentType("application/json") - } - } - metadata([ - wiremock: [ - stubMapping: '''\ - { - "response" : { - "fixedDelayMilliseconds": 2000 - } - } - ''' - ] - ]) - } - // end::metadata[] -] diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnACookie.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnACookie.groovy deleted file mode 100644 index 5861f0a1d7..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnACookie.groovy +++ /dev/null @@ -1,32 +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 contracts.fraudname - -org.springframework.cloud.contract.spec.Contract.make { - request { - method GET() - url '/frauds/name' - cookies { - cookie("name", "foo") - cookie(name2: "bar") - } - } - response { - status 200 - body("foo bar") - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnAFraudForTheName.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnAFraudForTheName.groovy deleted file mode 100644 index d9b83251f9..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnAFraudForTheName.groovy +++ /dev/null @@ -1,41 +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 contracts.fraudname - -org.springframework.cloud.contract.spec.Contract.make { - // highest priority - priority(1) - request { - method PUT() - url '/frauds/name' - body([ - name: "fraud" - ]) - headers { - contentType("application/json") - } - } - response { - status OK() - body([ - result: "Sorry ${fromRequest().body('$.name')} but you're a fraud" - ]) - headers { - header(contentType(), "${fromRequest().header(contentType())}") - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnNonFraudForTheName.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnNonFraudForTheName.groovy deleted file mode 100644 index 90467d12f3..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/fraudname/shouldReturnNonFraudForTheName.groovy +++ /dev/null @@ -1,39 +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 contracts.fraudname - -org.springframework.cloud.contract.spec.Contract.make { - request { - method PUT() - url '/frauds/name' - body([ - name: $(anyAlphaUnicode()) - ]) - headers { - contentType("application/json") - } - } - response { - status OK() - body([ - result: "Don't worry ${fromRequest().body('$.name')} you're not a fraud" - ]) - headers { - header(contentType(), "${fromRequest().header(contentType())}") - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/output.pdf b/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/output.pdf deleted file mode 100644 index c3b233056b..0000000000 Binary files a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/output.pdf and /dev/null differ diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldProduceValidSensorData.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldProduceValidSensorData.groovy deleted file mode 100644 index c9eb219453..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldProduceValidSensorData.groovy +++ /dev/null @@ -1,42 +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 contracts - -org.springframework.cloud.contract.spec.Contract.make { - // Human readable description - description 'Should produce valid sensor data' - // Label by means of which the output message can be triggered - label 'sensor1' - // input to the contract - input { - // the contract will be triggered by a method - triggeredBy('createSensorData()') - } - // output message of the contract - outputMessage { - // destination to which the output message will be sent - sentTo 'sensor_data' - headers { - header('contentType': 'application/json') - } - // the body of the output message - body([ - id : $(consumer(9), producer(regex("[0-9]+"))), - temperature: "123.45" - ]) - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldReturnOkWhenServiceIsHealthy.yml b/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldReturnOkWhenServiceIsHealthy.yml deleted file mode 100644 index 6360b45b39..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldReturnOkWhenServiceIsHealthy.yml +++ /dev/null @@ -1,6 +0,0 @@ -description: Should return 200 for /foo -request: - url: /foo - method: GET -response: - status: 200 \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldWorkWithInputOutputBinary.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldWorkWithInputOutputBinary.groovy deleted file mode 100644 index decdfd910d..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/messaging/shouldWorkWithInputOutputBinary.groovy +++ /dev/null @@ -1,33 +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 contracts - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - label("positive") - input { - triggeredBy("createBinaryPayload()") - } - outputMessage { - sentTo("bytes_output") - body(fileAsBytes("output.pdf")) - headers { - messagingContentType(applicationOctetStream()) - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartAsBytesWithContentType.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartAsBytesWithContentType.groovy deleted file mode 100644 index 1881dbb7e6..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartAsBytesWithContentType.groovy +++ /dev/null @@ -1,52 +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. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method 'POST' - url '/tests' - multipart( - [ - file1: named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: value(consumer(regex(nonEmpty())), producer('content1'))), - file2: named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: value(c(regex(nonEmpty())), producer('content2'))), - test : named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: - value(c(regex(nonEmpty())), producer(fileAsBytes("test.json"))), - contentType: value("application/json")) - ] - ) - - headers { - contentType('multipart/form-data') - } - } - response { - status 200 - body([ - status: 'ok' - ]) - headers { - contentType('application/json') - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartWithContentType.groovy b/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartWithContentType.groovy deleted file mode 100644 index 7fa5e05814..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/shouldWorkForMultipartWithContentType.groovy +++ /dev/null @@ -1,35 +0,0 @@ -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method 'POST' - url '/tests' - multipart( - [ - file1: named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: value(consumer(regex(nonEmpty())), producer('content1'))), - file2: named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: value(c(regex(nonEmpty())), producer('content2'))), - test : named( - name: value(consumer(regex(nonEmpty())), producer('filename1')), - content: value(c(regex(nonEmpty())), producer(file("test.json"))), - contentType: value("application/json")) - ] - ) - - headers { - contentType('multipart/form-data') - } - } - response { - status 200 - body([ - status: 'ok' - ]) - headers { - contentType('application/json') - } - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/test.json b/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/test.json deleted file mode 100644 index 984c08fbdf..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/multipart/test.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "test" -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/test/MyHttpContract.java b/samples/standalone/dsl/http-server/src/test/resources/contracts/test/MyHttpContract.java deleted file mode 100644 index 3be89863a6..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/test/MyHttpContract.java +++ /dev/null @@ -1,36 +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 test; - -import java.util.function.Supplier; - -import org.springframework.cloud.contract.spec.Contract; - -class MyHttpContract implements Supplier { - @Override - public Contract get() { - return Contract.make(c -> { - c.request(r -> { - r.method(r.GET()); - r.url("/example"); - }); - c.response(r -> { - r.status(r.OK()); - }); - }); - } -} diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/test/request.json b/samples/standalone/dsl/http-server/src/test/resources/contracts/test/request.json deleted file mode 100644 index 7cef5bbd05..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/test/request.json +++ /dev/null @@ -1 +0,0 @@ -{ "hello" : "world" } \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml b/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml deleted file mode 100644 index eb0656569e..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsFraud.yml +++ /dev/null @@ -1,52 +0,0 @@ -request: # (1) - method: PUT # (2) - url: /yamlfraudcheck # (3) - body: # (4) - "client.id": 1234567890 - loanAmount: 99999 - headers: # (5) - Content-Type: application/json - matchers: - body: - - path: $.['client.id'] # (6) - type: by_regex - value: "[0-9]{10}" -response: # (7) - status: 200 # (8) - body: # (9) - fraudCheckStatus: "FRAUD" - "rejection.reason": "Amount too high" - headers: # (10) - Content-Type: application/json - - -#From the Consumer perspective, when shooting a request in the integration test: -# -#(1) - If the consumer sends a request -#(2) - With the "PUT" method -#(3) - to the URL "/yamlfraudcheck" -#(4) - with the JSON body that -# * has a field `client.id` -# * has a field `loanAmount` that is equal to `99999` -#(5) - with header `Content-Type` equal to `application/json` -#(6) - and a `client.id` json entry matches the regular expression `[0-9]{10}` -#(7) - then the response will be sent with -#(8) - status equal `200` -#(9) - and JSON body equal to -# { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -#(10) - with header `Content-Type` equal to `application/json` -# -#From the Producer perspective, in the autogenerated producer-side test: -# -#(1) - A request will be sent to the producer -#(2) - With the "PUT" method -#(3) - to the URL "/yamlfraudcheck" -#(4) - with the JSON body that -# * has a field `client.id` `1234567890` -# * has a field `loanAmount` that is equal to `99999` -#(5) - with header `Content-Type` equal to `application/json` -#(7) - then the test will assert if the response has been sent with -#(8) - status equal `200` -#(9) - and JSON body equal to -# { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -#(10) - with header `Content-Type` equal to `application/json` \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsNotFraud.yaml b/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsNotFraud.yaml deleted file mode 100644 index 550322aa86..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldMarkClientAsNotFraud.yaml +++ /dev/null @@ -1,25 +0,0 @@ -request: - method: PUT - url: /yamlfraudcheck - body: - "client.id": 1234567890 - loanAmount: 123.123 - headers: - Content-Type: application/json - matchers: - body: - - path: $.['client.id'] - type: by_regex - value: "[0-9]{10}" -response: - status: 200 - body: - fraudCheckStatus: "OK" - "rejection.reason": null - headers: - Content-Type: application/json - matchers: - body: - - path: $.['rejection.reason'] - type: by_command - value: assertThatRejectionReasonIsNull($it) diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldReturnFraudStats.yml b/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldReturnFraudStats.yml deleted file mode 100644 index e14f824f07..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraud/shouldReturnFraudStats.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# tag::metadata[] -name: "should count all frauds" -request: - method: GET - url: /yamlfrauds -response: - status: 200 - body: - count: 200 - headers: - Content-Type: application/json -metadata: - wiremock: - stubMapping: > - { - "response" : { - "fixedDelayMilliseconds": 2000 - } - } -# end::metadata[] ---- -request: - method: GET - url: /yamldrunks -response: - status: 200 - body: - count: 100 - headers: - Content-Type: application/json \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnAFraudForTheName.yml b/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnAFraudForTheName.yml deleted file mode 100644 index 5e06866b80..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnAFraudForTheName.yml +++ /dev/null @@ -1,15 +0,0 @@ -# highest priority -priority: 1 -request: - method: PUT - url: /yamlfrauds/name - body: - name: "fraud" - headers: - Content-Type: application/json -response: - status: 200 - body: - result: "Sorry {{{ jsonpath this '$.name' }}} but you're a fraud" - headers: - Content-Type: "{{{ request.headers.Content-Type.0 }}}" \ No newline at end of file diff --git a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnNonFraudForTheName.yml b/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnNonFraudForTheName.yml deleted file mode 100644 index c0a8e14a07..0000000000 --- a/samples/standalone/dsl/http-server/src/test/resources/contracts/yml/fraudname/shouldReturnNonFraudForTheName.yml +++ /dev/null @@ -1,18 +0,0 @@ -request: - method: PUT - url: /yamlfrauds/name - body: - name: "non fraud" - headers: - Content-Type: application/json - matchers: - body: - - path: $.name - type: by_regex - predefined: only_alpha_unicode -response: - status: 200 - body: - result: "Don't worry {{{ jsonpath this '$.name' }}} you're not a fraud" - headers: - Content-Type: "{{{ request.headers.Content-Type.0 }}}" \ No newline at end of file diff --git a/samples/standalone/dsl/pom.xml b/samples/standalone/dsl/pom.xml deleted file mode 100644 index 227c914195..0000000000 --- a/samples/standalone/dsl/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.springframework.cloud - spring-cloud-contract-samples-standalone - 4.1.5-SNAPSHOT - .. - - - spring-cloud-contract-samples-dsl - pom - - Spring Cloud Contract Standalone Dsl Test Samples - Spring Cloud Contract Standalone Test Samples used for end to end tests - - - - 4.1.5-SNAPSHOT - - - - http-server - http-client - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - - - diff --git a/samples/standalone/mvnw b/samples/standalone/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/mvnw.cmd b/samples/standalone/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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 deleted file mode 100644 index 2a1bffc950..0000000000 --- a/samples/standalone/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - - org.springframework.cloud - spring-cloud-contract-samples - 4.2.0-SNAPSHOT - .. - - - spring-cloud-contract-samples-standalone - pom - 4.2.0-SNAPSHOT - Spring Cloud Contract Standalone Test Samples - Spring Cloud Contract Standalone Test Samples used for end to end tests - - - - ${project.version} - - - - contracts - restdocs - dsl - webclient - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.0.0 - - - - build - - - target - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - - diff --git a/samples/standalone/restdocs/http-client/.gitignore b/samples/standalone/restdocs/http-client/.gitignore deleted file mode 100644 index a275b7b864..0000000000 --- a/samples/standalone/restdocs/http-client/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ - -target/ - -.gradle -build/ - -/.apt_generated/ diff --git a/samples/standalone/restdocs/http-client/.mvn/jvm.config b/samples/standalone/restdocs/http-client/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/restdocs/http-client/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/restdocs/http-client/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/restdocs/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/restdocs/http-client/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/restdocs/http-client/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/restdocs/http-client/README.adoc b/samples/standalone/restdocs/http-client/README.adoc deleted file mode 100644 index cdcb0e4a56..0000000000 --- a/samples/standalone/restdocs/http-client/README.adoc +++ /dev/null @@ -1,26 +0,0 @@ -= Http Client - -== Prerequisites - -First you have to publish to Maven Local the stubs of the *http-server* module - -== How to run it? - -Run - -[source=groovy] --------- -./gradlew clean build --------- - -or - --------- -./mvnw clean package --------- - -To - -- build the app -- use spring-cloud-contract-stub-runner-spring[Stub Runner Spring] to download the stub of `Http Server` -- run the tests against stubbed server \ No newline at end of file diff --git a/samples/standalone/restdocs/http-client/build.gradle b/samples/standalone/restdocs/http-client/build.gradle deleted file mode 100644 index 9e4c683718..0000000000 --- a/samples/standalone/restdocs/http-client/build.gradle +++ /dev/null @@ -1,75 +0,0 @@ -buildscript { - repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - } - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:${findProperty('bootVersion') ?: bootVersion}" - } -} - -group = 'com.example' -version = '0.0.1' - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} - -apply plugin: 'groovy' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' -apply plugin: 'maven-publish' - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:$verifierVersion" - mavenBom "org.springframework.cloud:spring-cloud-stream-dependencies:$springCloudStreamVersion" - } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") - - testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' - testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation "com.example:http-server-restdocs:0.0.1:stubs" -} - -test { - useJUnitPlatform() - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/restdocs/http-client/gradle.properties b/samples/standalone/restdocs/http-client/gradle.properties deleted file mode 100644 index 7ae982c8ff..0000000000 --- a/samples/standalone/restdocs/http-client/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -springCloudStreamVersion=4.1.4-SNAPSHOT -bootVersion=3.2.7 \ No newline at end of file diff --git a/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c49..0000000000 Binary files a/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ac72c34e8a..0000000000 --- a/samples/standalone/restdocs/http-client/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/restdocs/http-client/gradlew b/samples/standalone/restdocs/http-client/gradlew deleted file mode 100755 index 0adc8e1a53..0000000000 --- a/samples/standalone/restdocs/http-client/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/restdocs/http-client/gradlew.bat b/samples/standalone/restdocs/http-client/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/restdocs/http-client/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/restdocs/http-client/mvnw b/samples/standalone/restdocs/http-client/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/restdocs/http-client/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/restdocs/http-client/mvnw.cmd b/samples/standalone/restdocs/http-client/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/restdocs/http-client/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/restdocs/http-client/pom.xml b/samples/standalone/restdocs/http-client/pom.xml deleted file mode 100644 index e8d4ac5f3a..0000000000 --- a/samples/standalone/restdocs/http-client/pom.xml +++ /dev/null @@ -1,259 +0,0 @@ - - - - - 4.0.0 - - com.example - http-client-restdocs - 0.0.1 - - Spring Cloud Contract RestDocs Http Client Sample - Spring Cloud Contract RestDocs Http Client Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - org.springframework.cloud - spring-cloud-contract-wiremock - test - - - org.springframework.cloud - spring-cloud-contract-stub-runner - test - - - - org.apache.httpcomponents.client5 - httpclient5 - - - org.slf4j - slf4j-api - - - compile - - - - com.example - http-server-restdocs - stubs - 0.0.1 - test - - - * - * - - - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-deploy-plugin - - true - - - - maven-surefire-plugin - - true - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - integration - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - - diff --git a/samples/standalone/restdocs/http-client/settings.gradle b/samples/standalone/restdocs/http-client/settings.gradle deleted file mode 100644 index 877b12b9ab..0000000000 --- a/samples/standalone/restdocs/http-client/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'http-client-restdocs-gradle' diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/Application.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/Application.java deleted file mode 100644 index 63645c66f5..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/Application.java +++ /dev/null @@ -1,31 +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 com.example.loan; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -@SpringBootApplication -@EnableConfigurationProperties(ServiceConfiguration.class) -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/LoanApplicationService.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/LoanApplicationService.java deleted file mode 100644 index 0e29422963..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/LoanApplicationService.java +++ /dev/null @@ -1,110 +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 com.example.loan; - -import com.example.loan.model.FraudCheckStatus; -import com.example.loan.model.FraudServiceRequest; -import com.example.loan.model.FraudServiceResponse; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private final RestTemplate restTemplate; - - private final ServiceConfiguration serviceConfiguration; - - public LoanApplicationService(ServiceConfiguration serviceConfiguration) { - this.restTemplate = new RestTemplate(); - // tag::custom_request_factory[] - this.restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory()); - // end::custom_request_factory[] - this.serviceConfiguration = serviceConfiguration; - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1); - - // tag::client_call_server[] - ResponseEntity response = restTemplate.exchange( - "http://localhost:" + getPort() + "/fraudcheck", HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - // end::client_call_server[] - - return response.getBody(); - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public int getPort() { - return this.serviceConfiguration.getPort(); - } - - public void setPort(int port) { - this.serviceConfiguration.setPort(port); - } - -} - -@ConfigurationProperties("service") -class ServiceConfiguration { - - private int port = 8080; - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/Client.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/Client.java deleted file mode 100644 index 8fac47b2fd..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/Client.java +++ /dev/null @@ -1,38 +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 com.example.loan.model; - -public class Client { - - private String pesel; - - public Client() { - } - - public Client(String pesel) { - this.pesel = pesel; - } - - public String getPesel() { - return pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java deleted file mode 100644 index 01f2969113..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java deleted file mode 100644 index 379d32e340..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java +++ /dev/null @@ -1,51 +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 com.example.loan.model; - -import java.math.BigDecimal; - -public class FraudServiceRequest { - - private String clientId; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientId = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java deleted file mode 100644 index c7d3aca9fb..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java +++ /dev/null @@ -1,44 +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 com.example.loan.model; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplication.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplication.java deleted file mode 100644 index e2f4aa2513..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplication.java +++ /dev/null @@ -1,61 +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 com.example.loan.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public LoanApplication() { - } - - public LoanApplication(Client client, double amount) { - this.client = client; - this.amount = BigDecimal.valueOf(amount); - } - - public Client getClient() { - return client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java deleted file mode 100644 index 73501084bb..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +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 com.example.loan.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java b/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java deleted file mode 100644 index 5afde21afc..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/samples/standalone/restdocs/http-client/src/main/resources/application.yml b/samples/standalone/restdocs/http-client/src/main/resources/application.yml deleted file mode 100644 index 456f83e828..0000000000 --- a/samples/standalone/restdocs/http-client/src/main/resources/application.yml +++ /dev/null @@ -1,6 +0,0 @@ -server.port: 8097 -logging: - level: - org.springframework.cloud.contract.wiremock: debug - org.springframework.web.client: debug - com.github.tomakehurst.wiremock: trace \ No newline at end of file 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 deleted file mode 100644 index bc2cdc6777..0000000000 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java +++ /dev/null @@ -1,87 +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 com.example.loan; - -import java.nio.charset.Charset; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.stubbing.StubMapping; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.core.io.Resource; - -import org.springframework.util.StreamUtils; - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest(properties = "service.port=${wiremock.server.port}") -@AutoConfigureWireMock(port = 0) -class LoanApplicationServiceTests { - - @Autowired - private LoanApplicationService service; - - @Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1/mappings/standalone/shouldMarkClientAsFraud.json") - private Resource markClientAsFraud; - - @Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1/mappings/webapp/shouldMarkClientAsNotFraud.json") - private Resource markClientAsNotFraud; - - @Autowired - private WireMockServer server; - - @Test - void shouldSuccessfullyApplyForLoan() throws Exception { - server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( - markClientAsNotFraud.getInputStream(), Charset.forName("UTF-8")))); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { - server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( - markClientAsFraud.getInputStream(), Charset.forName("UTF-8")))); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} 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 deleted file mode 100644 index 7398319c0f..0000000000 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java +++ /dev/null @@ -1,77 +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 com.example.loan; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; - - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest -@AutoConfigureStubRunner(ids = "com.example:http-server-restdocs") -class LoanApplicationServiceusingStubRunnerTests { - - @Autowired - LoanApplicationService service; - - @Value("${stubrunner.runningstubs.http-server-restdocs.port}") - int port; - - @BeforeEach - public void setup() { - this.service.setPort(this.port); - } - - @Test - void shouldSuccessfullyApplyForLoan() throws Exception { - // given - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} 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 deleted file mode 100644 index cf57d978f7..0000000000 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceTests.java +++ /dev/null @@ -1,109 +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 com.example.loan; - -import java.net.URI; -import java.nio.charset.Charset; - -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.stubbing.StubMapping; -import org.assertj.core.api.BDDAssertions; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.core.io.Resource; -import org.springframework.http.MediaType; -import org.springframework.http.RequestEntity; -import org.springframework.http.ResponseEntity; - -import org.springframework.util.StreamUtils; -import org.springframework.web.client.RestTemplate; - - -@SpringBootTest(properties = "service.port=${wiremock.server.port}") -@AutoConfigureWireMock(port = 0) -class XmlServiceTests { - - @Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1/mappings/should_return_empty_content.json") - private Resource empty; - - @Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1/mappings/should_return_full_content.json") - private Resource full; - - @Autowired - private WireMockServer server; - - @Test - void shouldSuccessfullyReturnFullResponse() throws Exception { - server.addStubMapping(StubMapping.buildFrom(StreamUtils - .copyToString(full.getInputStream(), Charset.forName("UTF-8")))); - - ResponseEntity responseEntity = new RestTemplate() - .exchange(RequestEntity - .post(URI.create( - "http://localhost:" + server.port() + "/xmlfraud")) - .contentType(MediaType.valueOf("application/xml;charset=UTF-8")) - .body(new XmlRequestBody("foo")), XmlResponseBody.class); - - BDDAssertions.then(responseEntity.getStatusCodeValue()).isEqualTo(200); - BDDAssertions.then(responseEntity.getBody().status).isEqualTo("FULL"); - } - - @Test - void shouldSuccessfullyReturnEmptyResponse() throws Exception { - server.addStubMapping(StubMapping.buildFrom(StreamUtils - .copyToString(empty.getInputStream(), Charset.forName("UTF-8")))); - - ResponseEntity responseEntity = new RestTemplate() - .exchange(RequestEntity - .post(URI.create( - "http://localhost:" + server.port() + "/xmlfraud")) - .contentType(MediaType.valueOf("application/xml;charset=UTF-8")) - .body(new XmlRequestBody("")), XmlResponseBody.class); - - BDDAssertions.then(responseEntity.getStatusCodeValue()).isEqualTo(200); - BDDAssertions.then(responseEntity.getBody().status).isEqualTo("EMPTY"); - } - -} - -class XmlRequestBody { - - public String name; - - public XmlRequestBody(String name) { - this.name = name; - } - -} - -class XmlResponseBody { - - public String status; - - public XmlResponseBody(String status) { - this.status = status; - } - - public XmlResponseBody() { - } - -} 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 deleted file mode 100644 index 68212120c7..0000000000 --- a/samples/standalone/restdocs/http-client/src/test/java/com/example/loan/XmlServiceUsingStubRunnerTests.java +++ /dev/null @@ -1,66 +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 com.example.loan; - -import java.net.URI; - -import org.assertj.core.api.BDDAssertions; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; -import org.springframework.http.MediaType; -import org.springframework.http.RequestEntity; -import org.springframework.http.ResponseEntity; - -import org.springframework.web.client.RestTemplate; - - -@SpringBootTest -@AutoConfigureStubRunner(ids = "com.example:http-server-restdocs") -class XmlServiceUsingStubRunnerTests { - - @Value("${stubrunner.runningstubs.http-server-restdocs.port}") - int port; - - @Test - void shouldSuccessfullyReturnFullResponse() throws Exception { - ResponseEntity responseEntity = new RestTemplate() - .exchange(RequestEntity - .post(URI.create("http://localhost:" + this.port + "/xmlfraud")) - .contentType(MediaType.valueOf("application/xml;charset=UTF-8")) - .body(new XmlRequestBody("foo")), XmlResponseBody.class); - - BDDAssertions.then(responseEntity.getStatusCodeValue()).isEqualTo(200); - BDDAssertions.then(responseEntity.getBody().status).isEqualTo("FULL"); - } - - @Test - void shouldSuccessfullyReturnEmptyResponse() throws Exception { - ResponseEntity responseEntity = new RestTemplate() - .exchange(RequestEntity - .post(URI.create("http://localhost:" + this.port + "/xmlfraud")) - .contentType(MediaType.valueOf("application/xml;charset=UTF-8")) - .body(new XmlRequestBody("")), XmlResponseBody.class); - - BDDAssertions.then(responseEntity.getStatusCodeValue()).isEqualTo(200); - BDDAssertions.then(responseEntity.getBody().status).isEqualTo("EMPTY"); - } - -} diff --git a/samples/standalone/restdocs/http-client/src/test/resources/application-gradle.yaml b/samples/standalone/restdocs/http-client/src/test/resources/application-gradle.yaml deleted file mode 100644 index b1818d9164..0000000000 --- a/samples/standalone/restdocs/http-client/src/test/resources/application-gradle.yaml +++ /dev/null @@ -1,2 +0,0 @@ -stubrunner: - stubs.ids: 'com.example:http-server-restdocs-gradle' diff --git a/samples/standalone/restdocs/http-server/.gitignore b/samples/standalone/restdocs/http-server/.gitignore deleted file mode 100644 index b05ba7bd6d..0000000000 --- a/samples/standalone/restdocs/http-server/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ - -target/ - -.gradle -build/ - diff --git a/samples/standalone/restdocs/http-server/.mvn/jvm.config b/samples/standalone/restdocs/http-server/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/restdocs/http-server/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/restdocs/http-server/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/restdocs/http-server/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/restdocs/http-server/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/restdocs/http-server/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/restdocs/http-server/README.adoc b/samples/standalone/restdocs/http-server/README.adoc deleted file mode 100644 index 2fd3fbc40d..0000000000 --- a/samples/standalone/restdocs/http-server/README.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= Http Server - -Run - -[source=groovy] --------- -./gradlew clean build publishToMavenLocal --------- - -or - --------- -./mvnw clean install --------- - -To - -- build the app -- generate and run Spring Cloud Contract Verifier tests -- publish the fatJar and the stubs to Maven Local \ No newline at end of file diff --git a/samples/standalone/restdocs/http-server/build.gradle b/samples/standalone/restdocs/http-server/build.gradle deleted file mode 100644 index 5fde7e7a5f..0000000000 --- a/samples/standalone/restdocs/http-server/build.gradle +++ /dev/null @@ -1,128 +0,0 @@ -plugins { - id "groovy" - id "org.springframework.boot" - id "io.spring.dependency-management" - id "org.springframework.cloud.contract" - id "maven-publish" -} - -group = 'com.example' -version = '0.0.1' - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}" - } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") - - testImplementation('org.springframework.boot:spring-boot-starter-test') - testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner' - // tag::dependencies[] - testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-verifier' - testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' - // end::dependencies[] -} - -contracts { - baseClassMappings { - baseClassMapping('.*standalone.*', 'com.example.fraud.FraudBaseWithStandaloneSetup') - baseClassMapping('.*webapp.*', 'com.example.fraud.FraudBaseWithWebAppSetup') - } -} - -generateClientStubs.enabled = false - -test { - useJUnitPlatform() - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -task stubsJar(type: Jar, dependsOn: ['copySnippets', 'copySources', 'copyClasses']) { - archiveBaseName = project.name - archiveClassifier = 'stubs' - from project.file("${project.buildDir}/stubs") -} - -task copySnippets(type: Copy, dependsOn: test) { - from "target/snippets/stubs" - into "${project.buildDir}/stubs/META-INF/${project.group}/${project.name}/${project.version}/mappings" -} - -task copySources(type: Copy) { - from "src/main/java" - include '**/model/Fraud*.*' - into "${project.buildDir}/stubs/" -} - -task copyClasses(type: Copy) { - from "${project.buildDir}/classes/main/" - include '**/model/Fraud*.*' - into "${project.buildDir}/stubs/" -} - - -project.tasks.named("verifierStubsJar").get().dependsOn('copySnippets', 'copySources', 'stubsJar') // TODO: We need to fix this -project.tasks.named("copyContracts").get().dependsOn('stubsJar') // TODO: We need to fix this -afterEvaluate { - project.tasks.matching { it.name.contains("publish") }.each { it.dependsOn('verifierStubsJar') } // TODO: We need to fix this -} - -publishing { - publications { - maven(MavenPublication) { - artifact bootJar - artifact stubsJar - - // https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273 - versionMapping { - usage("java-api") { - fromResolutionOf("runtimeClasspath") - } - usage("java-runtime") { - fromResolutionResult() - } - } - } - } -} - -clean.doFirst { - delete 'target/snippets/stubs' - delete "~/.m2/repository/com/example/http-server-restdocs-gradle" -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/restdocs/http-server/gradle.properties b/samples/standalone/restdocs/http-server/gradle.properties deleted file mode 100644 index 1696bd82a9..0000000000 --- a/samples/standalone/restdocs/http-server/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -bootVersion=3.2.7 diff --git a/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c49..0000000000 Binary files a/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ac72c34e8a..0000000000 --- a/samples/standalone/restdocs/http-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/restdocs/http-server/gradlew b/samples/standalone/restdocs/http-server/gradlew deleted file mode 100755 index 0adc8e1a53..0000000000 --- a/samples/standalone/restdocs/http-server/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/restdocs/http-server/gradlew.bat b/samples/standalone/restdocs/http-server/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/restdocs/http-server/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/restdocs/http-server/mvnw b/samples/standalone/restdocs/http-server/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/restdocs/http-server/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/restdocs/http-server/mvnw.cmd b/samples/standalone/restdocs/http-server/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/restdocs/http-server/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/restdocs/http-server/pom.xml b/samples/standalone/restdocs/http-server/pom.xml deleted file mode 100644 index 44c34e3a0c..0000000000 --- a/samples/standalone/restdocs/http-server/pom.xml +++ /dev/null @@ -1,274 +0,0 @@ - - - 4.0.0 - - com.example - http-server-restdocs - 0.0.1 - - Spring Cloud Contract RestDocs Http Server Sample - Spring Cloud RestDocs Verifier Http Server Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - true - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.cloud - spring-cloud-starter-contract-stub-runner - test - - - - org.springframework.cloud - spring-cloud-starter-contract-verifier - test - - - org.springframework.restdocs - spring-restdocs-mockmvc - true - - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-clean-plugin - - - - build - - - target - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - stub - prepare-package - - single - - false - - true - - ${basedir}/src/assembly/stub.xml - - - - - - - maven-surefire-plugin - - true - - - - - org.springframework.cloud - spring-cloud-contract-maven-plugin - ${spring-cloud-contract.version} - true - - - - .*standalone.* - com.example.fraud.FraudBaseWithStandaloneSetup - - - - .*webapp.* - com.example.fraud.FraudBaseWithWebAppSetup - - - - - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - gradlew.bat - - clean - build - - install - - -x - test - - -x - contractTest - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - diff --git a/samples/standalone/restdocs/http-server/settings.gradle b/samples/standalone/restdocs/http-server/settings.gradle deleted file mode 100644 index 8d6570b7b8..0000000000 --- a/samples/standalone/restdocs/http-server/settings.gradle +++ /dev/null @@ -1,22 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - gradlePluginPortal() - } - plugins { - id 'org.springframework.boot' version "${bootVersion}" - id "io.spring.dependency-management" version "1.1.3" - } - resolutionStrategy { - eachPlugin { - // protects us in case the gradle-portal-plugin hasn't yet been published by Maven - if (requested.id.id == 'org.springframework.cloud.contract') { - useModule("org.springframework.cloud:spring-cloud-contract-gradle-plugin:${verifierVersion}") - } - } - } -} - -rootProject.name = 'http-server-restdocs-gradle' diff --git a/samples/standalone/restdocs/http-server/src/assembly/stub.xml b/samples/standalone/restdocs/http-server/src/assembly/stub.xml deleted file mode 100644 index 310a3af245..0000000000 --- a/samples/standalone/restdocs/http-server/src/assembly/stub.xml +++ /dev/null @@ -1,51 +0,0 @@ - - stubs - - jar - - false - - - src/main/java - / - - **/model/Fraud*.* - - - - ${project.build.directory}/classes - / - - **/model/Fraud*.* - - - - ${project.build.directory}/generated-snippets/stubs - - META-INF/${project.groupId}/${project.artifactId}/${project.version}/mappings - - - **/* - - - - ${project.build.directory}/snippets/stubs - - META-INF/${project.groupId}/${project.artifactId}/${project.version}/mappings - - - **/* - - - - ${project.build.directory}/stubs - / - - **/* - - - - diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/Application.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/Application.java deleted file mode 100644 index c998b507b2..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/Application.java +++ /dev/null @@ -1,33 +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 com.example.fraud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionController.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionController.java deleted file mode 100644 index 1d5469e93f..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionController.java +++ /dev/null @@ -1,60 +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 com.example.fraud; - -import java.math.BigDecimal; - -import com.example.fraud.model.FraudCheck; -import com.example.fraud.model.FraudCheckResult; -import com.example.fraud.model.FraudCheckStatus; - -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -@RestController -public class FraudDetectionController { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - // tag::server_api[] - @RequestMapping(value = "/fraudcheck", method = PUT, consumes = FRAUD_SERVICE_JSON_VERSION_1, produces = FRAUD_SERVICE_JSON_VERSION_1) - public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) { - // end::server_api[] - // tag::new_impl[] - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FraudCheckStatus.FRAUD, AMOUNT_TOO_HIGH); - } - // end::new_impl[] - // tag::initial_impl[] - return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON); - // end::initial_impl[] - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionXmlController.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionXmlController.java deleted file mode 100644 index 7db345a02f..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/FraudDetectionXmlController.java +++ /dev/null @@ -1,59 +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 com.example.fraud; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -@Controller -public class FraudDetectionXmlController { - - @RequestMapping(value = "/xmlfraud", method = POST, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE) - @ResponseBody - public XmlResponseBody xmlResponseBody(@RequestBody XmlRequestBody xmlRequestBody) { - if (!StringUtils.hasText(xmlRequestBody.name)) { - return new XmlResponseBody("EMPTY"); - } - return new XmlResponseBody("FULL"); - } - -} - -class XmlRequestBody { - - public String name; - -} - -class XmlResponseBody { - - public String status; - - public XmlResponseBody(String status) { - this.status = status; - } - - public XmlResponseBody() { - } - -} diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheck.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheck.java deleted file mode 100644 index 4cf6ae3ea2..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheck.java +++ /dev/null @@ -1,46 +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 com.example.fraud.model; - -import java.math.BigDecimal; - -public class FraudCheck { - - private String clientId; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java deleted file mode 100644 index 95440c6790..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java +++ /dev/null @@ -1,49 +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 com.example.fraud.model; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java b/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java deleted file mode 100644 index a43b649f5c..0000000000 --- a/samples/standalone/restdocs/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.fraud.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/restdocs/http-server/src/main/resources/application.yml b/samples/standalone/restdocs/http-server/src/main/resources/application.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithStandaloneSetup.java b/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithStandaloneSetup.java deleted file mode 100644 index 5af34819b5..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithStandaloneSetup.java +++ /dev/null @@ -1,45 +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. - */ - -// tag::base_class[] -package com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.restdocs.RestDocumentationContextProvider; -import org.springframework.restdocs.RestDocumentationExtension; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; - -@ExtendWith(RestDocumentationExtension.class) -public abstract class FraudBaseWithStandaloneSetup { - - @BeforeEach - public void setup(TestInfo info, RestDocumentationContextProvider restDocumentation) { - RestAssuredMockMvc.standaloneSetup(MockMvcBuilders - .standaloneSetup(new FraudDetectionController()) - .apply(documentationConfiguration(restDocumentation)) - .alwaysDo(document( - getClass().getSimpleName() + "_" + info.getDisplayName()))); - } - -} -// end::base_class[] diff --git a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithWebAppSetup.java b/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithWebAppSetup.java deleted file mode 100644 index 5a7e68a9ba..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/FraudBaseWithWebAppSetup.java +++ /dev/null @@ -1,56 +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. - */ - -// tag::base_class[] -package com.example.fraud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.restdocs.RestDocumentationContextProvider; -import org.springframework.restdocs.RestDocumentationExtension; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; - -@ExtendWith(RestDocumentationExtension.class) -@SpringBootTest(classes = Application.class) -public abstract class FraudBaseWithWebAppSetup { - - @Autowired - private WebApplicationContext context; - - @BeforeEach - public void setup(TestInfo info, RestDocumentationContextProvider restDocumentation) { - RestAssuredMockMvc.mockMvc(MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(restDocumentation)) - .alwaysDo(document( - getClass().getSimpleName() + "_" + info.getDisplayName())) - .build()); - } - - protected void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} -// end::base_class[] diff --git a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java b/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java deleted file mode 100644 index e159ec787a..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java +++ /dev/null @@ -1,92 +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 com.example.fraud; - -import java.math.BigDecimal; - -import com.example.fraud.model.FraudCheck; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.json.JacksonTester; -import org.springframework.http.MediaType; - -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; - -import static org.springframework.cloud.contract.wiremock.restdocs.WireMockRestDocs.verify; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; - -@SpringBootTest(classes = Application.class) -@AutoConfigureRestDocs(outputDir = "target/snippets") -@AutoConfigureMockMvc -@AutoConfigureJsonTesters -public class StubGeneratorTests { - - @Autowired - private MockMvc mockMvc; - - private JacksonTester json; - - @BeforeEach - public void setup() { - ObjectMapper objectMappper = new ObjectMapper(); - // Possibly configure the mapper - JacksonTester.initFields(this, objectMappper); - } - - @Test - public void shouldMarkClientAsFraud() throws Exception { - FraudCheck fraudCheck = new FraudCheck(); - fraudCheck.setClientId("1234567890"); - fraudCheck.setLoanAmount(BigDecimal.valueOf(99999.0)); - mockMvc.perform(MockMvcRequestBuilders.put("/fraudcheck") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json")) - .content(json.write(fraudCheck).getJson())) - .andExpect(jsonPath("$.fraudCheckStatus").value("FRAUD")) - .andExpect(jsonPath("$.rejectionReason").value("Amount too high")) - .andDo(verify().jsonPath("$.clientId") - .jsonPath("$[?(@.loanAmount > 1000)]") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))) - .andDo(document("markClientAsFraud")); - } - - @Test - public void shouldMarkClientAsNotFraud() throws Exception { - FraudCheck fraudCheck = new FraudCheck(); - fraudCheck.setClientId("1234567890"); - fraudCheck.setLoanAmount(BigDecimal.valueOf(123.123)); - mockMvc.perform(MockMvcRequestBuilders.put("/fraudcheck") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json")) - .content(json.write(fraudCheck).getJson())) - .andExpect(jsonPath("$.fraudCheckStatus").value("OK")) - .andExpect(jsonPath("$.rejectionReason").doesNotExist()) - .andDo(verify().jsonPath("$.clientId") - .jsonPath("$[?(@.loanAmount <= 1000)]") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))) - .andDo(document("markClientAsNotFraud")); - } - -} 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 deleted file mode 100644 index 610573ee41..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/java/com/example/fraud/XmlStubGeneratorTests.java +++ /dev/null @@ -1,62 +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 com.example.fraud; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.MediaType; -import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; - -import org.springframework.test.web.servlet.MockMvc; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@SpringBootTest(classes = Application.class) -@AutoConfigureRestDocs(outputDir = "target/snippets") -@AutoConfigureMockMvc -class XmlStubGeneratorTests { - - @Autowired - private MockMvc mockMvc; - - @Test - void should_return_full_content() throws Exception { - mockMvc.perform(post("/xmlfraud").contentType(MediaType.APPLICATION_XML) - .content("foo")) - .andExpect(status().is2xxSuccessful()) - .andExpect(content().string( - "FULL")) - .andDo(MockMvcRestDocumentation.document("{methodName}")); - } - - @Test - void should_return_empty_content() throws Exception { - mockMvc.perform(post("/xmlfraud").contentType(MediaType.APPLICATION_XML) - .content("")) - .andExpect(status().is2xxSuccessful()) - .andExpect(content().string( - "EMPTY")) - .andDo(MockMvcRestDocumentation.document("{methodName}")); - } - -} diff --git a/samples/standalone/restdocs/http-server/src/test/resources/contracts/standalone/shouldMarkClientAsFraud.groovy b/samples/standalone/restdocs/http-server/src/test/resources/contracts/standalone/shouldMarkClientAsFraud.groovy deleted file mode 100644 index ca4e321816..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/resources/contracts/standalone/shouldMarkClientAsFraud.groovy +++ /dev/null @@ -1,82 +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 contracts.standalone - -org.springframework.cloud.contract.spec.Contract.make { - request { // (1) - method 'PUT' // (2) - url '/fraudcheck' // (3) - body([ // (4) - clientId : $(c(regex('[0-9]{10}')), p("8532032713")), - loanAmount: 99999 - ]) - headers { // (5) - contentType('application/vnd.fraud.v1+json') - } - } - response { // (6) - status OK() // (7) - body([ // (8) - fraudCheckStatus: "FRAUD", - rejectionReason : "Amount too high" - ]) - headers { // (9) - contentType('application/vnd.fraud.v1+json') - } - } -} - -/* -Since we don't want to force on the user to hardcode values of fields that are dynamic -(timestamps, database ids etc.), one can parametrize those entries. If you wrap your field's - value in a `$(...)` or `value(...)` and provide a dynamic value of a field then - the concrete value will be generated for you. If you want to be really explicit about - which side gets which value you can do that by using the `value(consumer(...), producer(...))` notation. - That way what's present in the `consumer` section will end up in the produced stub. What's - there in the `producer` will end up in the autogenerated test. If you provide only the - regular expression side without the concrete value then Spring Cloud Contract will generate one for you. - -From the Consumer perspective, when shooting a request in the integration test: - -(1) - If the consumer sends a request -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the response will be sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` - -From the Producer perspective, in the autogenerated producer-side test: - -(1) - A request will be sent to the producer -(2) - With the "PUT" method -(3) - to the URL "/fraudcheck" -(4) - with the JSON body that - * has a field `clientId` that will have a generated value that matches a regular expression `[0-9]{10}` - * has a field `loanAmount` that is equal to `99999` -(5) - with header `Content-Type` equal to `application/vnd.fraud.v1+json` -(6) - then the test will assert if the response has been sent with -(7) - status equal `200` -(8) - and JSON body equal to - { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" } -(9) - with header `Content-Type` matching `application/vnd.fraud.v1+json.*` - */ diff --git a/samples/standalone/restdocs/http-server/src/test/resources/contracts/webapp/shouldMarkClientAsNotFraud.groovy b/samples/standalone/restdocs/http-server/src/test/resources/contracts/webapp/shouldMarkClientAsNotFraud.groovy deleted file mode 100644 index ec4dc73cc5..0000000000 --- a/samples/standalone/restdocs/http-server/src/test/resources/contracts/webapp/shouldMarkClientAsNotFraud.groovy +++ /dev/null @@ -1,46 +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 contracts.webapp - -org.springframework.cloud.contract.spec.Contract.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "clientId":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}", - "loanAmount":123.123 - } - """ - ) - headers { - contentType("application/vnd.fraud.v1+json") - } - - } - response { - status OK() - body( - fraudCheckStatus: "OK", - rejectionReason: $(consumer(null), - producer(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - contentType("application/vnd.fraud.v1+json") - } - } -} diff --git a/samples/standalone/restdocs/pom.xml b/samples/standalone/restdocs/pom.xml deleted file mode 100644 index 1b4e9c40b6..0000000000 --- a/samples/standalone/restdocs/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.springframework.cloud - spring-cloud-contract-samples-standalone - 4.1.5-SNAPSHOT - .. - - - spring-cloud-contract-samples-restdocs - pom - - Spring Cloud Contract Standalone Restdocs Test Samples - Spring Cloud Contract Standalone Test Samples used for end to end tests - - - - 4.1.5-SNAPSHOT - - - - http-server - http-client - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - - - diff --git a/samples/standalone/webclient/http-client/.gitignore b/samples/standalone/webclient/http-client/.gitignore deleted file mode 100644 index a275b7b864..0000000000 --- a/samples/standalone/webclient/http-client/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ - -target/ - -.gradle -build/ - -/.apt_generated/ diff --git a/samples/standalone/webclient/http-client/.mvn/jvm.config b/samples/standalone/webclient/http-client/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/webclient/http-client/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/webclient/http-client/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/webclient/http-client/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/webclient/http-client/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/webclient/http-client/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/webclient/http-client/README.adoc b/samples/standalone/webclient/http-client/README.adoc deleted file mode 100644 index cdcb0e4a56..0000000000 --- a/samples/standalone/webclient/http-client/README.adoc +++ /dev/null @@ -1,26 +0,0 @@ -= Http Client - -== Prerequisites - -First you have to publish to Maven Local the stubs of the *http-server* module - -== How to run it? - -Run - -[source=groovy] --------- -./gradlew clean build --------- - -or - --------- -./mvnw clean package --------- - -To - -- build the app -- use spring-cloud-contract-stub-runner-spring[Stub Runner Spring] to download the stub of `Http Server` -- run the tests against stubbed server \ No newline at end of file diff --git a/samples/standalone/webclient/http-client/build.gradle b/samples/standalone/webclient/http-client/build.gradle deleted file mode 100644 index 95edc7e2c2..0000000000 --- a/samples/standalone/webclient/http-client/build.gradle +++ /dev/null @@ -1,64 +0,0 @@ -plugins { - id "groovy" - id "org.springframework.boot" - id "io.spring.dependency-management" - id "maven-publish" -} - -group = 'com.example' -version = '0.0.1' - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}" - } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-actuator") - - testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' - testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation "com.example:http-server-webclient:0.0.1:stubs" -} - -test { - useJUnitPlatform() - include '**/*GradleTests*' - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/webclient/http-client/gradle.properties b/samples/standalone/webclient/http-client/gradle.properties deleted file mode 100644 index 1696bd82a9..0000000000 --- a/samples/standalone/webclient/http-client/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -bootVersion=3.2.7 diff --git a/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c49..0000000000 Binary files a/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ac72c34e8a..0000000000 --- a/samples/standalone/webclient/http-client/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/webclient/http-client/gradlew b/samples/standalone/webclient/http-client/gradlew deleted file mode 100755 index 0adc8e1a53..0000000000 --- a/samples/standalone/webclient/http-client/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/webclient/http-client/gradlew.bat b/samples/standalone/webclient/http-client/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/webclient/http-client/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/webclient/http-client/mvnw b/samples/standalone/webclient/http-client/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/webclient/http-client/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/webclient/http-client/mvnw.cmd b/samples/standalone/webclient/http-client/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/webclient/http-client/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/webclient/http-client/pom.xml b/samples/standalone/webclient/http-client/pom.xml deleted file mode 100644 index 06215e915b..0000000000 --- a/samples/standalone/webclient/http-client/pom.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - 4.0.0 - - com.example - http-client-webclient - 0.0.1 - - Spring Cloud Contract RestDocs Http WebClient Sample - Spring Cloud Contract RestDocs Http WebClient Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - org.springframework.cloud - spring-cloud-contract-wiremock - test - - - org.springframework.cloud - spring-cloud-contract-stub-runner - test - - - com.example - http-server-webclient - stubs - 0.0.1 - test - - - * - * - - - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*GradleTests.java - - true - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-deploy-plugin - - true - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - integration - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - ./gradlew - - clean - build - publishToMavenLocal - - -x - test - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - - diff --git a/samples/standalone/webclient/http-client/settings.gradle b/samples/standalone/webclient/http-client/settings.gradle deleted file mode 100644 index ff0d4920f8..0000000000 --- a/samples/standalone/webclient/http-client/settings.gradle +++ /dev/null @@ -1,14 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - gradlePluginPortal() - } - plugins { - id 'org.springframework.boot' version "${bootVersion}" - id "io.spring.dependency-management" version "1.1.3" - } -} - -rootProject.name = 'http-client-webclient-gradle' diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/Application.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/Application.java deleted file mode 100644 index 63645c66f5..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/Application.java +++ /dev/null @@ -1,31 +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 com.example.loan; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -@SpringBootApplication -@EnableConfigurationProperties(ServiceConfiguration.class) -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/LoanApplicationService.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/LoanApplicationService.java deleted file mode 100644 index 0db17a8ebe..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/LoanApplicationService.java +++ /dev/null @@ -1,106 +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 com.example.loan; - -import com.example.loan.model.FraudCheckStatus; -import com.example.loan.model.FraudServiceRequest; -import com.example.loan.model.FraudServiceResponse; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private final RestTemplate restTemplate; - - private final ServiceConfiguration serviceConfiguration; - - public LoanApplicationService(ServiceConfiguration serviceConfiguration) { - this.restTemplate = new RestTemplate(); - this.serviceConfiguration = serviceConfiguration; - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1); - - // tag::client_call_server[] - ResponseEntity response = this.restTemplate.exchange( - "http://localhost:" + getPort() + "/fraudcheck", HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - // end::client_call_server[] - - return response.getBody(); - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public int getPort() { - return this.serviceConfiguration.getPort(); - } - - public void setPort(int port) { - this.serviceConfiguration.setPort(port); - } - -} - -@ConfigurationProperties("service") -class ServiceConfiguration { - - private int port = 8080; - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } -} \ No newline at end of file diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/Client.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/Client.java deleted file mode 100644 index 2c2c8b8d8a..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/Client.java +++ /dev/null @@ -1,38 +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 com.example.loan.model; - -public class Client { - - private String pesel; - - public Client() { - } - - public Client(String pesel) { - this.pesel = pesel; - } - - public String getPesel() { - return this.pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java deleted file mode 100644 index 01f2969113..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java deleted file mode 100644 index e4e63590bc..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceRequest.java +++ /dev/null @@ -1,51 +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 com.example.loan.model; - -import java.math.BigDecimal; - -public class FraudServiceRequest { - - private String clientId; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientId = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientId() { - return this.clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java deleted file mode 100644 index 4ca6dfc623..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/FraudServiceResponse.java +++ /dev/null @@ -1,44 +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 com.example.loan.model; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplication.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplication.java deleted file mode 100644 index 54ae63b0fe..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplication.java +++ /dev/null @@ -1,61 +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 com.example.loan.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public LoanApplication() { - } - - public LoanApplication(Client client, double amount) { - this.client = client; - this.amount = BigDecimal.valueOf(amount); - } - - public Client getClient() { - return this.client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return this.amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return this.loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java deleted file mode 100644 index 0850c0af0b..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +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 com.example.loan.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return this.loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java b/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java deleted file mode 100644 index 5afde21afc..0000000000 --- a/samples/standalone/webclient/http-client/src/main/java/com/example/loan/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +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 com.example.loan.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/samples/standalone/webclient/http-client/src/main/resources/application.yml b/samples/standalone/webclient/http-client/src/main/resources/application.yml deleted file mode 100644 index 056c802c77..0000000000 --- a/samples/standalone/webclient/http-client/src/main/resources/application.yml +++ /dev/null @@ -1,5 +0,0 @@ -server.port: 8097 -logging: - level: - org.springframework.web.client: debug - com.github.tomakehurst.wiremock: trace \ No newline at end of file diff --git a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java b/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java deleted file mode 100644 index ebd91253ad..0000000000 --- a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceTests.java +++ /dev/null @@ -1,87 +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 com.example.loan; - -import java.nio.charset.Charset; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.stubbing.StubMapping; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.core.io.Resource; - -import org.springframework.util.StreamUtils; - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest(properties = "service.port=${wiremock.server.port}") -@AutoConfigureWireMock(port = 0) -public class LoanApplicationServiceTests { - - @Autowired - private LoanApplicationService service; - - @Value("classpath:META-INF/com.example/http-server-webclient/0.0.1/mappings/markClientAsFraud.json") - private Resource markClientAsFraud; - - @Value("classpath:META-INF/com.example/http-server-webclient/0.0.1/mappings/markClientAsNotFraud.json") - private Resource markClientAsNotFraud; - - @Autowired - private WireMockServer server; - - @Test - public void shouldSuccessfullyApplyForLoan() throws Exception { - this.server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( - this.markClientAsNotFraud.getInputStream(), Charset.forName("UTF-8")))); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { - this.server.addStubMapping(StubMapping.buildFrom(StreamUtils.copyToString( - this.markClientAsFraud.getInputStream(), Charset.forName("UTF-8")))); - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} diff --git a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerGradleTests.java b/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerGradleTests.java deleted file mode 100644 index e75bbbae92..0000000000 --- a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerGradleTests.java +++ /dev/null @@ -1,77 +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 com.example.loan; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; - - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest -@AutoConfigureStubRunner(ids = "com.example:http-server-webclient") -public class LoanApplicationServiceusingStubRunnerGradleTests { - - @Autowired - LoanApplicationService service; - - @Value("${stubrunner.runningstubs.http-server-webclient.port}") - int port; - - @BeforeEach - public void setup() { - this.service.setPort(this.port); - } - - @Test - public void shouldSuccessfullyApplyForLoan() throws Exception { - // given - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} diff --git a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java b/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java deleted file mode 100644 index e1c1c13ec7..0000000000 --- a/samples/standalone/webclient/http-client/src/test/java/com/example/loan/LoanApplicationServiceusingStubRunnerTests.java +++ /dev/null @@ -1,77 +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 com.example.loan; - -import com.example.loan.model.Client; -import com.example.loan.model.LoanApplication; -import com.example.loan.model.LoanApplicationResult; -import com.example.loan.model.LoanApplicationStatus; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner; - - -import static org.assertj.core.api.Assertions.assertThat; - - -@SpringBootTest -@AutoConfigureStubRunner(ids = "com.example:http-server-webclient") -public class LoanApplicationServiceusingStubRunnerTests { - - @Autowired - LoanApplicationService service; - - @Value("${stubrunner.runningstubs.http-server-webclient.port}") - int port; - - @BeforeEach - public void setup() { - this.service.setPort(this.port); - } - - @Test - public void shouldSuccessfullyApplyForLoan() throws Exception { - // given - LoanApplication application = new LoanApplication(new Client("1234567890"), - 123.123); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLIED); - assertThat(loanApplication.getRejectionReason()).isNull(); - } - - @Test - public void shouldBeRejectedDueToAbnormalLoanAmount() throws Exception { - // given: - LoanApplication application = new LoanApplication(new Client("1234567890"), - 99999); - // when: - LoanApplicationResult loanApplication = this.service.loanApplication(application); - // then: - assertThat(loanApplication.getLoanApplicationStatus()) - .isEqualTo(LoanApplicationStatus.LOAN_APPLICATION_REJECTED); - assertThat(loanApplication.getRejectionReason()).isEqualTo("Amount too high"); - } - -} diff --git a/samples/standalone/webclient/http-client/src/test/resources/application-gradle.yaml b/samples/standalone/webclient/http-client/src/test/resources/application-gradle.yaml deleted file mode 100644 index 085483afa6..0000000000 --- a/samples/standalone/webclient/http-client/src/test/resources/application-gradle.yaml +++ /dev/null @@ -1,2 +0,0 @@ -stubrunner: - stubs.ids: 'com.example:http-server-webclient' diff --git a/samples/standalone/webclient/http-server/.gitignore b/samples/standalone/webclient/http-server/.gitignore deleted file mode 100644 index b05ba7bd6d..0000000000 --- a/samples/standalone/webclient/http-server/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ - -target/ - -.gradle -build/ - diff --git a/samples/standalone/webclient/http-server/.mvn/jvm.config b/samples/standalone/webclient/http-server/.mvn/jvm.config deleted file mode 100644 index 0e7dabeff6..0000000000 --- a/samples/standalone/webclient/http-server/.mvn/jvm.config +++ /dev/null @@ -1 +0,0 @@ --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 deleted file mode 100644 index a682990566..0000000000 --- a/samples/standalone/webclient/http-server/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --P spring diff --git a/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java b/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/samples/standalone/webclient/http-server/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/webclient/http-server/.mvn/wrapper/maven-wrapper.jar b/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f176..0000000000 Binary files a/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.properties b/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 015dfe6821..0000000000 --- a/samples/standalone/webclient/http-server/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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/webclient/http-server/README.adoc b/samples/standalone/webclient/http-server/README.adoc deleted file mode 100644 index 2fd3fbc40d..0000000000 --- a/samples/standalone/webclient/http-server/README.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= Http Server - -Run - -[source=groovy] --------- -./gradlew clean build publishToMavenLocal --------- - -or - --------- -./mvnw clean install --------- - -To - -- build the app -- generate and run Spring Cloud Contract Verifier tests -- publish the fatJar and the stubs to Maven Local \ No newline at end of file diff --git a/samples/standalone/webclient/http-server/build.gradle b/samples/standalone/webclient/http-server/build.gradle deleted file mode 100644 index 7a76265890..0000000000 --- a/samples/standalone/webclient/http-server/build.gradle +++ /dev/null @@ -1,128 +0,0 @@ -plugins { - id "groovy" - id "org.springframework.boot" - id "io.spring.dependency-management" - id "maven-publish" - /** - * While the SCC Gradle plugin is not strictly necessary for this project. - * It is included to ensure that if the contractDslDir does not exist, then - * the plugin reports "NO-SOURCE" for associated tasks, rather than resulting - * in an error for the end user. - */ - id "org.springframework.cloud.contract" -} - -group = 'com.example' -version = '0.0.1' - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}" - } -} - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-webflux") - implementation("org.springframework.boot:spring-boot-starter-actuator") - - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation 'org.springframework.restdocs:spring-restdocs-webtestclient' - testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' -} - -contracts { - failOnNoContracts = false -} - -generateClientStubs.enabled = false - -test { - useJUnitPlatform() - systemProperty 'spring.profiles.active', 'gradle' - testLogging { - exceptionFormat = 'full' - } - afterSuite { desc, result -> - if (!desc.parent) { - println "Results: (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" - if (result.testCount == 0) { - throw new IllegalStateException("No tests were found. Failing the build") - } - } - } -} - -task stubsJar(type: Jar, dependsOn: ['copySnippets', 'copySources', 'copyClasses']) { - archiveBaseName = project.name - archiveClassifier = 'stubs' - from project.file("${project.buildDir}/stubs") -} - -task copySnippets(type: Copy, dependsOn: test) { - from "target/snippets/stubs" - into "${project.buildDir}/stubs/META-INF/${project.group}/${project.name}/${project.version}/mappings" -} - -task copySources(type: Copy) { - from "src/main/java" - include '**/model/Fraud*.*' - into "${project.buildDir}/stubs/" -} - -task copyClasses(type: Copy) { - from "${project.buildDir}/classes/main/" - include '**/model/Fraud*.*' - into "${project.buildDir}/stubs/" -} - -project.tasks.named("verifierStubsJar").get().dependsOn('copySnippets', 'copySources', 'stubsJar') // TODO: We need to fix this -project.tasks.named("copyContracts").get().dependsOn('stubsJar') // TODO: We need to fix this -afterEvaluate { - project.tasks.matching { it.name.contains("publish") }.each { it.dependsOn('verifierStubsJar') } // TODO: We need to fix this -} - -publishing { - publications { - maven(MavenPublication) { - artifact bootJar - artifact stubsJar - - // https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273 - versionMapping { - usage("java-api") { - fromResolutionOf("runtimeClasspath") - } - usage("java-runtime") { - fromResolutionResult() - } - } - } - } -} - -clean.doFirst { - delete 'target/snippets/stubs' - delete "~/.m2/repository/com/example/http-server-webclient-gradle" -} - -task resolveDependencies { - doLast { - project.rootProject.allprojects.each { subProject -> - subProject.buildscript.configurations.each { configuration -> - configuration.resolve() - } - subProject.configurations.each { configuration -> - configuration.resolve() - } - } - } -} diff --git a/samples/standalone/webclient/http-server/gradle.properties b/samples/standalone/webclient/http-server/gradle.properties deleted file mode 100644 index 1baaf2d82c..0000000000 --- a/samples/standalone/webclient/http-server/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.daemon=false -verifierVersion=4.1.5-SNAPSHOT -bootVersion=3.2.7 \ No newline at end of file diff --git a/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.jar b/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135c49..0000000000 Binary files a/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.properties b/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ac72c34e8a..0000000000 --- a/samples/standalone/webclient/http-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/samples/standalone/webclient/http-server/gradlew b/samples/standalone/webclient/http-server/gradlew deleted file mode 100755 index 0adc8e1a53..0000000000 --- a/samples/standalone/webclient/http-server/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# 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. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/samples/standalone/webclient/http-server/gradlew.bat b/samples/standalone/webclient/http-server/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/samples/standalone/webclient/http-server/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem 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, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/samples/standalone/webclient/http-server/mvnw b/samples/standalone/webclient/http-server/mvnw deleted file mode 100755 index 5643201c7d..0000000000 --- a/samples/standalone/webclient/http-server/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -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 - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # 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 - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# 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)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - 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 - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -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 $@" -export MAVEN_CMD_LINE_ARGS - -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_CONFIG "$@" diff --git a/samples/standalone/webclient/http-server/mvnw.cmd b/samples/standalone/webclient/http-server/mvnw.cmd deleted file mode 100644 index 23b7079a3d..0000000000 --- a/samples/standalone/webclient/http-server/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@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/webclient/http-server/pom.xml b/samples/standalone/webclient/http-server/pom.xml deleted file mode 100644 index 3388c1bee1..0000000000 --- a/samples/standalone/webclient/http-server/pom.xml +++ /dev/null @@ -1,241 +0,0 @@ - - - 4.0.0 - - com.example - http-server-webclient - 0.0.1 - - Spring Cloud Contract RestDocs Http Server Sample - Spring Cloud RestDocs Verifier Http Server Sample - - - org.springframework.boot - spring-boot-starter-parent - 3.2.7 - - - - - UTF-8 - 17 - 4.1.5-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-webflux - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - org.springframework.restdocs - spring-restdocs-webtestclient - test - - - org.springframework.cloud - spring-cloud-contract-wiremock - test - - - - - - - org.springframework.cloud - spring-cloud-contract-dependencies - ${spring-cloud-contract.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-clean-plugin - - - - build - - - target - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - stub - prepare-package - - single - - false - - true - - ${basedir}/src/assembly/stub.xml - - - - - - - maven-surefire-plugin - - true - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - - windows - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - gradle - test - - gradlew.bat - - clean - build - - install - - -x - test - - -x - contractTest - - -PverifierVersion=${spring-cloud-contract.version} - - - - - exec - - - - - - - - - diff --git a/samples/standalone/webclient/http-server/settings.gradle b/samples/standalone/webclient/http-server/settings.gradle deleted file mode 100644 index e3747344a1..0000000000 --- a/samples/standalone/webclient/http-server/settings.gradle +++ /dev/null @@ -1,22 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - gradlePluginPortal() - } - plugins { - id 'org.springframework.boot' version "${bootVersion}" - id "io.spring.dependency-management" version "1.1.3" - } - resolutionStrategy { - eachPlugin { - // protects us in case the gradle-portal-plugin hasn't yet been published by Maven - if (requested.id.id == 'org.springframework.cloud.contract') { - useModule("org.springframework.cloud:spring-cloud-contract-gradle-plugin:${verifierVersion}") - } - } - } -} - -rootProject.name = 'http-server-webclient-gradle' diff --git a/samples/standalone/webclient/http-server/src/assembly/stub.xml b/samples/standalone/webclient/http-server/src/assembly/stub.xml deleted file mode 100644 index 13bdf69cef..0000000000 --- a/samples/standalone/webclient/http-server/src/assembly/stub.xml +++ /dev/null @@ -1,35 +0,0 @@ - - stubs - - jar - - false - - - src/main/java - / - - **/model/Fraud*.* - - - - ${project.build.directory}/classes - / - - **/model/Fraud*.* - - - - ${project.build.directory}/snippets/stubs - - META-INF/${project.groupId}/${project.artifactId}/${project.version}/mappings - - - **/* - - - - diff --git a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/Application.java b/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/Application.java deleted file mode 100644 index c998b507b2..0000000000 --- a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/Application.java +++ /dev/null @@ -1,33 +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 com.example.fraud; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/FraudDetectionController.java b/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/FraudDetectionController.java deleted file mode 100644 index 1d5469e93f..0000000000 --- a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/FraudDetectionController.java +++ /dev/null @@ -1,60 +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 com.example.fraud; - -import java.math.BigDecimal; - -import com.example.fraud.model.FraudCheck; -import com.example.fraud.model.FraudCheckResult; -import com.example.fraud.model.FraudCheckStatus; - -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -@RestController -public class FraudDetectionController { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - // tag::server_api[] - @RequestMapping(value = "/fraudcheck", method = PUT, consumes = FRAUD_SERVICE_JSON_VERSION_1, produces = FRAUD_SERVICE_JSON_VERSION_1) - public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) { - // end::server_api[] - // tag::new_impl[] - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FraudCheckStatus.FRAUD, AMOUNT_TOO_HIGH); - } - // end::new_impl[] - // tag::initial_impl[] - return new FraudCheckResult(FraudCheckStatus.OK, NO_REASON); - // end::initial_impl[] - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheck.java b/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheck.java deleted file mode 100644 index 4cf6ae3ea2..0000000000 --- a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheck.java +++ /dev/null @@ -1,46 +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 com.example.fraud.model; - -import java.math.BigDecimal; - -public class FraudCheck { - - private String clientId; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public BigDecimal getLoanAmount() { - return loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java b/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java deleted file mode 100644 index 95440c6790..0000000000 --- a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckResult.java +++ /dev/null @@ -1,49 +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 com.example.fraud.model; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java b/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java deleted file mode 100644 index a43b649f5c..0000000000 --- a/samples/standalone/webclient/http-server/src/main/java/com/example/fraud/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +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 com.example.fraud.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/samples/standalone/webclient/http-server/src/main/resources/application.yml b/samples/standalone/webclient/http-server/src/main/resources/application.yml deleted file mode 100644 index 1c421cf2b7..0000000000 --- a/samples/standalone/webclient/http-server/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 \ No newline at end of file diff --git a/samples/standalone/webclient/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java b/samples/standalone/webclient/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java deleted file mode 100644 index 42e8074aa0..0000000000 --- a/samples/standalone/webclient/http-server/src/test/java/com/example/fraud/StubGeneratorTests.java +++ /dev/null @@ -1,92 +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 com.example.fraud; - -import java.math.BigDecimal; - -import com.example.fraud.model.FraudCheck; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.json.JacksonTester; -import org.springframework.http.MediaType; -import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation; -import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.reactive.function.BodyInserters; - -import static org.springframework.cloud.contract.wiremock.restdocs.WireMockWebTestClient.verify; - - -@SpringBootTest(classes = Application.class) -@AutoConfigureRestDocs(outputDir = "target/snippets") -@AutoConfigureWebTestClient -@AutoConfigureJsonTesters -public class StubGeneratorTests { - - @Autowired - private WebTestClient client; - - private JacksonTester json; - - @BeforeEach - public void setup() { - ObjectMapper objectMappper = new ObjectMapper(); - // Possibly configure the mapper - JacksonTester.initFields(this, objectMappper); - } - - @Test - public void shouldMarkClientAsFraud() throws Exception { - FraudCheck fraudCheck = new FraudCheck(); - fraudCheck.setClientId("1234567890"); - fraudCheck.setLoanAmount(BigDecimal.valueOf(99999.0)); - client.put().uri("/fraudcheck") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json")) - .body(BodyInserters.fromObject(json.write(fraudCheck).getJson())) - .exchange().expectBody().jsonPath("$.fraudCheckStatus").isEqualTo("FRAUD") - .jsonPath("$.rejectionReason").isEqualTo("Amount too high") - .consumeWith(verify().jsonPath("$.clientId") - .jsonPath("$[?(@.loanAmount > 1000)]") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))) - .consumeWith( - WebTestClientRestDocumentation.document("markClientAsFraud")); - } - - @Test - public void shouldMarkClientAsNotFraud() throws Exception { - FraudCheck fraudCheck = new FraudCheck(); - fraudCheck.setClientId("1234567890"); - fraudCheck.setLoanAmount(BigDecimal.valueOf(123.123)); - client.put().uri("/fraudcheck") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json")) - .body(BodyInserters.fromObject(json.write(fraudCheck).getJson())) - .exchange().expectBody().jsonPath("$.fraudCheckStatus").isEqualTo("OK") - .jsonPath("$.rejectionReason").doesNotExist() - .consumeWith(verify().jsonPath("$.clientId") - .jsonPath("$[?(@.loanAmount <= 1000)]") - .contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))) - .consumeWith( - WebTestClientRestDocumentation.document("markClientAsNotFraud")); - } - -} diff --git a/samples/standalone/webclient/pom.xml b/samples/standalone/webclient/pom.xml deleted file mode 100644 index f6aef1095c..0000000000 --- a/samples/standalone/webclient/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.springframework.cloud - spring-cloud-contract-samples-standalone - 4.1.5-SNAPSHOT - .. - - - spring-cloud-contract-samples-webclient - pom - - Spring Cloud Contract Standalone Restdocs Test Samples - Spring Cloud Contract Standalone Test Samples used for end to end tests - - - - 4.1.5-SNAPSHOT - - - - http-server - http-client - - - - - - maven-deploy-plugin - 2.8.2 - - true - - - - - -