diff --git a/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.groovy b/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.groovy deleted file mode 100644 index 1e24185d1f..0000000000 --- a/provider/spring/src/test/groovy/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.groovy +++ /dev/null @@ -1,22 +0,0 @@ -package au.com.dius.pact.provider.spring.testspringbootapp - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.Bean - -@SpringBootApplication -class TestApplication { - - @Singleton - class ObjectThatMustBeClosed { - boolean destroyed = false - - def shutdown() { - destroyed = true - } - } - - @Bean(destroyMethod= 'shutdown') - ObjectThatMustBeClosed mustBeClosed() { - ObjectThatMustBeClosed.instance - } -} diff --git a/provider/spring/src/test/java/au/com/dius/pact/provider/spring/ConsumerVersionSelectorTest.java b/provider/spring/src/test/java/au/com/dius/pact/provider/spring/ConsumerVersionSelectorTest.java new file mode 100644 index 0000000000..5bf25d596b --- /dev/null +++ b/provider/spring/src/test/java/au/com/dius/pact/provider/spring/ConsumerVersionSelectorTest.java @@ -0,0 +1,40 @@ +package au.com.dius.pact.provider.spring; + +import au.com.dius.pact.provider.junit.target.HttpTarget; +import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; +import au.com.dius.pact.provider.junitsupport.Provider; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; +import au.com.dius.pact.provider.junitsupport.loader.PactBrokerConsumerVersionSelectors; +import au.com.dius.pact.provider.junitsupport.loader.SelectorBuilder; +import au.com.dius.pact.provider.junitsupport.target.Target; +import au.com.dius.pact.provider.junitsupport.target.TestTarget; +import au.com.dius.pact.provider.spring.testspringbootapp.TestApplication; +import org.junit.AfterClass; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +@RunWith(SpringRestPactRunner.class) +@Provider("myAwesomeService") +@PactBroker(url = "http://broker.host") +@IgnoreNoPactsToVerify(ignoreIoErrors = "true") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = { TestApplication.class }) +public class ConsumerVersionSelectorTest { + @TestTarget + public final Target target = new HttpTarget(8332); + + static boolean called = false; + @PactBrokerConsumerVersionSelectors + public static SelectorBuilder consumerVersionSelectors() { + called = true; + return new SelectorBuilder().branch("current"); + } + + @AfterClass + public static void after() { + assertThat("consumerVersionSelectors() was not called", called, is(true)); + } +} diff --git a/provider/spring/src/test/java/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.java b/provider/spring/src/test/java/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.java new file mode 100644 index 0000000000..5bda271552 --- /dev/null +++ b/provider/spring/src/test/java/au/com/dius/pact/provider/spring/testspringbootapp/TestApplication.java @@ -0,0 +1,28 @@ +package au.com.dius.pact.provider.spring.testspringbootapp; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class TestApplication { + + public static class ObjectThatMustBeClosed { + private ObjectThatMustBeClosed() {} + + private static final ObjectThatMustBeClosed instance = new ObjectThatMustBeClosed(); + public static ObjectThatMustBeClosed getInstance() { + return instance; + } + + public boolean destroyed = false; + + public void shutdown() { + destroyed = true; + } + } + + @Bean(destroyMethod="shutdown") + ObjectThatMustBeClosed mustBeClosed() { + return ObjectThatMustBeClosed.getInstance(); + } +}