diff --git a/spring-cloud-contract-stub-runner/pom.xml b/spring-cloud-contract-stub-runner/pom.xml index b30d092eae..99db2e11d4 100644 --- a/spring-cloud-contract-stub-runner/pom.xml +++ b/spring-cloud-contract-stub-runner/pom.xml @@ -20,10 +20,8 @@ spring-cloud-contract-stub-runner spring-cloud-contract-stub-runner-jetty - spring-cloud-contract-stub-runner-spring spring-cloud-contract-stub-runner-boot spring-cloud-contract-stub-runner-messaging - spring-cloud-contract-stub-runner-spring-cloud diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/README.adoc b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/README.adoc deleted file mode 100644 index edd082eb09..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/README.adoc +++ /dev/null @@ -1,27 +0,0 @@ -=== Stub Runner Spring Cloud - -Registers the stubs in the provided Service Discovery. It's enough to add the jar - -[source,groovy,indent=0] ----- -org.springframework.cloud:stub-runner-spring-cloud ----- - -and the Stub Runner autoconfiguration should be picked up. - -==== Stubbing Service Discovery - -The most important feature of `Stub Runner Spring Cloud` is the fact that it's stubbing - -- `DiscoveryClient` -- `Ribbon` `ServerList` - -that means that regardles of the fact whether you're using Zookeeper, Consul, Eureka or anything else, you don't need that in your tests. -We're starting WireMock instances of your dependencies and we're telling your application whenever you're using `Feign`, load balanced `RestTemplate` -or `DiscoveryClient` directly, to call those stubbed servers instead of calling the real Service Discovery tool. - -==== Additional Configuration - -You can match the artifactId of the stub with the name of your app by using the `stubrunner.stubs.idsToServiceIds:` map. -You can disable Stub Runner Ribbon support by providing: `stubrunner.cloud.ribbon.enabled` equal to `false` -You can disable Stub Runner support by providing: `stubrunner.cloud.enabled` equal to `false` \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/pom.xml deleted file mode 100644 index 48a23efd48..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-contract-stub-runner-build - 1.0.0.BUILD-SNAPSHOT - .. - - spring-cloud-contract-stub-runner-spring-cloud - jar - Spring Cloud Contract Stub Runner Spring Cloud - Spring Cloud Contract Stub Runner Spring Cloud - - - org.springframework.cloud - spring-cloud-contract-stub-runner-boot - - - org.springframework.cloud - spring-cloud-contract-wiremock - - - org.springframework.cloud - spring-cloud-starter-ribbon - true - - - org.springframework.cloud - spring-cloud-starter-zookeeper-discovery - true - - - org.codehaus.groovy - groovy - - - org.spockframework - spock-spring - test - - - org.apache.curator - curator-test - test - - - org.springframework.boot - spring-boot-starter-web - test - - - org.springframework.boot - spring-boot-starter-test - test - - - info.solidsoft.spock - spock-global-unroll - test - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - - - - testCompile - - - - - - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/resources/META-INF/spring.factories b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 81590f52d9..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,4 +0,0 @@ -# Auto Configuration -org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner=\ -org.springframework.cloud.contract.stubrunner.spring.cloud.StubRunnerSpringCloudAutoConfiguration,\ -org.springframework.cloud.contract.stubrunner.spring.cloud.ribbon.StubRunnerRibbonAutoConfiguration diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/application.yml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/application.yml deleted file mode 100644 index 629b688f80..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/application.yml +++ /dev/null @@ -1,6 +0,0 @@ -stubrunner.stubs.repository.root: classpath:m2repo/repository/ -stubrunner.stubs.ids: org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer - -stubrunner.stubs.idsToServiceIds: - ivyNotation: someValueInsideYourCode - fraudDetectionServer: someNameThatShouldMapFraudDetectionServer \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/logback.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/logback.xml deleted file mode 100644 index 7eecabf2f2..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/logback.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar deleted file mode 100644 index fdb70e383f..0000000000 Binary files a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar and /dev/null differ diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom deleted file mode 100644 index 40610c8cdb..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - - 4.0.0 - org.springframework.cloud.contract.verifier.stubs - fraudDetectionServer - 0.0.1-SNAPSHOT - pom - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml deleted file mode 100644 index 281b9b3b80..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - org.springframework.cloud.contract.verifier.stubs - fraudDetectionServer - 0.0.1-SNAPSHOT - - - 0.0.1-SNAPSHOT - - 20160409062112 - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar deleted file mode 100644 index e322590636..0000000000 Binary files a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar and /dev/null differ diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom deleted file mode 100644 index 59db343686..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - - 4.0.0 - org.springframework.cloud.contract.verifier.stubs - loanIssuance - 0.0.1-SNAPSHOT - pom - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml deleted file mode 100644 index 615428dae6..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - org.springframework.cloud.contract.verifier.stubs - loanIssuance - 0.0.1-SNAPSHOT - - - 0.0.1-SNAPSHOT - - 20160409062111 - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/README.adoc b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/README.adoc deleted file mode 100644 index 38169894bf..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/README.adoc +++ /dev/null @@ -1,21 +0,0 @@ -=== Stub Runner Spring - -Sets up Spring configuration of the Stub Runner project. - -By providing a list of stubs inside your configuration file the Stub Runner automatically downloads -and registers in WireMock the selected stubs. - -If you want to find the URL of your stubbed dependency you can autowire the `StubFinder` interface and use -its methods as presented below: - -[source,groovy,indent=0] ----- -include::src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy[tags=test] ----- - -for the following configuration file: - -[source,yml,indent=0] ----- -include::src/test/resources/application.yml[] ----- \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/pom.xml deleted file mode 100644 index c69e29601c..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-contract-stub-runner-build - 1.0.0.BUILD-SNAPSHOT - .. - - spring-cloud-contract-stub-runner-spring - jar - Spring Cloud Contract Stub Runner Spring - Spring Cloud Contract Stub Runner Spring - - - org.springframework.cloud - spring-cloud-contract-stub-runner - - - org.springframework.cloud - spring-cloud-contract-wiremock - - - org.codehaus.groovy - groovy - - - org.spockframework - spock-spring - test - - - org.springframework.boot - spring-boot-starter-web - test - - - org.springframework.boot - spring-boot-starter-test - test - - - info.solidsoft.spock - spock-global-unroll - test - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - - - - testCompile - - - - - - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/AutoConfigureStubRunner.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/AutoConfigureStubRunner.java deleted file mode 100644 index c5eb9af52a..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/AutoConfigureStubRunner.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-2015 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. - */ - -package org.springframework.cloud.contract.stubrunner.spring; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; - -/** - * @author Dave Syer - * - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@ImportAutoConfiguration -public @interface AutoConfigureStubRunner { - -} diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.java deleted file mode 100644 index 3a9e2d040c..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013-2016 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. - */ - -package org.springframework.cloud.contract.stubrunner.spring; - -import java.io.IOException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.cloud.contract.stubrunner.AetherStubDownloader; -import org.springframework.cloud.contract.stubrunner.BatchStubRunner; -import org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory; -import org.springframework.cloud.contract.stubrunner.StubDownloader; -import org.springframework.cloud.contract.stubrunner.StubRunner; -import org.springframework.cloud.contract.stubrunner.StubRunnerOptions; -import org.springframework.cloud.contract.stubrunner.StubRunnerOptionsBuilder; -import org.springframework.cloud.contract.verifier.messaging.ContractVerifierMessaging; -import org.springframework.cloud.contract.verifier.messaging.noop.NoOpContractVerifierMessaging; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.Resource; - -/** - * Configuration that initializes a {@link BatchStubRunner} that runs {@link StubRunner} instance for each stub - */ -@Configuration -@ConditionalOnMissingBean(type="org.springframework.cloud.contract.wiremock.WiremockServerConfiguration") -public class StubRunnerConfiguration { - - @Autowired(required = false) ContractVerifierMessaging contractVerifierMessaging; - @Autowired(required = false) StubDownloader stubDownloader; - - /** - * Bean that initializes stub runners, runs them and on shutdown closes them. Upon its instantiation - * JAR with stubs is downloaded and unpacked to a temporary folder and WireMock server are started - * for each of those stubs - * - * @param minPortValue min port value of the WireMock instance for stubs - * @param maxPortValue max port value of the WireMock instance for stubs - * @param stubRepositoryRoot root URL from where the JAR with stub mappings will be downloaded - * @param stubsSuffix classifier for the jar containing stubs - * @param workOffline forces offline work - * @param stubs comma separated list of stubs presented in Ivy notation - */ - @Bean - public BatchStubRunner batchStubRunner( - @Value("${stubrunner.port.range.min:10000}") Integer minPortValue, - @Value("${stubrunner.port.range.max:15000}") Integer maxPortValue, - @Value("${stubrunner.stubs.repository.root:}") Resource stubRepositoryRoot, - @Value("${stubrunner.stubs.classifier:stubs}") String stubsSuffix, - @Value("${stubrunner.work-offline:false}") boolean workOffline, - @Value("${stubrunner.stubs.ids:}") String stubs) throws IOException { - StubRunnerOptions stubRunnerOptions = new StubRunnerOptionsBuilder() - .withMinMaxPort(minPortValue, maxPortValue) - .withStubRepositoryRoot(uriStringOrEmpty(stubRepositoryRoot)) - .withWorkOffline(stubRepositoryRoot == null || workOffline) - .withStubsClassifier(stubsSuffix) - .withStubs(stubs) - .build(); - BatchStubRunner batchStubRunner = new BatchStubRunnerFactory(stubRunnerOptions, - stubDownloader != null ? stubDownloader : new AetherStubDownloader(stubRunnerOptions), - contractVerifierMessaging != null ? contractVerifierMessaging : new NoOpContractVerifierMessaging()).buildBatchStubRunner(); - // TODO: Consider running it in a separate thread - batchStubRunner.runStubs(); - return batchStubRunner; - } - - private String uriStringOrEmpty(Resource stubRepositoryRoot) throws IOException { - return stubRepositoryRoot != null ? stubRepositoryRoot.getURI().toString() : ""; - } - -} diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/resources/META-INF/spring.factories b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/resources/META-INF/spring.factories deleted file mode 100644 index a0e462c04c..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configuration -org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner=\ -org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy deleted file mode 100644 index 876816baf3..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2013-2016 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. - */ - -package org.springframework.cloud.contract.stubrunner.spring - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.autoconfigure.EnableAutoConfiguration -import org.springframework.boot.test.context.SpringBootContextLoader -import org.springframework.cloud.contract.stubrunner.StubFinder -import org.springframework.context.annotation.Configuration -import org.springframework.test.context.ContextConfiguration - -import spock.lang.Specification - -/** - * @author Marcin Grzejszczak - */ -// tag::test[] -@ContextConfiguration(classes = Config, loader = SpringBootContextLoader) -@AutoConfigureStubRunner -class StubRunnerConfigurationSpec extends Specification { - - @Autowired StubFinder stubFinder - - def 'should start WireMock servers'() { - expect: 'WireMocks are running' - stubFinder.findStubUrl('org.springframework.cloud.contract.verifier.stubs', 'loanIssuance') != null - stubFinder.findStubUrl('loanIssuance') != null - stubFinder.findStubUrl('loanIssuance') == stubFinder.findStubUrl('org.springframework.cloud.contract.verifier.stubs', 'loanIssuance') - stubFinder.findStubUrl('org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer') != null - and: - stubFinder.findAllRunningStubs().isPresent('loanIssuance') - stubFinder.findAllRunningStubs().isPresent('org.springframework.cloud.contract.verifier.stubs', 'fraudDetectionServer') - stubFinder.findAllRunningStubs().isPresent('org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer') - and: 'Stubs were registered' - "${stubFinder.findStubUrl('loanIssuance').toString()}/name".toURL().text == 'loanIssuance' - "${stubFinder.findStubUrl('fraudDetectionServer').toString()}/name".toURL().text == 'fraudDetectionServer' - } - - @Configuration - @EnableAutoConfiguration - static class Config {} -} -// end::test[] \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/application.yml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/application.yml deleted file mode 100644 index 4f618057e1..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -stubrunner.stubs.repository.root: classpath:m2repo/repository/ -stubrunner.stubs.ids: org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/logback.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/logback.xml deleted file mode 100644 index 7eecabf2f2..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/logback.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar deleted file mode 100644 index fdb70e383f..0000000000 Binary files a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT-stubs.jar and /dev/null differ diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom deleted file mode 100644 index 40610c8cdb..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/0.0.1-SNAPSHOT/fraudDetectionServer-0.0.1-SNAPSHOT.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - - 4.0.0 - org.springframework.cloud.contract.verifier.stubs - fraudDetectionServer - 0.0.1-SNAPSHOT - pom - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml deleted file mode 100644 index 281b9b3b80..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/fraudDetectionServer/maven-metadata.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - org.springframework.cloud.contract.verifier.stubs - fraudDetectionServer - 0.0.1-SNAPSHOT - - - 0.0.1-SNAPSHOT - - 20160409062112 - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar deleted file mode 100644 index e322590636..0000000000 Binary files a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT-stubs.jar and /dev/null differ diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom deleted file mode 100644 index 59db343686..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/0.0.1-SNAPSHOT/loanIssuance-0.0.1-SNAPSHOT.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - - 4.0.0 - org.springframework.cloud.contract.verifier.stubs - loanIssuance - 0.0.1-SNAPSHOT - pom - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml deleted file mode 100644 index 615428dae6..0000000000 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring/src/test/resources/m2repo/repository/org/springframework/cloud/contract/verifier/stubs/loanIssuance/maven-metadata.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - org.springframework.cloud.contract.verifier.stubs - loanIssuance - 0.0.1-SNAPSHOT - - - 0.0.1-SNAPSHOT - - 20160409062111 - - diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/README.adoc b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/README.adoc index 612f4cd746..0b10e95d47 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/README.adoc +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/README.adoc @@ -129,3 +129,52 @@ You can see that for this example the following test is valid: include::src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleCustomPortJUnitTest.java[tags=test_with_port] ---- +-=== Stub Runner Spring + +Sets up Spring configuration of the Stub Runner project. + +By providing a list of stubs inside your configuration file the Stub Runner automatically downloads +and registers in WireMock the selected stubs. + +If you want to find the URL of your stubbed dependency you can autowire the `StubFinder` interface and use +its methods as presented below: + +[source,groovy,indent=0] +---- +include::src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy[tags=test] +---- + +for the following configuration file: + +[source,yml,indent=0] +---- +include::src/test/resources/application.yml[] +---- + +=== Stub Runner Spring Cloud + +Registers the stubs in the provided Service Discovery. It's enough to add the jar + +[source,groovy,indent=0] +---- +org.springframework.cloud:stub-runner-spring-cloud +---- + +and the Stub Runner autoconfiguration should be picked up. + +==== Stubbing Service Discovery + +The most important feature of `Stub Runner Spring Cloud` is the fact that it's stubbing + +- `DiscoveryClient` +- `Ribbon` `ServerList` + +that means that regardles of the fact whether you're using Zookeeper, Consul, Eureka or anything else, you don't need that in your tests. +We're starting WireMock instances of your dependencies and we're telling your application whenever you're using `Feign`, load balanced `RestTemplate` +or `DiscoveryClient` directly, to call those stubbed servers instead of calling the real Service Discovery tool. + +==== Additional Configuration + +You can match the artifactId of the stub with the name of your app by using the `stubrunner.stubs.idsToServiceIds:` map. +You can disable Stub Runner Ribbon support by providing: `stubrunner.cloud.ribbon.enabled` equal to `false` +You can disable Stub Runner support by providing: `stubrunner.cloud.enabled` equal to `false` \ No newline at end of file diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/pom.xml index bd2858f538..c4976bf1a1 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/pom.xml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/pom.xml @@ -22,6 +22,16 @@ spring-cloud-contract-wiremock true + + org.springframework.cloud + spring-cloud-starter + true + + + org.springframework.cloud + spring-cloud-starter-ribbon + true + org.springframework.cloud spring-cloud-contract-verifier-messaging-core @@ -91,6 +101,16 @@ spock-global-unroll test + + org.springframework.cloud + spring-cloud-starter-zookeeper-discovery + test + + + org.apache.curator + curator-test + test + diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubMapperProperties.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubMapperProperties.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubMapperProperties.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubMapperProperties.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerDiscoveryClient.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerDiscoveryClient.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerDiscoveryClient.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerDiscoveryClient.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerServiceInstance.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerServiceInstance.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerServiceInstance.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerServiceInstance.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfiguration.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfiguration.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfiguration.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfiguration.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonAutoConfiguration.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonAutoConfiguration.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonAutoConfiguration.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonAutoConfiguration.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonBeanPostProcessor.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonBeanPostProcessor.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonBeanPostProcessor.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonBeanPostProcessor.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonConfiguration.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonConfiguration.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonConfiguration.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonConfiguration.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonServerList.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonServerList.java similarity index 100% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonServerList.java rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/cloud/ribbon/StubRunnerRibbonServerList.java diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories index a0e462c04c..acec82308a 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/main/resources/META-INF/spring.factories @@ -1,3 +1,5 @@ # Auto Configuration org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner=\ -org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration \ No newline at end of file +org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfiguration,\ +org.springframework.cloud.contract.stubrunner.spring.cloud.StubRunnerSpringCloudAutoConfiguration,\ +org.springframework.cloud.contract.stubrunner.spring.cloud.ribbon.StubRunnerRibbonAutoConfiguration diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy similarity index 98% rename from spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy rename to spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy index 8fd70b9a31..fea4d2662d 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-spring-cloud/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/cloud/StubRunnerSpringCloudAutoConfigurationSpec.groovy @@ -44,13 +44,13 @@ import spock.lang.Specification */ @ContextConfiguration(classes = Config, loader = SpringBootContextLoader) @WebIntegrationTest(randomPort = true) -@IntegrationTest @Slf4j @AutoConfigureStubRunner class StubRunnerSpringCloudAutoConfigurationSpec extends Specification { @Autowired StubFinder stubFinder @Autowired @LoadBalanced RestTemplate restTemplate + // TODO: this shouldn't be needed? @Autowired ZookeeperServiceDiscovery zookeeperServiceDiscovery @Autowired ConfigurableApplicationContext applicationContext diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/resources/application.yml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/resources/application.yml index 4f618057e1..629b688f80 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/resources/application.yml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/resources/application.yml @@ -1,2 +1,6 @@ stubrunner.stubs.repository.root: classpath:m2repo/repository/ -stubrunner.stubs.ids: org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer \ No newline at end of file +stubrunner.stubs.ids: org.springframework.cloud.contract.verifier.stubs:loanIssuance,org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer + +stubrunner.stubs.idsToServiceIds: + ivyNotation: someValueInsideYourCode + fraudDetectionServer: someNameThatShouldMapFraudDetectionServer \ No newline at end of file