au.com.dius:pact-jvm-consumer-junit_2.10:2.0.1

Group / Artifact / Version au.com.dius / pact-jvm-consumer-junit_2.10 / 2.0.1
Namepact-jvm-consumer-junit_2.10
Descriptionpact-jvm-consumer-junit ======================= Bindings for the junit library ##Dependency The library is available on maven central using: group-id = `au.com.dius` artifact-id = `pact-jvm-consumer-junit_2.10` version-id = `2.0.0` ##Usage To write a pact spec extend ConsumerPactTest Here is an example: ``` import au.com.dius.pact.model.PactFragment; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.assertEquals; public class ExampleJavaConsumerPactTest extends ConsumerPactTest { @Override protected PactFragment createFragment(ConsumerPactBuilder.PactDslWithProvider builder) { Map headers = new HashMap(); headers.put("testreqheader", "testreqheadervalue"); return builder .given("test state") // NOTE: Using provider states are optional, you can leave it out .uponReceiving("java test interaction") .path("/") .method("GET") .headers(headers) .body("{\"test\":true}") .willRespondWith() .status(200) .headers(headers) .body("{\"responsetest\":true}").toFragment(); } @Override protected String providerName() { return "test_provider"; } @Override protected String consumerName() { return "test_consumer"; } @Override protected void runTest(String url) { try { assertEquals(new ConsumerClient(url).get("/"), "{\"responsetest\":true}"); } catch (Exception e) { // NOTE: if you want to see any pact failure, do not throw an exception here. This should be // fixed at some point (see Issue #40 https://github.com/DiUS/pact-jvm/issues/40) throw new RuntimeException(e); } } } ``` ## Debugging pact failures When the test runs, Pact will start a mock provider that will listen for requests and match them against the expectations you setup in `createFragment`. If the request does not match, it will return a 500 error response. Each request received and the generated response is logged using [SLF4J](http://www.slf4j.org/). Just enable debug level logging for au.com.dius.pact.consumer.UnfilteredMockProvider. Most failures tend to be mismatched headers or bodies.
Last modified2014-08-06 10:33:56 UTC
URL https://github.com/DiUS/pact-jvm
Repository URL https://oss.sonatype.org/content/repositories/releases/au/com/dius/pact-jvm-consumer-junit_2.10/2.0.1/
Packaging jar
POM File View
Effective POM File View
Dependency tag
<dependency>
  <groupId>au.com.dius</groupId>
  <artifactId>pact-jvm-consumer-junit_2.10</artifactId>
  <version>2.0.1</version>
</dependency>
'au.com.dius:pact-jvm-consumer-junit_2.10:jar:2.0.1'
<dependency org="au.com.dius" name="pact-jvm-consumer-junit_2.10" rev="2.0.1" />
@Grapes(@Grab(group='au.com.dius', module='pact-jvm-consumer-junit_2.10', version='2.0.1'))
compile 'au.com.dius:pact-jvm-consumer-junit_2.10:2.0.1'
libraryDependencies += "au.com.dius" % "pact-jvm-consumer-junit_2.10" % "2.0.1"
Repository tag
  <repository>
    <id>central</id>
    <url>http://repo1.maven.org/maven2/</url>
  </repository>
  <repository>
    <id>ibiblio.org-releases</id>
    <url>http://mirrors.ibiblio.org/maven2/</url>
  </repository>
  <repository>
    <id>sonatype-releases</id>
    <url>https://oss.sonatype.org/content/repositories/releases/</url>
  </repository>
  <repository>
    <id>sonatype-staging</id>
    <url>https://oss.sonatype.org/content/repositories/staging/</url>
  </repository>
  <repository>
    <id>spring-milestones</id>
    <url>http://repo.spring.io/libs-milestone/</url>
  </repository>
  <repository>
    <id>spring-plugin-releases</id>
    <url>http://repo.spring.io/plugins-release/</url>
  </repository>
  <repository>
    <id>spring-releases</id>
    <url>http://repo.spring.io/libs-release-remote/</url>
  </repository>
Packages

au.com.dius.pact.consumer

nl.flotsam.xeger