All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Download JAR files tagged by without with all dependencies

Search JAR files by class name

antlr3-maven-plugin from group org.antlr (version 3.5.3)

This is the brand new, re-written from scratch plugin for ANTLR v3. Previous valiant efforts all suffered from being unable to modify the ANTLR Tool itself to provide support not just for Maven oriented things but any other tool that might wish to invoke ANTLR without resorting to the command line interface. Rather than try to shoe-horn new code into the existing Mojo (in fact I think that by incorporating a patch supplied by someone I ended up with tow versions of the Mojo, I elected to rewrite everything from scratch, including the documentation, so that we might end up with a perfect Mojo that can do everything that ANTLR v3 supports such as imported grammar processing, proper support for library directories and locating token files from generated sources, and so on. In the end I decided to also change the the ANTLR Tool.java code so that it would be the provider of all the things that a build tool needs, rather than delegating things to 5 different tools. So, things like dependencies, dependency sorting, option tracking, generating sources and so on are all folded back in to ANTLR's Tool.java code, where they belong, and they now provide a public interface to anyone that might want to interface with them. One other goal of this rewrite was to completely document the whole thing to death. Hence even this pom has more comments than funcitonal elements, in case I get run over by a bus or fall off a cliff while skiing. Jim Idle - March 2009

Group: org.antlr Artifact: antlr3-maven-plugin
Show all versions Show documentation Show source 
 

1 downloads
Artifact antlr3-maven-plugin
Group org.antlr
Version 3.5.3
Last update 10. April 2022
Organization not specified
URL http://antlr.org
License not specified
Dependencies amount 6
Dependencies plexus-compiler-api, plexus-build-api, antlr, slf4j-api, slf4j-simple, antlr,
There are maybe transitive dependencies!

pact-jvm-consumer-java8_2.12 from group au.com.dius (version 3.6.15)

# pact-jvm-consumer-java8 Provides a Java8 lambda based DSL for use with Junit to build consumer tests. # A Lambda DSL for Pact This is an extension for the pact DSL provided by [pact-jvm-consumer](../pact-jvm-consumer). The difference between the default pact DSL and this lambda DSL is, as the name suggests, the usage of lambdas. The use of lambdas makes the code much cleaner. ## Why a new DSL implementation? The lambda DSL solves the following two main issues. Both are visible in the following code sample: ```java new PactDslJsonArray() .array() # open an array .stringValue("a1") # choose the method that is valid for arrays .stringValue("a2") # choose the method that is valid for arrays .closeArray() # close the array .array() # open an array .numberValue(1) # choose the method that is valid for arrays .numberValue(2) # choose the method that is valid for arrays .closeArray() # close the array .array() # open an array .object() # now we work with an object .stringValue("foo", "Foo") # choose the method that is valid for objects .closeObject() # close the object and we're back in the array .closeArray() # close the array ``` ### The existing DSL is quite error-prone Methods may only be called in certain states. For example `object()` may only be called when you're currently working on an array whereas `object(name)` is only allowed to be called when working on an object. But both of the methods are available. You'll find out at runtime if you're using the correct method. Finally, the need for opening and closing objects and arrays makes usage cumbersome. The lambda DSL has no ambiguous methods and there's no need to close objects and arrays as all the work on such an object is wrapped in a lamda call. ### The existing DSL is hard to read When formatting your source code with an IDE the code becomes hard to read as there's no indentation possible. Of course, you could do it by hand but we want auto formatting! Auto formatting works great for the new DSL! ```java array.object((o) -> { o.stringValue("foo", "Foo"); # an attribute o.stringValue("bar", "Bar"); # an attribute o.object("tar", (tarObject) -> { # an attribute with a nested object tarObject.stringValue("a", "A"); # attribute of the nested object tarObject.stringValue("b", "B"); # attribute of the nested object }) }); ``` ## Installation ### Maven ``` <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-java8_2.12</artifactId> <version>${pact.version}</version> </dependency> ``` ## Usage Start with a static import of `LambdaDsl`. This class contains factory methods for the lambda dsl extension. When you come accross the `body()` method of `PactDslWithProvider` builder start using the new extensions. The call to `LambdaDsl` replaces the call to instance `new PactDslJsonArray()` and `new PactDslJsonBody()` of the pact library. ```java io.pactfoundation.consumer.dsl.LambdaDsl.* ``` ### Response body as json array ```java import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonArray; ... PactDslWithProvider builder = ... builder.given("some state") .uponReceiving("a request") .path("/my-app/my-service") .method("GET") .willRespondWith() .status(200) .body(newJsonArray((a) -> { a.stringValue("a1"); a.stringValue("a2"); }).build()); ``` ### Response body as json object ```java import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody; ... PactDslWithProvider builder = ... builder.given("some state") .uponReceiving("a request") .path("/my-app/my-service") .method("GET") .willRespondWith() .status(200) .body(newJsonBody((o) -> { o.stringValue("foo", "Foo"); o.stringValue("bar", "Bar"); }).build()); ``` ### Examples #### Simple Json object When creating simple json structures the difference between the two approaches isn't big. ##### JSON ```json { "bar": "Bar", "foo": "Foo" } ``` ##### Pact DSL ```java new PactDslJsonBody() .stringValue("foo", "Foo") .stringValue("bar", "Bar") ``` ##### Lambda DSL ```java newJsonBody((o) -> { o.stringValue("foo", "Foo"); o.stringValue("bar", "Bar"); }).build(); ``` #### An array of arrays When we come to more complex constructs with arrays and nested objects the beauty of lambdas become visible! ##### JSON ```json [ ["a1", "a2"], [1, 2], [{"foo": "Foo"}] ] ``` ##### Pact DSL ```java new PactDslJsonArray() .array() .stringValue("a1") .stringValue("a2") .closeArray() .array() .numberValue(1) .numberValue(2) .closeArray() .array() .object() .stringValue("foo", "Foo") .closeObject() .closeArray(); ``` ##### Lambda DSL ```java newJsonArray((rootArray) -> { rootArray.array((a) -> a.stringValue("a1").stringValue("a2")); rootArray.array((a) -> a.numberValue(1).numberValue(2)); rootArray.array((a) -> a.object((o) -> o.stringValue("foo", "Foo"))); }).build(); ``` `object` is a reserved word in Kotlin. To allow using the DSL without escaping, a Kotlin extension `newObject` is available: ```kotlin newJsonArray { rootArray -> rootArray.array { a -> a.stringValue("a1").stringValue("a2") } rootArray.array { a -> a.numberValue(1).numberValue(2) } rootArray.array { a -> a.newObject { o -> o.stringValue("foo", "Foo") } } }.build(); ```

Group: au.com.dius Artifact: pact-jvm-consumer-java8_2.12
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-consumer-java8_2.12
Group au.com.dius
Version 3.6.15
Last update 29. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 1
Dependencies pact-jvm-consumer_2.12,
There are maybe transitive dependencies!

pact-jvm-provider-junit5-spring from group au.com.dius (version 4.0.10)

# Pact Spring/JUnit5 Support This module extends the base [Pact JUnit5 module](../pact-jvm-provider-junit5). See that for more details. For writing Spring Pact verification tests with JUnit 5, there is an JUnit 5 Invocation Context Provider that you can use with the `@TestTemplate` annotation. This will generate a test for each interaction found for the pact files for the provider. To use it, add the `@Provider` and `@ExtendWith(SpringExtension.class)` and one of the pact source annotations to your test class (as per a JUnit 5 test), then add a method annotated with `@TestTemplate` and `@ExtendWith(PactVerificationSpringProvider.class)` that takes a `PactVerificationContext` parameter. You will need to call `verifyInteraction()` on the context parameter in your test template method. For example: ```java @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @Provider("Animal Profile Service") @PactBroker public class ContractVerificationTest { @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } } ``` You will now be able to setup all the required properties using the Spring context, e.g. creating an application YAML file in the test resources: ```yaml pactbroker: host: your.broker.host auth: username: broker-user password: broker.password ``` You can also run pact tests against `MockMvc` without need to spin up the whole application context which takes time and often requires more additional setup (e.g. database). In order to run lightweight tests just use `@WebMvcTest` from Spring and `MockMvcTestTarget` as a test target before each test. For example: ```java @WebMvcTest @Provider("myAwesomeService") @PactBroker class ContractVerificationTest { @Autowired private MockMvc mockMvc; @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new MockMvcTestTarget(mockMvc)); } } ``` You can also use `MockMvcTestTarget` for tests without spring context by providing the controllers manually. For example: ```java @Provider("myAwesomeService") @PactFolder("pacts") class MockMvcTestTargetStandaloneMockMvcTestJava { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { MockMvcTestTarget testTarget = new MockMvcTestTarget(); testTarget.setControllers(new DataResource()); context.setTarget(testTarget); } @RestController static class DataResource { @GetMapping("/data") @ResponseStatus(HttpStatus.NO_CONTENT) void getData(@RequestParam("ticketId") String ticketId) { } } } ``` **Important:** Since `@WebMvcTest` starts only Spring MVC components you can't use `PactVerificationSpringProvider` and need to fallback to `PactVerificationInvocationContextProvider`

Group: au.com.dius Artifact: pact-jvm-provider-junit5-spring
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-junit5-spring
Group au.com.dius
Version 4.0.10
Last update 18. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!

web-grid from group org.apache.oodt (version 1.0)

The OODT grid services (product and profile services) use CORBA or RMI as their underlying network transport. However, limitations of CORBA and RMI make them inappropriate for large-scale deployments. For one, both are procedural mechanisms, providing a remote interface that resembles a method call. This makes streaming of data from a service impossible, because there are limitations to the sizes of data structures that can be passed over a remote method call. Instead, repeated calls must be made to retrieve each block of a product, making transfer speeds horribly slow compared to HTTP or FTP. (Block-based retrieval of profiles was never implemented, resulting in out of memory conditions for large profile results, which is another problem.) Second, both CORBA and RMI rely on a central name registry. The registry makes an object independent of its network location, enabling a client to call it by name (looking up its last known location in the registry). However, this requires that server objects be able to make outbound network calls to the registry (through any outbound firewall), and that the registry accept those registrations (through any inbound firewall). This required administrative action at institutions hosting server objects and at the institution hosting the registry. Often, these firewall exceptions would change without notice as system adminstrators changed at each location (apparently firewall exceptions are poorly documented everywhere). Further, in the two major deployments of OODT (PDS and EDRN), server objects have almost never moved, nullifying any benefit of the registry. This project, OODT Web Grid Services, avoids the prolems of CORBA and RMI by using HTTP as the transport mechanism for products and profiles. Further, it provides a password-protected mechanism to add new sets of product and profile query handlers, enabling seamless activation of additional capabilities.

Group: org.apache.oodt Artifact: web-grid
Show all versions Show documentation 
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact web-grid
Group org.apache.oodt
Version 1.0
Last update 21. June 2016
Organization not specified
URL Not specified
License not specified
Dependencies amount 7
Dependencies apache-jena-libs, oodt-commons, oodt-product, oodt-profile, oodt-xmlquery, xalan, xercesImpl,
There are maybe transitive dependencies!

alphatier from group io.alphatier (version 0.3.0)

Alphatier is a resource management library. It is designed to allow different schedulers to share the resources of a pool of executors in order to execute tasks with those. Read the [detailed documentation](#io.alphatier.pools) below to get an in-depth understanding. ## License Copyright &copy; 2014 [Tobias Sarnowski](mailto:[email protected]), [Willi Schönborn](mailto:[email protected]) Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ## Usage The library is written in [Clojure](http://clojure.org/) and is available in the [central Maven repository](https://repo1.maven.org/maven2/io/alphatier/alphatier/): <dependency> <groupId>io.alphatier</groupId> <artifactId>alphatier</artifactId> <version>0.3.0</version> </dependency> The library is written in pure Clojure without [ahead-of-time compilation](http://clojure.org/compilation). This means, that the library does not contain any *.class files. If you work with Clojure, this is not a problem but if you like to use the library from another JVM language (like Java, Scala or Groovy), you can use [Clojure's built-in tools](http://clojure.org/java_interop#Java%20Interop-Calling%20Clojure%20From%20Java) for interoperability or try our Java library: [https://github.com/sarnowski/alphatier-java](https://github.com/sarnowski/alphatier-java) ### Development If you like to change this library, please have a look at the [README](README.md). Development is done via [Github](https://github.com/sarnowski/alphatier).

Group: io.alphatier Artifact: alphatier
Show all versions 
 

0 downloads
Artifact alphatier
Group io.alphatier
Version 0.3.0
Last update 16. October 2014
Organization not specified
URL http://alphatier.io
License ISC License
Dependencies amount 3
Dependencies clojure, core.incubator, core.typed,
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.12 from group au.com.dius (version 3.6.15)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.2.11&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=:consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. #### Returning values that can be injected (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. There are methods on the consumer DSLs that can provider an expression that contains variables (like &apos;/api/user/${id}&apos; for the path). The provider state callback can then return a map for values, and the `id` attribute from the map will be expanded in the expression. For URL callbacks, the values need to be returned as JSON in the response body. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=:consumer1,:consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.12
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.12
Group au.com.dius
Version 3.6.15
Last update 29. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 8
Dependencies pact-jvm-provider_2.12, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-provider-lein from group au.com.dius (version 4.0.10)

# Leiningen plugin to verify a provider Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein &quot;4.0.0&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=:consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. #### Returning values that can be injected (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. There are methods on the consumer DSLs that can provider an expression that contains variables (like &apos;/api/user/${id}&apos; for the path). The provider state callback can then return a map for values, and the `id` attribute from the map will be expanded in the expression. For URL callbacks, the values need to be returned as JSON in the response body. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=:consumer1,:consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein
Group au.com.dius
Version 4.0.10
Last update 18. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 10
Dependencies pact-jvm-provider, clojure, core.match, leiningen-core, maven-aether-provider, aether-connector-file, aether-connector-wagon, httpclient, jansi, groovy,
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.11 from group au.com.dius (version 3.5.24)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.2.11&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |:pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos; [version 3.5.18+]| |:pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=consumer1,consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.11
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.11
Group au.com.dius
Version 3.5.24
Last update 04. November 2018
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 15
Dependencies kotlin-stdlib-jdk8, kotlin-reflect, slf4j-api, groovy-all, kotlin-logging, scala-library, scala-logging_2.11, pact-jvm-provider_2.11, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-provider-lein_2.10 from group au.com.dius (version 2.4.20)

# Leiningen plugin to verify a provider [version 2.2.14+, 3.0.3+] Leiningen plugin for verifying pacts against a provider. The plugin provides a `pact-verify` task which will verify all configured pacts against your provider. ## To Use It ### 1. Add the plugin to your project plugins, preferably in it&apos;s own profile. ```clojure :profiles { :pact { :plugins [[au.com.dius/pact-jvm-provider-lein_2.11 &quot;3.0.3&quot; :exclusions [commons-logging]]] :dependencies [[ch.qos.logback/logback-core &quot;1.1.3&quot;] [ch.qos.logback/logback-classic &quot;1.1.3&quot;] [org.apache.httpcomponents/httpclient &quot;4.4.1&quot;]] }}} ``` ### 2. Define the pacts between your consumers and providers You define all the providers and consumers within the `:pact` configuration element of your project. ```clojure :pact { :service-providers { ; You can define as many as you need, but each must have a unique name :provider1 { ; All the provider properties are optional, and have sensible defaults (shown below) :protocol &quot;http&quot; :host &quot;localhost&quot; :port 8080 :path &quot;/&quot; :has-pact-with { ; Again, you can define as many consumers for each provider as you need, but each must have a unique name :consumer1 { ; pact file can be either a path or an URL :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ### 3. Execute `lein with-profile pact pact-verify` You will have to have your provider running for this to pass. ## Enabling insecure SSL For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `:insecure true` on the provider. ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :insecure true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` ## Specifying a custom trust store For environments that are running their own certificate chains: ```clojure :pact { :service-providers { :provider1 { :protocol &quot;https&quot; :host &quot;localhost&quot; :port 8443 :trust-store &quot;relative/path/to/trustStore.jks&quot; :trust-store-password &quot;changeme&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` `:trust-store` is relative to the current working (build) directory. `:trust-store-password` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the requests before they are sent Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Leiningen plugin provides a request filter that can be set to an anonymous function on the provider that will be called before the request is made. This function will receive the HttpRequest object as a parameter. ```clojure :pact { :service-providers { :provider1 { ; function that adds an Authorization header to each request :request-filter #(.addHeader % &quot;Authorization&quot; &quot;oauth-token eyJhbGciOiJSUzI1NiIsIm...&quot;) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Modifying the HTTP Client Used The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a function assigned to `:create-client` on the provider that returns a `CloseableHttpClient`. The function will receive the provider info as a parameter. ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Plugin Properties The following plugin options can be specified on the command line: |Property|Description| |--------|-----------| |:pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |:pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |:pact.filter.consumers|Comma seperated list of consumer names to verify| |:pact.filter.description|Only verify interactions whose description match the provided regular expression| |:pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| Example, to run verification only for a particular consumer: ``` $ lein with-profile pact pact-verify :pact.filter.consumers=consumer2 ``` ## Provider States For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the `providerState` description from the pact file before each interaction via a POST. The `:state-change-uses-body` controls if the state is passed in the request body or as a query parameter. These values can be set at the provider level, or for a specific consumer. Consumer values take precedent if both are given. ```clojure :pact { :service-providers { :provider1 { :state-change-url &quot;http://localhost:8080/tasks/pactStateChange&quot; :state-change-uses-body false ; defaults to true :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` If the `:state-change-uses-body` is not specified, or is set to true, then the provider state description will be sent as JSON in the body of the request. If it is set to false, it will passed as a query parameter. As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before it is sent. Set `:state-change-request-filter` to an anonymous function on the provider that will be called before the request is made. ## Filtering the interactions that are verified You can filter the interactions that are run using three properties: `:pact.filter.consumers`, `:pact.filter.description` and `:pact.filter.providerState`. Adding `:pact.filter.consumers=consumer1,consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `:pact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `:pact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `:pact.filter.providerState=` will match any interaction that does not have a provider state. ## Starting and shutting down your provider For the pact verification to run, the provider needs to be running. Leiningen provides a `do` task that can chain tasks together. So, by creating a `start-app` and `terminate-app` alias, you could so something like: $ lein with-profile pact do start-app, pact-verify, terminate-app However, if the pact verification fails the build will abort without running the `terminate-app` task. To have the start and terminate tasks always run regardless of the state of the verification, you can assign them to `:start-provider-task` and `:terminate-provider-task` on the provider. ```clojure :aliases {&quot;start-app&quot; ^{:doc &quot;Starts the app&quot;} [&quot;tasks to start app ...&quot;] ; insert tasks to start the app here &quot;terminate-app&quot; ^{:doc &quot;Kills the app&quot;} [&quot;tasks to terminate app ...&quot;] ; insert tasks to stop the app here } :pact { :service-providers { :provider1 { :start-provider-task &quot;start-app&quot; :terminate-provider-task &quot;terminate-app&quot; :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ``` Then you can just run: $ lein with-profile pact pact-verify and the `start-app` and `terminate-app` tasks will run before and after the provider verification. ## Specifying the provider hostname at runtime [3.0.4+] If you need to calculate the provider hostname at runtime (for instance it is run as a new docker container or AWS instance), you can give an anonymous function as the provider host that returns the host name. The function will receive the provider information as a parameter. ```clojure :pact { :service-providers { :provider1 { :host #(calculate-host-name %) :has-pact-with { :consumer1 { :pact-file &quot;path/to/provider1-consumer1-pact.json&quot; } } } } } ```

Group: au.com.dius Artifact: pact-jvm-provider-lein_2.10
Show all versions Show documentation Show source 
 

0 downloads
Artifact pact-jvm-provider-lein_2.10
Group au.com.dius
Version 2.4.20
Last update 14. April 2018
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 10
Dependencies slf4j-api, scala-library, pact-jvm-provider_2.10, clojure, core.match, leiningen-core, logback-core, logback-classic, httpclient, jansi,
There are maybe transitive dependencies!

pact-jvm-provider-gradle_2.12 from group au.com.dius (version 3.6.15)

pact-jvm-provider-gradle ======================== Gradle plugin for verifying pacts against a provider. The Gradle plugin creates a task `pactVerify` to your build which will verify all configured pacts against your provider. ## To Use It ### For Gradle versions prior to 2.1 #### 1.1. Add the pact-jvm-provider-gradle jar file to your build script class path: ```groovy buildscript { repositories { mavenCentral() } dependencies { classpath &apos;au.com.dius:pact-jvm-provider-gradle_2.10:3.2.11&apos; } } ``` #### 1.2. Apply the pact plugin ```groovy apply plugin: &apos;au.com.dius.pact&apos; ``` ### For Gradle versions 2.1+ ```groovy plugins { id &quot;au.com.dius.pact&quot; version &quot;3.2.11&quot; } ``` ### 2. Define the pacts between your consumers and providers ```groovy pact { serviceProviders { // You can define as many as you need, but each must have a unique name provider1 { // All the provider properties are optional, and have sensible defaults (shown below) protocol = &apos;http&apos; host = &apos;localhost&apos; port = 8080 path = &apos;/&apos; // Again, you can define as many consumers for each provider as you need, but each must have a unique name hasPactWith(&apos;consumer1&apos;) { // currently supports a file path using file() or a URL using url() pactSource = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } // Or if you have many pact files in a directory hasPactsWith(&apos;manyConsumers&apos;) { // Will define a consumer for each pact file in the directory. // Consumer name is read from contents of pact file pactFileLocation = file(&apos;path/to/pacts&apos;) } } } } ``` ### 3. Execute `gradle pactVerify` ## Specifying the provider hostname at runtime If you need to calculate the provider hostname at runtime, you can give a Closure as the provider `host`. ```groovy pact { serviceProviders { provider1 { host = { lookupHostName() } hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` _Since version 3.3.2+/2.4.17+_ you can also give a Closure as the provider `port`. ## Specifying the pact file or URL at runtime [versions 3.2.7/2.4.9+] If you need to calculate the pact file or URL at runtime, you can give a Closure as the provider `pactFile`. ```groovy pact { serviceProviders { provider1 { host = &apos;localhost&apos; hasPactWith(&apos;consumer1&apos;) { pactFile = { lookupPactFile() } } } } } ``` ## Starting and shutting down your provider If you need to start-up or shutdown your provider, define Gradle tasks for each action and set `startProviderTask` and `terminateProviderTask` properties of each provider. You could use the jetty tasks here if you provider is built as a WAR file. ```groovy // This will be called before the provider task task(&apos;startTheApp&apos;) { doLast { // start up your provider here } } // This will be called after the provider task task(&apos;killTheApp&apos;) { doLast { // kill your provider here } } pact { serviceProviders { provider1 { startProviderTask = startTheApp terminateProviderTask = killTheApp hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` Following typical Gradle behaviour, you can set the provider task properties to the actual tasks, or to the task names as a string (for the case when they haven&apos;t been defined yet). ## Preventing the chaining of provider verify task to `pactVerify` [version 3.4.1+] Normally a gradle task named `pactVerify_${provider.name}` is created and added as a task dependency for `pactVerify`. You can disable this dependency on a provider by setting `isDependencyForPactVerify` to `false` (defaults to `true`). ```groovy pact { serviceProviders { provider1 { isDependencyForPactVerify = false hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` To run this task, you would then have to explicitly name it as in ```gradle pactVerify_provider1```, a normal ```gradle pactVerify``` would skip it. This can be useful when you want to define two providers, one with `startProviderTask`/`terminateProviderTask` and as second without, so you can manually start your provider (to debug it from your IDE, for example) but still want a `pactVerify` to run normally from your CI build. ## Enabling insecure SSL [version 2.2.8+] For providers that are running on SSL with self-signed certificates, you need to enable insecure SSL mode by setting `insecure = true` on the provider. ```groovy pact { serviceProviders { provider1 { insecure = true // allow SSL with a self-signed cert hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` ## Specifying a custom trust store [version 2.2.8+] For environments that are running their own certificate chains: ```groovy pact { serviceProviders { provider1 { trustStore = new File(&apos;relative/path/to/trustStore.jks&apos;) trustStorePassword = &apos;changeit&apos; hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` `trustStore` is either relative to the current working (build) directory. `trustStorePassword` defaults to `changeit`. NOTE: The hostname will still be verified against the certificate. ## Modifying the HTTP Client Used [version 2.2.4+] The default HTTP client is used for all requests to providers (created with a call to `HttpClients.createDefault()`). This can be changed by specifying a closure assigned to createClient on the provider that returns a CloseableHttpClient. For example: ```groovy pact { serviceProviders { provider1 { createClient = { provider -&gt; // This will enable the client to accept self-signed certificates HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()) .setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, { x509Certificates, s -&gt; true }) .build()) .build() } hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` ## Modifying the requests before they are sent **NOTE on breaking change: Version 2.1.8+ uses Apache HttpClient instead of HttpBuilder so the closure will receive a HttpRequest object instead of a request Map.** Sometimes you may need to add things to the requests that can&apos;t be persisted in a pact file. Examples of these would be authentication tokens, which have a small life span. The Pact Gradle plugin provides a request filter that can be set to a closure on the provider that will be called before the request is made. This closure will receive the HttpRequest prior to it being executed. ```groovy pact { serviceProviders { provider1 { requestFilter = { req -&gt; // Add an authorization header to each request req.addHeader(&apos;Authorization&apos;, &apos;OAUTH eyJhbGciOiJSUzI1NiIsImN0eSI6ImFw...&apos;) } hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) } } } } ``` __*Important Note:*__ You should only use this feature for things that can not be persisted in the pact file. By modifying the request, you are potentially modifying the contract from the consumer tests! ## Turning off URL decoding of the paths in the pact file [version 3.3.3+] By default the paths loaded from the pact file will be decoded before the request is sent to the provider. To turn this behaviour off, set the system property `pact.verifier.disableUrlPathDecoding` to `true`. __*Important Note:*__ If you turn off the url path decoding, you need to ensure that the paths in the pact files are correctly encoded. The verifier will not be able to make a request with an invalid encoded path. ## Project Properties The following project properties can be specified with `-Pproperty=value` on the command line: |Property|Description| |--------|-----------| |pact.showStacktrace|This turns on stacktrace printing for each request. It can help with diagnosing network errors| |pact.showFullDiff|This turns on displaying the full diff of the expected versus actual bodies [version 3.3.6+]| |pact.filter.consumers|Comma seperated list of consumer names to verify| |pact.filter.description|Only verify interactions whose description match the provided regular expression| |pact.filter.providerState|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state| |pact.verifier.publishResults|Publishing of verification results will be skipped unless this property is set to &apos;true&apos;| |pact.matching.wildcard|Enables matching of map values ignoring the keys when this property is set to &apos;true&apos;| |pact.verifier.disableUrlPathDecoding|Disables decoding of request paths| |pact.pactbroker.httpclient.usePreemptiveAuthentication|Enables preemptive authentication with the pact broker when set to `true`| ## Provider States For a description of what provider states are, see the pact documentations: http://docs.pact.io/documentation/provider_states.html ### Using a state change URL For each provider you can specify a state change URL to use to switch the state of the provider. This URL will receive the providerState description and all the parameters from the pact file before each interaction via a POST. As for normal requests, a request filter (`stateChangeRequestFilter`) can also be set to manipulate the request before it is sent. ```groovy pact { serviceProviders { provider1 { hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) stateChangeUrl = url(&apos;http://localhost:8001/tasks/pactStateChange&apos;) stateChangeUsesBody = false // defaults to true stateChangeRequestFilter = { req -&gt; // Add an authorization header to each request req.addHeader(&apos;Authorization&apos;, &apos;OAUTH eyJhbGciOiJSUzI1NiIsImN0eSI6ImFw...&apos;) } } // or hasPactsWith(&apos;consumers&apos;) { pactFileLocation = file(&apos;path/to/pacts&apos;) stateChangeUrl = url(&apos;http://localhost:8001/tasks/pactStateChange&apos;) stateChangeUsesBody = false // defaults to true } } } } ``` If the `stateChangeUsesBody` is not specified, or is set to true, then the provider state description and parameters will be sent as JSON in the body of the request : ```json { &quot;state&quot; : &quot;a provider state description&quot;, &quot;params&quot;: { &quot;a&quot;: &quot;1&quot;, &quot;b&quot;: &quot;2&quot; } } ``` If it is set to false, they will be passed as query parameters. #### Teardown calls for state changes [version 3.2.5/2.4.7+] You can enable teardown state change calls by setting the property `stateChangeTeardown = true` on the provider. This will add an `action` parameter to the state change call. The setup call before the test will receive `action=setup`, and then a teardown call will be made afterwards to the state change URL with `action=teardown`. ### Using a Closure [version 2.2.2+] You can set a closure to be called before each verification with a defined provider state. The closure will be called with the state description and parameters from the pact file. ```groovy pact { serviceProviders { provider1 { hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) // Load a fixture file based on the provider state and then setup some database // data. Does not require a state change request so returns false stateChange = { providerState -&gt; // providerState is an instance of ProviderState def fixture = loadFixtuerForProviderState(providerState) setupDatabase(fixture) } } } } } ``` #### Teardown calls for state changes [version 3.2.5/2.4.7+] You can enable teardown state change calls by setting the property `stateChangeTeardown = true` on the provider. This will add an `action` parameter to the state change closure call. The setup call before the test will receive `setup`, as the second parameter, and then a teardown call will be made afterwards with `teardown` as the second parameter. ```groovy pact { serviceProviders { provider1 { hasPactWith(&apos;consumer1&apos;) { pactFile = file(&apos;path/to/provider1-consumer1-pact.json&apos;) // Load a fixture file based on the provider state and then setup some database // data. Does not require a state change request so returns false stateChange = { providerState, action -&gt; if (action == &apos;setup&apos;) { def fixture = loadFixtuerForProviderState(providerState) setupDatabase(fixture) } else { cleanupDatabase() } false } } } } } ``` #### Returning values that can be injected (3.6.11+) You can have values from the provider state callbacks be injected into most places (paths, query parameters, headers, bodies, etc.). This works by using the V3 spec generators with provider state callbacks that return values. One example of where this would be useful is API calls that require an ID which would be auto-generated by the database on the provider side, so there is no way to know what the ID would be beforehand. There are methods on the consumer DSLs that can provider an expression that contains variables (like &apos;/api/user/${id}&apos; for the path). The provider state callback can then return a map for values, and the `id` attribute from the map will be expanded in the expression. For URL callbacks, the values need to be returned as JSON in the response body. ## Filtering the interactions that are verified You can filter the interactions that are run using three project properties: `pact.filter.consumers`, `pact.filter.description` and `pact.filter.providerState`. Adding `-Ppact.filter.consumers=consumer1,consumer2` to the command line will only run the pact files for those consumers (consumer1 and consumer2). Adding `-Ppact.filter.description=a request for payment.*` will only run those interactions whose descriptions start with &apos;a request for payment&apos;. `-Ppact.filter.providerState=.*payment` will match any interaction that has a provider state that ends with payment, and `-Ppact.filter.providerState=` will match any interaction that does not have a provider state. ## Verifying pact files from a pact broker [version 3.1.1+/2.3.1+] You can setup your build to validate against the pacts stored in a pact broker. The pact gradle plugin will query the pact broker for all consumers that have a pact with the provider based on its name. For example: ```groovy pact { serviceProviders { provider1 { // You can get the latest pacts from the broker hasPactsFromPactBroker(&apos;http://pact-broker:5000/&apos;) // And/or you can get the latest pact with a specific tag hasPactsFromPactBrokerWithTag(&apos;http://pact-broker:5000/&apos;,&quot;tagname&quot;) } } } ``` This will verify all pacts found in the pact broker where the provider name is &apos;provider1&apos;. If you need to set any values on the consumers from the pact broker, you can add a Closure to configure them. ```groovy pact { serviceProviders { provider1 { hasPactsFromPactBroker(&apos;http://pact-broker:5000/&apos;) { consumer -&gt; stateChange = { providerState -&gt; /* state change code here */ true } } } } } ``` **NOTE: Currently the pacts are fetched from the broker during the configuration phase of the build. This means that if the broker is not available, you will not be able to run any Gradle tasks.** This should be fixed in a forth coming release. In the mean time, to only load the pacts when running the validate task, you can do something like: ```groovy pact { serviceProviders { provider1 { // Only load the pacts from the broker if the start tasks from the command line include pactVerify if (&apos;pactVerify&apos; in gradle.startParameter.taskNames) { hasPactsFromPactBroker(&apos;http://pact-broker:5000/&apos;) { consumer -&gt; stateChange = { providerState -&gt; /* state change code here */ true } } } } } } ``` ### Using an authenticated Pact Broker You can add the authentication details for the Pact Broker like so: ```groovy pact { serviceProviders { provider1 { hasPactsFromPactBroker(&apos;http://pact-broker:5000/&apos;, authentication: [&apos;Basic&apos;, pactBrokerUser, pactBrokerPassword]) } } } ``` `pactBrokerUser` and `pactBrokerPassword` can be defined in the gradle properties. Or with a bearer token: ```groovy pact { serviceProviders { provider1 { hasPactsFromPactBroker(&apos;http://pact-broker:5000/&apos;, authentication: [&apos;Bearer&apos;, pactBrokerToken]) } } } ``` Preemptive Authentication can be enabled by setting the `pact.pactbroker.httpclient.usePreemptiveAuthentication` Java system property to `true`. ## Verifying pact files from a S3 bucket [version 3.3.2+/2.4.17+] Pact files stored in an S3 bucket can be verified by using an S3 URL to the pact file. I.e., ```groovy pact { serviceProviders { provider1 { hasPactWith(&apos;consumer1&apos;) { pactFile = &apos;s3://bucketname/path/to/provider1-consumer1-pact.json&apos; } } } } ``` **NOTE:** you can&apos;t use the `url` function with S3 URLs, as the URL and URI classes from the Java SDK don&apos;t support URLs with the s3 scheme. # Publishing pact files to a pact broker [version 2.2.7+] The pact gradle plugin provides a `pactPublish` task that can publish all pact files in a directory to a pact broker. To use it, you need to add a publish configuration to the pact configuration that defines the directory where the pact files are and the URL to the pact broker. For example: ```groovy pact { publish { pactDirectory = &apos;/pact/dir&apos; // defaults to $buildDir/pacts pactBrokerUrl = &apos;http://pactbroker:1234&apos; } } ``` You can set any tags that the pacts should be published with by setting the `tags` property. A common use of this is setting the tag to the current source control branch. This supports using pact with feature branches. ```groovy pact { publish { pactDirectory = &apos;/pact/dir&apos; // defaults to $buildDir/pacts pactBrokerUrl = &apos;http://pactbroker:1234&apos; tags = [project.pactBrokerTag] } } ``` _NOTE:_ The pact broker requires a version for all published pacts. The `pactPublish` task will use the version of the gradle project by default. Make sure you have set one otherwise the broker will reject the pact files. _Version 3.2.2/2.4.3+_ you can override the version in the publish block. ## Publishing to an authenticated pact broker To publish to a broker protected by basic auth, include the username/password in the `pactBrokerUrl`. For example: ```groovy pact { publish { pactBrokerUrl = &apos;https://username:[email protected]&apos; } } ``` ### [version 3.3.9+] You can add the username and password as properties since version 3.3.9+ ```groovy pact { publish { pactBrokerUrl = &apos;https://mypactbroker.com&apos; pactBrokerUsername = &apos;username&apos; pactBrokerPassword = &apos;password&apos; } } ``` or with a bearer token ```groovy pact { publish { pactBrokerUrl = &apos;https://mypactbroker.com&apos; pactBrokerToken = &apos;token&apos; } } ``` ## Excluding pacts from being published [version 3.5.19+] You can exclude some of the pact files from being published by providing a list of regular expressions that match against the base names of the pact files. For example: ```groovy pact { publish { pactBrokerUrl = &apos;https://mypactbroker.com&apos; excludes = [ &apos;.*\\-\\d+$&apos; ] // exclude all pact files that end with a dash followed by a number in the name } } ``` # Verifying a message provider [version 2.2.12+] The Gradle plugin has been updated to allow invoking test methods that can return the message contents from a message producer. To use it, set the way to invoke the verification to `ANNOTATED_METHOD`. This will allow the pact verification task to scan for test methods that return the message contents. Add something like the following to your gradle build file: ```groovy pact { serviceProviders { messageProvider { verificationType = &apos;ANNOTATED_METHOD&apos; packagesToScan = [&apos;au.com.example.messageprovider.*&apos;] // This is optional, but leaving it out will result in the entire // test classpath being scanned hasPactWith(&apos;messageConsumer&apos;) { pactFile = url(&apos;url/to/messagepact.json&apos;) } } } } ``` Now when the `pactVerify` task is run, will look for methods annotated with `@PactVerifyProvider` in the test classpath that have a matching description to what is in the pact file. ```groovy class ConfirmationKafkaMessageBuilderTest { @PactVerifyProvider(&apos;an order confirmation message&apos;) String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setExchange(&apos;ASX&apos;) order.setSecurityCode(&apos;CBA&apos;) order.setPrice(BigDecimal.TEN) order.setUnits(15) order.setGst(new BigDecimal(&apos;15.0&apos;)) order.setFees(BigDecimal.TEN) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` It will then validate that the returned contents matches the contents for the message in the pact file. ## Publishing to the Gradle Community Portal To publish the plugin to the community portal: $ ./gradlew :pact-jvm-provider-gradle_2.11:publishPlugins # Verification Reports [versions 3.2.7/2.4.9+] The default behaviour is to display the verification being done to the console, and pass or fail the build via the normal Gradle mechanism. From versions 3.2.7/2.4.9+, additional reports can be generated from the verification. ## Enabling additional reports The verification reports can be controlled by adding a reports section to the pact configuration in the gradle build file. For example: ```groovy pact { reports { defaultReports() // adds the standard console output markdown // report in markdown format json // report in json format } } ``` Any report files will be written to &quot;build/reports/pact&quot;. ## Additional Reports The following report types are available in addition to console output (which is enabled by default): `markdown`, `json`. # Publishing verification results to a Pact Broker [version 3.5.4+] For pacts that are loaded from a Pact Broker, the results of running the verification can be published back to the broker against the URL for the pact. You will be able to see the result on the Pact Broker home screen. To turn on the verification publishing, set the project property `pact.verifier.publishResults` to `true` [version 3.5.18+].

Group: au.com.dius Artifact: pact-jvm-provider-gradle_2.12
Show all versions Show documentation Show source 
 

1 downloads
Artifact pact-jvm-provider-gradle_2.12
Group au.com.dius
Version 3.6.15
Last update 29. April 2020
Organization not specified
URL https://github.com/DiUS/pact-jvm
License Apache 2
Dependencies amount 2
Dependencies pact-jvm-provider_2.12, jansi,
There are maybe transitive dependencies!



Page 196 from 197 (items total 1963)


© 2015 - 2024 Weber Informatics LLC | Privacy Policy