au.com.dius:pact-jvm-provider_2.11:3.5.0-beta.4

Group / Artifact / Version au.com.dius / pact-jvm-provider_2.11 / 3.5.0-beta.4
Namepact-jvm-provider_2.11
DescriptionPact provider ============= sub project of https://github.com/DiUS/pact-jvm The pact provider is responsible for verifying that an API provider adheres to a number of pacts authored by its clients This library provides the basic tools required to automate the process, and should be usable on its own in many instances. Framework and build tool specific bindings will be provided in separate libraries that build on top of this core functionality. ### Running Pacts Main takes 2 arguments: The first is the root folder of your pact files (all .json files in root and subfolders are assumed to be pacts) The second is the location of your pact config json file. ### Pact config The pact config is a simple mapping of provider names to endpoint url's paths will be appended to endpoint url's when interactions are attempted for an example see: https://github.com/DiUS/pact-jvm/blob/master/pact-jvm-provider/src/test/resources/pact-config.json ### Provider State Before each interaction is executed, the provider under test will have the opportunity to enter a state. Generally the state maps to a set of fixture data for mocking out services that the provider is a consumer of (they will have their own pacts) The pact framework will instruct the test server to enter that state by sending: POST "${config.stateChangeUrl.url}/setup" { "state" : "${interaction.stateName}" } ### An example of running provider verification with junit This example uses java, junit and hamcrest matchers to run the provider verification. As the provider service is a DropWizard application, it uses the DropwizardAppRule to startup the service before running any test. Warning: It only grabs the first interaction from the pact file with the consumer, where there could be many. (This could possibly be solved with a parameterized test) ```java public class PactJVMProviderJUnitTest { @ClassRule public static TestRule startServiceRule = new DropwizardAppRule(DropwizardApp.class, "config.yml"); private static ProviderInfo serviceProvider; private static Pact testConsumerPact; @BeforeClass public static void setupProvider() { serviceProvider = new ProviderInfo("Dropwizard App"); serviceProvider.setProtocol("http"); serviceProvider.setHost("localhost"); serviceProvider.setPort(8080); serviceProvider.setPath("/"); ConsumerInfo consumer = new ConsumerInfo(); consumer.setName("test_consumer"); consumer.setPactFile(new File("target/pacts/ping_client-ping_service.json")); // serviceProvider.getConsumers().add(consumer); testConsumerPact = (Pact) new PactReader().loadPact(consumer.getPactFile()); } @Test @SuppressWarnings("unchecked") public void runConsumerPacts() { //grab the first interaction from the pact with consumer List interactions = scala.collection.JavaConversions.seqAsJavaList(testConsumerPact.interactions()); Interaction interaction1 = interactions.get(0); //setup any provider state //setup the client and interaction to fire against the provider ProviderClient client = new ProviderClient(); client.setProvider(serviceProvider); client.setRequest(interaction1.request()); Map clientResponse = (Map) client.makeRequest(); Map result = (Map) ResponseComparison.compareResponse(interaction1.response(), clientResponse, (int) clientResponse.get("statusCode"), (Map) clientResponse.get("headers"), (String) clientResponse.get("data")); //assert all good assertThat(result.get("method"), is(true)); // method type matches Map headers = (Map) result.get("headers"); //headers match headers.forEach( (k, v) -> assertThat(format("Header: [%s] does not match", k), v, org.
Last modified2017-05-14 11:54:34 UTC
URL https://github.com/DiUS/pact-jvm
Repository URL http://repo1.maven.org/maven2/au/com/dius/pact-jvm-provider_2.11/3.5.0-beta.4/
Packaging jar
POM File View
Effective POM File View
Dependency tag
<dependency>
  <groupId>au.com.dius</groupId>
  <artifactId>pact-jvm-provider_2.11</artifactId>
  <version>3.5.0-beta.4</version>
</dependency>
'au.com.dius:pact-jvm-provider_2.11:jar:3.5.0-beta.4'
<dependency org="au.com.dius" name="pact-jvm-provider_2.11" rev="3.5.0-beta.4" />
@Grapes(@Grab(group='au.com.dius', module='pact-jvm-provider_2.11', version='3.5.0-beta.4'))
compile 'au.com.dius:pact-jvm-provider_2.11:3.5.0-beta.4'
libraryDependencies += "au.com.dius" % "pact-jvm-provider_2.11" % "3.5.0-beta.4"
Repository tag
  <repository>
    <id>central</id>
    <url>http://repo1.maven.org/maven2/</url>
  </repository>
Used by
Packages

au.com.dius.pact.provider

au.com.dius.pact.provider.broker

au.com.dius.pact.provider.org.fusesource.jansi

au.com.dius.pact.provider.reporters

au.com.dius.pact.provider.sbtsupport

au.com.dius.pact.provider.unfiltered

SCM
  Urlhttps://github.com/DiUS/pact-jvm
  Connectionhttps://github.com/DiUS/pact-jvm.git
Dependencies
GroupArtifactVersion
org.jetbrains.kotlinkotlin-stdlib-jre81.1.2
org.jetbrains.kotlinkotlin-reflect1.1.2
org.slf4jslf4j-api1.7.21
org.codehaus.groovygroovy-all2.4.7
io.github.microutilskotlin-logging1.4.4
org.scala-langscala-library2.11.8
org.scala-langscala-compiler2.11.8
com.typesafe.scala-loggingscala-logging_2.113.4.0
au.com.diuspact-jvm-model3.5.0-beta.4
au.com.diuspact-jvm-matchers_2.113.5.0-beta.4
org.scalatestscalatest_2.112.2.6
commons-iocommons-io2.5
org.fusesource.jansijansi1.13
org.codehaus.groovy.modules.http-builderhttp-builder0.7.1
org.apache.httpcomponentshttpclient4.5.2
org.reflectionsreflections0.9.10
net.databinderunfiltered-netty-server_2.110.8.4
net.databinder.dispatchdispatch-core_2.110.11.3
org.specs2specs2-core_2.113.8.4
org.specs2specs2-junit_2.113.8.4
org.hamcresthamcrest-all1.3
org.mockitomockito-core1.10.19
junitjunit4.12
org.spockframeworkspock-core1.1-groovy-2.4
cglibcglib3.2.4
org.objenesisobjenesis2.4
au.com.diuspact-jvm-consumer-groovy_2.113.5.0-beta.4
Plugins
GroupArtifactVersion
org.apache.maven.pluginsmaven-clean-plugin2.5
org.apache.maven.pluginsmaven-resources-plugin2.6
org.apache.maven.pluginsmaven-jar-plugin2.4
org.apache.maven.pluginsmaven-compiler-plugin3.1
org.apache.maven.pluginsmaven-surefire-plugin2.12.4
org.apache.maven.pluginsmaven-install-plugin2.4
org.apache.maven.pluginsmaven-deploy-plugin2.7
org.apache.maven.pluginsmaven-site-plugin3.3
Licenses
  NameApache 2
  Urlhttp://www.apache.org/licenses/LICENSE-2.0.txt
  Distributionrepo