From 5681cd1d553c030192c8349b322bf3b3a52cfcef Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Sat, 16 Jul 2016 10:40:52 +0100 Subject: [PATCH] Remove references to old stub runner modules --- .../build.gradle | 3 +- .../pom.xml | 5 +++ .../http-client/build.gradle | 2 +- .../samples-standalone/http-client/pom.xml | 2 +- spring-cloud-contract-dependencies/pom.xml | 5 --- .../pom.xml | 6 ++- .../pom.xml | 5 ++- .../pom.xml | 9 ++--- .../pom.xml | 16 +++----- .../contract/stubrunner/AdhocTestSuite.groovy | 39 +++++++++++++++++++ .../StubRunnerRuleCustomPortJUnitTest.java | 4 +- .../junit/StubRunnerRuleJUnitTest.java | 4 +- .../junit/StubRunnerRuleSpec.groovy | 4 +- .../spring/StubRunnerConfigurationSpec.groovy | 13 +++++++ ...nerSpringCloudAutoConfigurationSpec.groovy | 12 ++++++ 15 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/AdhocTestSuite.groovy diff --git a/samples/samples-standalone/contract-verifier-sample-stream-sink/build.gradle b/samples/samples-standalone/contract-verifier-sample-stream-sink/build.gradle index f93372ebdc..1b3d749874 100644 --- a/samples/samples-standalone/contract-verifier-sample-stream-sink/build.gradle +++ b/samples/samples-standalone/contract-verifier-sample-stream-sink/build.gradle @@ -46,7 +46,8 @@ dependencies { testCompile "org.spockframework:spock-core" testCompile "org.springframework.boot:spring-boot-starter-test" testCompile "junit:junit" - testCompile "org.springframework.cloud:spring-cloud-contract-stub-runner-stream:${project.findProperty('verifierVersion') ?: verifierVersion}" + testCompile "org.springframework.cloud:spring-cloud-contract-stub-runner-stream" + testCompile "org.springframework.cloud:spring-cloud-contract-wiremock" } test { diff --git a/samples/samples-standalone/contract-verifier-sample-stream-sink/pom.xml b/samples/samples-standalone/contract-verifier-sample-stream-sink/pom.xml index 60c1ec6fbd..8d03967068 100644 --- a/samples/samples-standalone/contract-verifier-sample-stream-sink/pom.xml +++ b/samples/samples-standalone/contract-verifier-sample-stream-sink/pom.xml @@ -40,6 +40,11 @@ spring-cloud-contract-stub-runner-stream test + + org.springframework.cloud + spring-cloud-contract-wiremock + test + diff --git a/samples/samples-standalone/http-client/build.gradle b/samples/samples-standalone/http-client/build.gradle index e2719513fe..d8dfd41fe5 100644 --- a/samples/samples-standalone/http-client/build.gradle +++ b/samples/samples-standalone/http-client/build.gradle @@ -46,7 +46,7 @@ dependencies { testCompile "org.spockframework:spock-core" testCompile "junit:junit" testCompile 'org.springframework.cloud:spring-cloud-contract-wiremock' - testCompile "org.springframework.cloud:spring-cloud-contract-stub-runner-spring:${findProperty('verifierVersion') ?: verifierVersion}" + testCompile "org.springframework.cloud:spring-cloud-contract-stub-runner" } test { diff --git a/samples/samples-standalone/http-client/pom.xml b/samples/samples-standalone/http-client/pom.xml index 50241bafd4..44dabfa182 100644 --- a/samples/samples-standalone/http-client/pom.xml +++ b/samples/samples-standalone/http-client/pom.xml @@ -46,7 +46,7 @@ org.springframework.cloud - spring-cloud-contract-stub-runner-spring + spring-cloud-contract-stub-runner test diff --git a/spring-cloud-contract-dependencies/pom.xml b/spring-cloud-contract-dependencies/pom.xml index 9f7c9057f1..d03319e7dc 100644 --- a/spring-cloud-contract-dependencies/pom.xml +++ b/spring-cloud-contract-dependencies/pom.xml @@ -56,11 +56,6 @@ spring-cloud-contract-stub-runner-jetty ${project.version} - - org.springframework.cloud - spring-cloud-contract-stub-runner-spring - ${project.version} - org.springframework.cloud spring-cloud-contract-stub-runner-boot diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-boot/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-boot/pom.xml index 997c42fd92..2c9fe3dec6 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-boot/pom.xml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-boot/pom.xml @@ -24,7 +24,11 @@ org.springframework.cloud - spring-cloud-contract-stub-runner-spring + spring-cloud-contract-stub-runner + + + org.springframework.cloud + spring-cloud-contract-wiremock org.spockframework diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-camel/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-camel/pom.xml index f1b4506bb4..fa99ea3620 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-camel/pom.xml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-camel/pom.xml @@ -15,11 +15,12 @@ org.springframework.cloud - spring-cloud-contract-stub-runner-jetty + spring-cloud-contract-stub-runner org.springframework.cloud - spring-cloud-contract-stub-runner-spring + spring-cloud-contract-stub-runner-jetty + test org.springframework.cloud diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-integration/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-integration/pom.xml index 37cbff66af..9e2d71f59e 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-integration/pom.xml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-integration/pom.xml @@ -18,11 +18,12 @@ org.springframework.cloud - spring-cloud-contract-stub-runner-jetty + spring-cloud-contract-stub-runner org.springframework.cloud - spring-cloud-contract-stub-runner-spring + spring-cloud-contract-stub-runner-jetty + test org.springframework.cloud @@ -37,10 +38,6 @@ junit test - - org.codehaus.groovy - groovy - org.spockframework spock-core diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/pom.xml b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/pom.xml index 831125ca0a..5f8cef91c3 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/pom.xml +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner-messaging/spring-cloud-contract-stub-runner-stream/pom.xml @@ -18,7 +18,12 @@ org.springframework.cloud - spring-cloud-contract-stub-runner-spring + spring-cloud-contract-stub-runner + + + org.springframework.cloud + spring-cloud-contract-stub-runner-jetty + test org.springframework.cloud @@ -33,10 +38,6 @@ junit test - - org.codehaus.groovy - groovy - org.spockframework spock-core @@ -52,11 +53,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-starter-web - test - info.solidsoft.spock spock-global-unroll diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/AdhocTestSuite.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/AdhocTestSuite.groovy new file mode 100644 index 0000000000..3bf905cf9b --- /dev/null +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/AdhocTestSuite.groovy @@ -0,0 +1,39 @@ +/* + * Copyright 2012-2013 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; + +import org.junit.Ignore +import org.junit.runner.RunWith +import org.junit.runners.Suite +import org.junit.runners.Suite.SuiteClasses +import org.springframework.cloud.contract.stubrunner.spring.StubRunnerConfigurationSpec +import org.springframework.cloud.contract.stubrunner.spring.cloud.StubRunnerSpringCloudAutoConfigurationSpec + +/** + * A test suite for probing weird ordering problems in the tests. + * + * @author Dave Syer + */ +@RunWith(Suite) +@SuiteClasses([ + StubRunnerSpringCloudAutoConfigurationSpec, + StubRunnerConfigurationSpec + ]) +@Ignore +public class AdhocTestSuite { + +} diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleCustomPortJUnitTest.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleCustomPortJUnitTest.java index 06519312b3..42843de0b9 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleCustomPortJUnitTest.java +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleCustomPortJUnitTest.java @@ -36,8 +36,8 @@ public class StubRunnerRuleCustomPortJUnitTest { @BeforeClass @AfterClass public static void setupProps() { - System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); - System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); + System.clearProperty("stubrunner.stubs.repository.root"); + System.clearProperty("stubrunner.stubs.classifier"); } // tag::classrule_with_port[] diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleJUnitTest.java b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleJUnitTest.java index e5ae1d1c15..41cd3e9c85 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleJUnitTest.java +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleJUnitTest.java @@ -36,8 +36,8 @@ public class StubRunnerRuleJUnitTest { @BeforeClass @AfterClass public static void setupProps() { - System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); - System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); + System.clearProperty("stubrunner.stubs.repository.root"); + System.clearProperty("stubrunner.stubs.classifier"); } // tag::classrule[] diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleSpec.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleSpec.groovy index 3399d25ea0..241226de4d 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleSpec.groovy +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/junit/StubRunnerRuleSpec.groovy @@ -30,8 +30,8 @@ class StubRunnerRuleSpec extends Specification { @BeforeClass @AfterClass void setupProps() { - System.getProperties().setProperty("stubrunner.stubs.repository.root", ""); - System.getProperties().setProperty("stubrunner.stubs.classifier", "stubs"); + System.clearProperty("stubrunner.stubs.repository.root"); + System.clearProperty("stubrunner.stubs.classifier"); } // tag::classrule[] diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy index 6d749e0efa..2460562296 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy +++ b/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy @@ -16,12 +16,15 @@ package org.springframework.cloud.contract.stubrunner.spring +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.context.SpringBootContextLoader import org.springframework.cloud.contract.stubrunner.StubFinder import org.springframework.context.annotation.Configuration +import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import spock.lang.Specification @@ -31,11 +34,21 @@ import spock.lang.Specification */ // tag::test[] @ContextConfiguration(classes = Config, loader = SpringBootContextLoader) +// Not necessary if Spring Cloud is used. TODO: make it work without this. +@IntegrationTest("stubrunner.cloud.enabled=false") @AutoConfigureStubRunner +@DirtiesContext class StubRunnerConfigurationSpec extends Specification { @Autowired StubFinder stubFinder + @BeforeClass + @AfterClass + void setupProps() { + System.clearProperty("stubrunner.stubs.repository.root"); + System.clearProperty("stubrunner.stubs.classifier"); + } + def 'should start WireMock servers'() { expect: 'WireMocks are running' stubFinder.findStubUrl('org.springframework.cloud.contract.verifier.stubs', 'loanIssuance') != null diff --git a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/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 index fea4d2662d..52700d02d5 100644 --- a/spring-cloud-contract-stub-runner/spring-cloud-contract-stub-runner/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 @@ -19,6 +19,8 @@ package org.springframework.cloud.contract.stubrunner.spring.cloud import groovy.util.logging.Slf4j import org.apache.curator.test.TestingServer +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.IntegrationTest @@ -33,6 +35,7 @@ import org.springframework.cloud.zookeeper.discovery.ZookeeperServiceDiscovery import org.springframework.context.ConfigurableApplicationContext import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.ContextConfiguration import org.springframework.util.SocketUtils import org.springframework.web.client.RestTemplate @@ -44,8 +47,10 @@ import spock.lang.Specification */ @ContextConfiguration(classes = Config, loader = SpringBootContextLoader) @WebIntegrationTest(randomPort = true) +@IntegrationTest @Slf4j @AutoConfigureStubRunner +@DirtiesContext class StubRunnerSpringCloudAutoConfigurationSpec extends Specification { @Autowired StubFinder stubFinder @@ -54,6 +59,13 @@ class StubRunnerSpringCloudAutoConfigurationSpec extends Specification { @Autowired ZookeeperServiceDiscovery zookeeperServiceDiscovery @Autowired ConfigurableApplicationContext applicationContext + @BeforeClass + @AfterClass + void setupProps() { + System.clearProperty("stubrunner.stubs.repository.root"); + System.clearProperty("stubrunner.stubs.classifier"); + } + def 'should make service discovery work'() { expect: 'WireMocks are running' "${stubFinder.findStubUrl('loanIssuance').toString()}/name".toURL().text == 'loanIssuance'