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

Download JAR files tagged by types with all dependencies

Search JAR files by class name

clirr-maven-plugin from group org.neo4j.build.plugins (version 1.0.1)

This is a specialized version of the Clirr Maven Plugin. It adds capabilities for excluding specific error types, as well as separating code into three, rather than two, subgroups: Internal code (no checks) Externally invoked code (Annotated with an "externally invoked" annotation, same as Externally implemented, but adding methods to interfaces and abstract classes is allowed) Externally implemented code (Assumed default. Full backwards compatibility required *unless* an interface is annotated with a defined adaptor annotation, in which case full backwards compatibility is required for the adaptor class, but the rules of @ExternallyInvoked apply to the interface itself) Clirr is a tool that checks Java libraries for binary and source compatibility with older releases. Basically you give it two sets of jar files and Clirr dumps out a list of changes in the public API. The clirr-maven-plugin can be configured to break the build, if it detects incompatible api changes. In a continuous integration process, the clirr-maven-plugin can automatically prevent accidental introduction of binary or source compatibility problems. Additionally, the plugin can generate a report as part of the generated site.

Group: org.neo4j.build.plugins Artifact: clirr-maven-plugin
Show all versions Show documentation Show source 
 

0 downloads
Artifact clirr-maven-plugin
Group org.neo4j.build.plugins
Version 1.0.1
Last update 09. November 2015
Organization not specified
URL Not specified
License The Apache Software License, Version 2.0
Dependencies amount 14
Dependencies clirr-core, bcel-findbugs, maven-artifact, maven-model, maven-plugin-api, maven-project, doxia-decoration-model, doxia-module-xhtml, doxia-sink-api, doxia-site-renderer, maven-reporting-api, plexus-i18n, plexus-utils, junit,
There are maybe transitive dependencies!

netbeans-color-codes-preview from group com.junichi11.netbeans.modules (version 0.13.4)

Show color codes preview per line in a sidebar area of an editor. <h2>Disable / Enable</h2> Check/Uncheck View > Show Colors <h2>Supported color patterns</h2> <ul> <li>Hex color code (e.g. #ffffff, #000)</li> <li>Css rgb/rgba values (e.g. rgb(0,0,0), rgba(255, 255, 255, 0.8))</li> <li>Css hsl/hsla values (e.g. hsl(0, 100%, 50%), hsla(120, 100%, 50%, 0.5))</li> <li>Named colors (e.g. red, blue)</li> <li>Java Color class (e.g. Color.black, new Color(100, 100, 100))</li> </ul> <h2>Multiple colors</h2> <ul> <li>Show top two colors in a sidebar if there are multiple colors in a line.</li> <li>If you want to check all colors, please click a specific rectangle. They will be shown as a list.</li> </ul> <h2>Change a color using the color chooser</h2> <ul> <li>Click a colored rectangle</li> <li>Click a color value of a list</li> <li>Select a new color in the color chooser</li> <li>An old color value will be changed to new one with the same format</li> </ul> <h2>Generate color codes</h2><p>You can generate color codes via a code generator(<kbd>Alt</kbd> + <kbd>Ins</kbd>).</p> <ol> <li>Run a code generator(Alt + Ins)</li> <li>Choose <code>Color...</code></li> <li>Choose format you expect (e.g. <code>new Color(r, g, b)</code>)</li> <li>Choose a color</li> <li>Click the OK button</li> <li>A color code is generated at the caret position</li> </ol> <h2>Options</h2> Tools > Options > Miscellaneous > Color Codes Preview <h3>Regex for enabled mime-types for Hex and CSS colors</h3> Default value is `^text/(x-)?(css|less|sass|scss)$`. If you would like to disable/enable some mime-types, please change the default regex. This pattern is used when the plugin checks a mime-type. <h3>Named Colors</h3> This option is `false` by default. If you would like to show named colors, please check it. <h2>NOTE</h2> <ul> <li>If you would like to show colors of `Color.decode(<hex>)` e.g. `Color.decode(#000000)`, Please add `java` to "Regex for enabled mime-types" of Hex and CSS e.g. (`^text/(x-)?(css|less|sass|scss|java)$`)</li> <li>Colors may be shown if they are not color codes. e.g. "#feature" contains #fea. This plugin recognizes it as a hex color code.</li> <li>If you use the GTK Look and Feel, you cannot change an alpha value in the color chooser.</li> <li>Hsl or hsla color values may not be changed correctly when you use the color chooser. (There may be 1% errors.)</li> </ul>

Group: com.junichi11.netbeans.modules Artifact: netbeans-color-codes-preview
Show all versions 
 

0 downloads
Artifact netbeans-color-codes-preview
Group com.junichi11.netbeans.modules
Version 0.13.4
Last update 10. October 2021
Organization not specified
URL https://github.com/junichi11/netbeans-color-codes-preview
License Apache License, Version 2.0
Dependencies amount 16
Dependencies org-netbeans-api-annotations-common, org-netbeans-modules-editor-lib2, org-netbeans-modules-editor-lib, org-openide-util, org-openide-util-ui, org-netbeans-modules-editor-mimelookup, org-openide-util-lookup, org-netbeans-modules-editor-settings, org-netbeans-modules-editor, org-openide-dialogs, org-netbeans-modules-editor-fold, org-openide-text, org-netbeans-modules-options-api, org-openide-awt, org-netbeans-modules-editor-document, org-openide-modules,
There are maybe transitive dependencies!

EasyConfig from group net.sf.ssg.tools (version 0.1)

EasyConfig provides simple way to overview and apply settings to file or folder based collections of files. Synonyms to "setting" are property, attribute, value while throughout application "setting" is used. The settings are groupped in "configuration" that is collection of settings from various sources. Main design concepts are: * minimalistic way to describe configuration * pluggable support for data types (validation), setting sources, source handlers Sample use case: An application is deployed in multiple locations. We need to quickly check key settings/parameters and optionally modify some of them. These values are located in different places: - in files directly in file structure - in files inside archive files (optionally nested archives) - values in DB tables - values accessible via URLs - other sources (just guessed: SSH/telnet connection+some command(s), UPnP devices, proprietary protocols, etc) We gather info from any supported (extendable) source and can modify and apply changes if supported by source (e.g. we can't update value that is count of rows in DB table, but we can read that value).

Group: net.sf.ssg.tools Artifact: EasyConfig
Show documentation Show source 
 

0 downloads
Artifact EasyConfig
Group net.sf.ssg.tools
Version 0.1
Last update 01. February 2013
Organization not specified
URL http://sourceforge.net/p/easyconfig
License The Apache Software License, Version 2.0
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!

chips-n-salsa from group org.cicirello (version 6.4.0)

Chips-n-Salsa is a Java library of customizable, hybridizable, iterative, parallel, stochastic, and self-adaptive local search algorithms. The library includes implementations of several stochastic local search algorithms, including simulated annealing, hill climbers, as well as constructive search algorithms such as stochastic sampling. Chips-n-Salsa now also includes genetic algorithms as well as evolutionary algorithms more generally. The library very extensively supports simulated annealing. It includes several classes for representing solutions to a variety of optimization problems. For example, the library includes a BitVector class that implements vectors of bits, as well as classes for representing solutions to problems where we are searching for an optimal vector of integers or reals. For each of the built-in representations, the library provides the most common mutation operators for generating random neighbors of candidate solutions, as well as common crossover operators for use with evolutionary algorithms. Additionally, the library provides extensive support for permutation optimization problems, including implementations of many different mutation operators for permutations, and utilizing the efficiently implemented Permutation class of the JavaPermutationTools (JPT) library. Chips-n-Salsa is customizable, making extensive use of Java's generic types, enabling using the library to optimize other types of representations beyond what is provided in the library. It is hybridizable, providing support for integrating multiple forms of local search (e.g., using a hill climber on a solution generated by simulated annealing), creating hybrid mutation operators (e.g., local search using multiple mutation operators), as well as support for running more than one type of search for the same problem concurrently using multiple threads as a form of algorithm portfolio. Chips-n-Salsa is iterative, with support for multistart metaheuristics, including implementations of several restart schedules for varying the run lengths across the restarts. It also supports parallel execution of multiple instances of the same, or different, stochastic local search algorithms for an instance of a problem to accelerate the search process. The library supports self-adaptive search in a variety of ways, such as including implementations of adaptive annealing schedules for simulated annealing, such as the Modified Lam schedule, implementations of the simpler annealing schedules but which self-tune the initial temperature and other parameters, and restart schedules that adapt to run length.

Group: org.cicirello Artifact: chips-n-salsa
Show all versions Show documentation Show source 
 

0 downloads
Artifact chips-n-salsa
Group org.cicirello
Version 6.4.0
Last update 28. July 2023
Organization Cicirello.Org
URL https://chips-n-salsa.cicirello.org/
License GPL-3.0-or-later
Dependencies amount 3
Dependencies jpt, rho-mu, core,
There are maybe transitive dependencies!

osgi-tests from group org.apache.axis2 (version 1.6.3)

Group: org.apache.axis2 Artifact: osgi-tests
Show source 
 

1 downloads
Artifact osgi-tests
Group org.apache.axis2
Version 1.6.3
Last update 27. June 2015
Organization not specified
URL http://axis.apache.org/axis2/java/core/
License not specified
Dependencies amount 1
Dependencies axis2-testutils,
There are maybe transitive dependencies!

axis2-parent from group org.apache.axis2 (version 1.6.3)

Axis2 is an effort to re-design and totally re-implement both Axis/Java and (eventually) Axis/C++ on a new architecture. Evolving from the now standard "handler chain" model which Axis1 pioneered, Axis2 is developing a more flexible pipeline architecture which can yet be managed and packaged in a more organized manner. This new design acknowledges the maturing of the Web services space in terms of new protocols such as WS-ReliableMessaging, WS-Security and WS-Addressing that are built on top of the base SOAP system. At the time Axis1 was designed, while it was fully expected that other protocols such as WS-ReliableMessaging would be built on top of it, there was not a proper extension architecture defined to enable clean composition of such layers. Thus, one of the key motivations for Axis2 is to provide a clean and simple environment for like Apache Sandesha and Apache WSS4J to layer on top of the base SOAP system. Another driving force for Axis2 as well as the move away from RPC oriented Web services towards more document-oriented, message style asynchronous service interactions. The Axis2 project is centered on a new representation for SOAP messages called AXIOM (AXIs Object Model). AXIOM consists of two parts: a complete XML Infoset representation and a SOAP Infoset representation on top of that. The XML Infoset representation provides a JDOM-like simple API but is built on a deferred model via a StAX-based (Streaming API for XML) pull parsing API. A key feature of AXIOM is that it allows one to stop building the XML tree and just access the pull stream directly; thus enabling both maximum flexibility and maximum performance. This approach allows us to support multiple levels of abstraction for consuming and offering Web services: using plain AXIOM, using generated code and statically data-bound data types and so on. At the time of Axis1's design, RPC-style, synchronous, request-response interactions were the order of the day for Web services. Today service interactions are much more message -oriented and exploit many different message exchange patterns. The Axis2 engine architecture is careful to not build in any assumptions of request-response patterns to ensure that it can be used easily to support arbitrary message exchange patterns.

Group: org.apache.axis2 Artifact: axis2-parent
Show all versions 
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact axis2-parent
Group org.apache.axis2
Version 1.6.3
Last update 27. June 2015
Organization not specified
URL http://axis.apache.org/axis2/java/core/
License not specified
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!

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

# Pact junit runner ## Overview Library provides ability to play contract tests against a provider service in JUnit fashionable way. Supports: - Out-of-the-box convenient ways to load pacts - Easy way to change assertion strategy - **org.junit.BeforeClass**, **org.junit.AfterClass** and **org.junit.ClassRule** JUnit annotations, that will be run once - before/after whole contract test suite. - **org.junit.Before**, **org.junit.After** and **org.junit.Rule** JUnit annotations, that will be run before/after each test of an interaction. - **au.com.dius.pact.provider.junit.State** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. These methods must either take no parameters or a single Map parameter. ## Example of HTTP test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactFolder(&quot;pacts&quot;) // Point where to find pacts (See also section Pacts source in documentation) public class ContractTest { // NOTE: this is just an example of embedded service that listens to requests, you should start here real service @ClassRule //Rule will be applied once: before/after whole contract test suite public static final ClientDriverRule embeddedService = new ClientDriverRule(8332); @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Rest data // Mock dependent service responses // ... embeddedService.addExpectation( onRequestTo(&quot;/data&quot;), giveEmptyResponse() ); } @State(&quot;default&quot;, &quot;no-data&quot;) // Method will be run before testing interactions that require &quot;default&quot; or &quot;no-data&quot; state public void toDefaultState() { // Prepare service before interaction that require &quot;default&quot; state // ... System.out.println(&quot;Now service in default state&quot;); } @State(&quot;with-data&quot;) // Method will be run before testing interactions that require &quot;with-data&quot; state public void toStateWithData(Map data) { // Prepare service before interaction that require &quot;with-data&quot; state. The provider state data will be passed // in the data parameter // ... System.out.println(&quot;Now service in state using data &quot; + data); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget(8332); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) } ``` ## Example of AMQP Message test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;) public class ConfirmationKafkaContractTest { @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new AmqpTarget(); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Message data preparation // ... } @PactVerifyProvider(&apos;an order confirmation message&apos;) String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setPrice(BigDecimal.TEN) order.setUnits(15) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` ## Provider state callback methods For the provider states in the pact being verified, you can define methods to be invoked to setup the correct state for each interaction. Just annotate a method with the `au.com.dius.pact.provider.junit.State` annotation and the method will be invoked before the interaction is verified. For example: ```java @State(&quot;SomeProviderState&quot;) // Must match the state description in the pact file public void someProviderState() { // Do what you need to set the correct state } ``` If there are parameters in the pact file, just add a Map parameter to the method to be able to access those parameters. ```java @State(&quot;SomeProviderState&quot;) public void someProviderState(Map&lt;String, Object&gt; providerStateParameters) { // Do what you need to set the correct state } ``` ### Provider state teardown methods [3.5.22+] If you need to tear down your provider state, you can annotate a method with the `@State` annotation with the action set to `StateChangeAction.TEARDOWN` and it will be invoked after the interaction is verified. ```java @State(&quot;SomeProviderState&quot;, action = StateChangeAction.TEARDOWN) public void someProviderStateCleanup() { // Do what you need to to teardown the state } ``` ## Pact source The Pact runner will automatically collect pacts based on annotations on the test class. For this purpose there are 3 out-of-the-box options (files from a directory, files from a set of URLs or a pact broker) or you can easily add your own Pact source. If you need to load a single pact file from the file system, use the `PactUrl` with the URL set to the file path. **Note:** You can only define one source of pacts per test class. ### Download pacts from a pact-broker To use pacts from a Pact Broker, annotate the test class with `@PactBroker(host=&quot;host.of.pact.broker.com&quot;, port = &quot;80&quot;)`. From _version 3.2.2/2.4.3+_ you can also specify the protocol, which defaults to &quot;http&quot;. The pact broker will be queried for all pacts with the same name as the provider annotation. For example, test all pacts for the &quot;Activity Service&quot; in the pact broker: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### _Version 3.2.3/2.4.4+_ - Using Java System properties The pact broker loader was updated to allow system properties to be used for the hostname, port or protocol. The port was changed to a string to allow expressions to be set. To use a system property or environment variable, you can place the property name in `${}` expression de-markers: ```java @PactBroker(host=&quot;${pactbroker.hostname}&quot;, port = &quot;80&quot;) ``` You can provide a default value by separating the property name with a colon (`:`): ```java @PactBroker(host=&quot;${pactbroker.hostname:localhost}&quot;, port = &quot;80&quot;) ``` #### _Version 3.5.3+_ - More Java System properties The default values of the `@PactBroker` annotation now enable variable interpolation. The following keys may be managed through the environment * `pactbroker.host` * `pactbroker.port` * `pactbroker.protocol` * `pactbroker.tags` (comma separated) * `pactbroker.auth.scheme` * `pactbroker.auth.username` * `pactbroker.auth.password` #### _Version 3.2.4/2.4.6+_ - Using tags with the pact broker The pact broker allows different versions to be tagged. To load all the pacts: ```java @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;, tags = {&quot;latest&quot;, &quot;dev&quot;, &quot;prod&quot;}) ``` The default value for tags is `latest` which is not actually a tag but instead corresponds to the latest version ignoring the tags. If there are multiple consumers matching the name specified in the provider annotation then the latest pact for each of the consumers is loaded. For any other value the latest pact tagged with the specified tag is loaded. Specifying multiple tags is an OR operation. For example if you specify `tags = {&quot;dev&quot;, &quot;prod&quot;}` then both the latest pact file tagged with `dev` and the latest pact file taggged with `prod` is loaded. #### _Version 3.3.4/2.4.19+_ - Using basic auth with the with the pact broker You can use basic authentication with the `@PactBroker` annotation by setting the `authentication` value to a `@PactBrokerAuth` annotation. For example: ```java @PactBroker(host = &quot;${pactbroker.url:localhost}&quot;, port = &quot;1234&quot;, tags = {&quot;latest&quot;, &quot;prod&quot;, &quot;dev&quot;}, authentication = @PactBrokerAuth(username = &quot;test&quot;, password = &quot;test&quot;)) ``` The `username` and `password` values also take Java system property expressions. ### Pact Url To use pacts from urls annotate the test class with ```java @PactUrl(urls = {&quot;http://build.server/zoo_app-animal_service.json&quot;} ) ``` If you need to load a single pact file from the file system, you can use the `PactUrl` with the URL set to the file path. ### Pact folder To use pacts from a resource folder of the project annotate test class with ```java @PactFolder(&quot;subfolder/in/resource/directory&quot;) ``` ### Custom pacts source It&apos;s possible to use a custom Pact source. For this, implement interface `au.com.dius.pact.provider.junit.loader.PactLoader` and annotate the test class with `@PactSource(MyOwnPactLoader.class)`. **Note:** class `MyOwnPactLoader` must have a default empty constructor or a constructor with one argument of class `Class` which at runtime will be the test class so you can get custom annotations of test class. ### Filtering the interactions that are verified [version 3.5.3+] By default, the pact runner will verify all pacts for the given provider. You can filter the pacts and interactions by the following methods. #### Filtering by Consumer You can run only those pacts for a particular consumer by adding a `@Consumer` annotation to the test class. For example: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @Consumer(&quot;Activity Consumer&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### Filtering by Provider State You can filter the interactions that are executed by adding a `@PactFilter` annotation to your test class. The pact filter annotation will then only verify interactions that have a matching provider state. You can provide multiple states to match with. For example: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) @PactFilter(&apos;Activity 100 exists in the database&apos;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` You can also use regular expressions with the filter [version 3.5.3+]. For example: ```java @RunWith(PactRunner.class) @PactFilter(&apos;Activity \\d+ exists in the database&apos;) public class PactJUnitTest { } ``` ### Setting the test to not fail when no pacts are found [version 3.5.3+] By default the pact runner will fail the verification test if no pact files are found to verify. To change the failure into a warning, add a `@IgnoreNoPactsToVerify` annotation to your test class. #### Ignoring IO errors loading pact files [version 3.5.24+] You can also set the test to ignore any IO and parser exceptions when loading the pact files by setting the `ignoreIoErrors` attribute on the annotation to `&quot;true&quot;` or setting the JVM system property `pact.verification.ignoreIoErrors` to `true`. ** WARNING! Do not enable this on your CI server, as this could result in your build passing with no providers having been verified due to a configuration error. ** ## Test target The field in test class of type `au.com.dius.pact.provider.junit.target.Target` annotated with `au.com.dius.pact.provider.junit.target.TestTarget` will be used for actual Interaction execution and asserting of contract. **Note:** there must be exactly 1 such field, otherwise an `InitializationException` will be thrown. ### HttpTarget `au.com.dius.pact.provider.junit.target.HttpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as http request and assert response from service by matching rules from pact. _Version 3.2.2/2.4.3+_ you can also specify the protocol, defaults to &quot;http&quot;. ### AmqpTarget `au.com.dius.pact.provider.junit.target.AmqpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as an AMQP message and assert response from service by matching rules from pact. #### Modifying the requests before they are sent [Version 3.2.3/2.4.5+] 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 HttpTarget supports request filters by annotating methods on the test class with `@TargetRequestFilter`. These methods must be public void methods that take a single HttpRequest parameter. For example: ```java @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { request.addHeader(&quot;Authorization&quot;, &quot;OAUTH hdsagasjhgdjashgdah...&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! #### 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. ### Custom Test Target It&apos;s possible to use custom `Target`, for that interface `Target` should be implemented and this class can be used instead of `HttpTarget`. # Verification Reports [versions 3.2.7/2.4.9+] The default test behaviour is to display the verification being done to the console, and pass or fail the test via the normal JUnit mechanism. From versions 3.2.7/2.4.9+, additional reports can be generated from the tests. ## Enabling additional reports via annotations on the test classes A `@VerificationReports` annotation can be added to any pact test class which will control the verification output. The annotation takes a list report types and an optional report directory (defaults to &quot;target/pact/reports&quot;). The currently supported report types are `console`, `markdown` and `json`. For example: ```java @VerificationReports({&quot;console&quot;, &quot;markdown&quot;}) public class MyPactTest { ``` will enable the markdown report in addition to the normal console output. And, ```java @VerificationReports(value = {&quot;markdown&quot;}, reportDir = &quot;/myreports&quot;) public class MyPactTest { ``` will disable the normal console output and write the markdown reports to &quot;/myreports&quot;. ## Enabling additional reports via Java system properties or environment variables The additional reports can also be enabled with Java System properties or environment variables. The following two properties have been introduced: `pact.verification.reports` and `pact.verification.reportDir`. `pact.verification.reports` is the comma separated list of report types to enable (e.g. `console,json,markdown`). `pact.verification.reportDir` is the directory to write reports to (defaults to &quot;target/pact/reports&quot;). ## Additional Reports The following report types are available in addition to console output (`console`, which is enabled by default): `markdown`, `json`. You can also provide a fully qualified classname as report so custom reports are also supported. This class must implement `au.com.dius.pact.provider.reporters.VerifierReporter` interface in order to be correct custom implementation of a report. # 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. You need to set the version of the provider that is verified using the `pact.provider.version` system property. To enable publishing of results, set the property `pact.verifier.publishResults` to `true` [version 3.5.18+].

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

9 downloads
Artifact pact-jvm-provider-junit_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, fluent-hc, httpclient, junit, commons-lang3, jool, guava-retrying, mail,
There are maybe transitive dependencies!

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

# Pact junit runner ## Overview Library provides ability to play contract tests against a provider service in JUnit fashionable way. Supports: - Out-of-the-box convenient ways to load pacts - Easy way to change assertion strategy - **org.junit.BeforeClass**, **org.junit.AfterClass** and **org.junit.ClassRule** JUnit annotations, that will be run once - before/after whole contract test suite. - **org.junit.Before**, **org.junit.After** and **org.junit.Rule** JUnit annotations, that will be run before/after each test of an interaction. - **au.com.dius.pact.provider.junit.State** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. ## Example of HTTP test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactFolder(&quot;pacts&quot;) // Point where to find pacts (See also section Pacts source in documentation) public class ContractTest { // NOTE: this is just an example of embedded service that listens to requests, you should start here real service @ClassRule //Rule will be applied once: before/after whole contract test suite public static final ClientDriverRule embeddedService = new ClientDriverRule(8332); @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Rest data // Mock dependent service responses // ... embeddedService.addExpectation( onRequestTo(&quot;/data&quot;), giveEmptyResponse() ); } @State(&quot;default&quot;, &quot;no-data&quot;) // Method will be run before testing interactions that require &quot;default&quot; or &quot;no-data&quot; state public void toDefaultState() { // Prepare service before interaction that require &quot;default&quot; state // ... System.out.println(&quot;Now service in default state&quot;); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget(8332); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) } ``` ## Example of AMQP Message test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;) public class ConfirmationKafkaContractTest { @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new AmqpTarget(); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Message data preparation // ... } @PactVerifyProvider(&apos;an order confirmation message&apos;) String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setPrice(BigDecimal.TEN) order.setUnits(15) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` ## Pact source The Pact runner will automatically collect pacts based on annotations on the test class. For this purpose there are 3 out-of-the-box options (files from a directory, files from a set of URLs or a pact broker) or you can easily add your own Pact source. **Note:** You can only define one source of pacts per test class. ### Download pacts from a pact-broker To use pacts from a Pact Broker, annotate the test class with `@PactBroker(host=&quot;host.of.pact.broker.com&quot;, port = &quot;80&quot;)`. From _version 3.2.2/2.4.3+_ you can also specify the protocol, which defaults to &quot;http&quot;. The pact broker will be queried for all pacts with the same name as the provider annotation. For example, test all pacts for the &quot;Activity Service&quot; in the pact broker: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### _Version 3.2.3/2.4.4+_ - Using Java System properties The pact broker loader was updated to allow system properties to be used for the hostname, port or protocol. The port was changed to a string to allow expressions to be set. To use a system property or environment variable, you can place the property name in `${}` expression de-markers: ```java @PactBroker(host=&quot;${pactbroker.hostname}&quot;, port = &quot;80&quot;) ``` You can provide a default value by separating the property name with a colon (`:`): ```java @PactBroker(host=&quot;${pactbroker.hostname:localhost}&quot;, port = &quot;80&quot;) ``` #### _Version ???/???+_ - More Java System properties The default values of the `@PactBroker` annotation now enable variable interpolation. The following keys may be managed through the environment * `pactbroker.host` * `pactbroker.port` * `pactbroker.protocol` * `pactbroker.tags` (comma separated) * `pactbroker.auth.scheme` * `pactbroker.auth.username` * `pactbroker.auth.password` #### _Version 3.2.4/2.4.6+_ - Using tags with the pact broker The pact broker allows different versions to be tagged. To load all the pacts: ```java @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;, tags = {&quot;latest&quot;, &quot;dev&quot;, &quot;prod&quot;}) ``` The default value for tags is `latest` which is not actually a tag but instead corresponds to the latest version ignoring the tags. If there are multiple consumers matching the name specified in the provider annotation then the latest pact for each of the consumers is loaded. For any other value the latest pact tagged with the specified tag is loaded. Specifying multiple tags is an OR operation. For example if you specify `tags = {&quot;dev&quot;, &quot;prod&quot;}` then both the latest pact file tagged with `dev` and the latest pact file taggged with `prod` is loaded. #### _Version 3.3.4/2.4.19+_ - Using basic auth with the with the pact broker You can use basic authentication with the `@PactBroker` annotation by setting the `authentication` value to a `@PactBrokerAuth` annotation. For example: ```java @PactBroker(host = &quot;${pactbroker.url:localhost}&quot;, port = &quot;1234&quot;, tags = {&quot;latest&quot;, &quot;prod&quot;, &quot;dev&quot;}, authentication = @PactBrokerAuth(username = &quot;test&quot;, password = &quot;test&quot;)) ``` The `username` and `password` values also take Java system property expressions. ### Pact Url To use pacts from urls annotate the test class with ```java @PactUrl(urls = {&quot;http://build.server/zoo_app-animal_service.json&quot;} ) ``` ### Pact folder To use pacts from a resource folder of the project annotate test class with ```java @PactFolder(&quot;subfolder/in/resource/directory&quot;) ``` ### Custom pacts source It&apos;s possible to use a custom Pact source. For this, implement interface `au.com.dius.pact.provider.junit.loader.PactLoader` and annotate the test class with `@PactSource(MyOwnPactLoader.class)`. **Note:** class `MyOwnPactLoader` must have a default empty constructor or a constructor with one argument of class `Class` which at runtime will be the test class so you can get custom annotations of test class. ## Test target The field in test class of type `au.com.dius.pact.provider.junit.target.Target` annotated with `au.com.dius.pact.provider.junit.target.TestTarget` will be used for actual Interaction execution and asserting of contract. **Note:** there must be exactly 1 such field, otherwise an `InitializationException` will be thrown. ### HttpTarget `au.com.dius.pact.provider.junit.target.HttpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as http request and assert response from service by matching rules from pact. _Version 3.2.2/2.4.3+_ you can also specify the protocol, defaults to &quot;http&quot;. ### AmqpTarget `au.com.dius.pact.provider.junit.target.AmqpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as an AMQP message and assert response from service by matching rules from pact. #### Modifying the requests before they are sent [Version 3.2.3/2.4.5+] 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 HttpTarget supports request filters by annotating methods on the test class with `@TargetRequestFilter`. These methods must be public void methods that take a single HttpRequest parameter. For example: ```java @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { request.addHeader(&quot;Authorization&quot;, &quot;OAUTH hdsagasjhgdjashgdah...&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! #### 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. ### Custom Test Target It&apos;s possible to use custom `Target`, for that interface `Target` should be implemented and this class can be used instead of `HttpTarget`. # Verification Reports [versions 3.2.7/2.4.9+] The default test behaviour is to display the verification being done to the console, and pass or fail the test via the normal JUnit mechanism. From versions 3.2.7/2.4.9+, additional reports can be generated from the tests. ## Enabling additional reports via annotations on the test classes A `@VerificationReports` annotation can be added to any pact test class which will control the verification output. The annotation takes a list report types and an optional report directory (defaults to &quot;target/pact/reports&quot;). The currently supported report types are `console`, `markdown` and `json`. For example: ```java @VerificationReports({&quot;console&quot;, &quot;markdown&quot;}) public class MyPactTest { ``` will enable the markdown report in addition to the normal console output. And, ```java @VerificationReports(value = {&quot;markdown&quot;}, reportDir = &quot;/myreports&quot;) public class MyPactTest { ``` will disable the normal console output and write the markdown reports to &quot;/myreports&quot;. ## Enabling additional reports via Java system properties or environment variables The additional reports can also be enabled with Java System properties or environment variables. The following two properties have been introduced: `pact.verification.reports` and `pact.verification.reportDir`. `pact.verification.reports` is the comma separated list of report types to enable (e.g. `console,json,markdown`). `pact.verification.reportDir` is the directory to write reports to (defaults to &quot;target/pact/reports&quot;). ## Additional Reports The following report types are available in addition to console output (`console`, which is enabled by default): `markdown`, `json`. You can also provide a fully qualified classname as report so custom reports are also supported. This class must implement `au.com.dius.pact.provider.reporters.VerifierReporter` interface in order to be correct custom implementation of a report.

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

3 downloads
Artifact pact-jvm-provider-junit_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 9
Dependencies slf4j-api, scala-library, pact-jvm-provider_2.10, fluent-hc, httpclient, junit, commons-lang3, jackson-databind, commons-collections4,
There are maybe transitive dependencies!

pact-jvm-consumer-groovy_2.10 from group au.com.dius (version 2.4.20)

pact-jvm-consumer-groovy ========================= Groovy DSL for Pact JVM ## Dependency The library is available on maven central using: * group-id = `au.com.dius` * artifact-id = `pact-jvm-consumer-groovy_2.11` * version-id = `2.4.x` or `3.2.x` ## Usage Add the `pact-jvm-consumer-groovy` library to your test class path. This provides a `PactBuilder` class for you to use to define your pacts. For a full example, have a look at the example JUnit `ExampleGroovyConsumerPactTest`. If you are using gradle for your build, add it to your `build.gradle`: dependencies { testCompile &apos;au.com.dius:pact-jvm-consumer-groovy_2.11:3.2.14&apos; } Then create an instance of the `PactBuilder` in your test. ```groovy @Test void &quot;A service consumer side of a pact goes a little something like this&quot;() { def alice_service = new PactBuilder() // Create a new PactBuilder alice_service { serviceConsumer &quot;Consumer&quot; // Define the service consumer by name hasPactWith &quot;Alice Service&quot; // Define the service provider that it has a pact with port 1234 // The port number for the service. It is optional, leave it out to // to use a random one given(&apos;there is some good mallory&apos;) // defines a provider state. It is optional. uponReceiving(&apos;a retrieve Mallory request&apos;) // upon_receiving starts a new interaction withAttributes(method: &apos;get&apos;, path: &apos;/mallory&apos;) // define the request, a GET request to &apos;/mallory&apos; willRespondWith( // define the response we want returned status: 200, headers: [&apos;Content-Type&apos;: &apos;text/html&apos;], body: &apos;&quot;That is some good Mallory.&quot;&apos; ) } // Execute the run method to have the mock server run. // It takes a closure to execute your requests and returns a Pact VerificationResult. VerificationResult result = alice_service.run() { def client = new RESTClient(&apos;http://localhost:1234/&apos;) def alice_response = client.get(path: &apos;/mallory&apos;) assert alice_response.status == 200 assert alice_response.contentType == &apos;text/html&apos; def data = alice_response.data.text() assert data == &apos;&quot;That is some good Mallory.&quot;&apos; } assert result == PactVerified$.MODULE$ // This means it is all good in weird Scala speak. } ``` After running this test, the following pact file is produced: { &quot;provider&quot; : { &quot;name&quot; : &quot;Alice Service&quot; }, &quot;consumer&quot; : { &quot;name&quot; : &quot;Consumer&quot; }, &quot;interactions&quot; : [ { &quot;provider_state&quot; : &quot;there is some good mallory&quot;, &quot;description&quot; : &quot;a retrieve Mallory request&quot;, &quot;request&quot; : { &quot;method&quot; : &quot;get&quot;, &quot;path&quot; : &quot;/mallory&quot;, &quot;requestMatchers&quot; : { } }, &quot;response&quot; : { &quot;status&quot; : 200, &quot;headers&quot; : { &quot;Content-Type&quot; : &quot;text/html&quot; }, &quot;body&quot; : &quot;That is some good Mallory.&quot;, &quot;responseMatchers&quot; : { } } } ] } ### DSL Methods #### serviceConsumer(String consumer) This names the service consumer for the pact. #### hasPactWith(String provider) This names the service provider for the pact. #### port(int port) Sets the port that the mock server will run on. If not supplied, a random port will be used. #### given(String providerState) Defines a state that the provider needs to be in for the request to succeed. For more info, see https://github.com/realestate-com-au/pact/wiki/Provider-states #### uponReceiving(String requestDescription) Starts the definition of a of a pact interaction. #### withAttributes(Map requestData) Defines the request for the interaction. The request data map can contain the following: | key | Description | Default Value | |----------------------------|-------------------------------------------|-----------------------------| | method | The HTTP method to use | get | | path | The Path for the request | / | | query | Query parameters as a Map&lt;String, List&gt; | | | headers | Map of key-value pairs for the request headers | | | body | The body of the request. If it is not a string, it will be converted to JSON. Also accepts a PactBodyBuilder. | | | prettyPrint | Boolean value to control if the body is pretty printed. See note on Pretty Printed Bodies below | For the path, header attributes and query parameters (version 2.2.2+ for headers, 3.3.7+ for query parameters), you can use regular expressions to match. You can either provide a regex `Pattern` class or use the `regexp` method to construct a `RegexpMatcher` (you can use any of the defined matcher methods, see DSL methods below). If you use a `Pattern`, or the `regexp` method but don&apos;t provide a value, a random one will be generated from the regular expression. This value is used when generating requests. For example: ```groovy .withAttributes(path: ~&apos;/transaction/[0-9]+&apos;) // This will generate a random path for requests // or .withAttributes(path: regexp(&apos;/transaction/[0-9]+&apos;, &apos;/transaction/1234567890&apos;)) ``` #### withBody(Closure closure) Constructs the body of the request or response by invoking the supplied closure in the context of a PactBodyBuilder. ##### Pretty Printed Bodies [Version 2.2.15+, 3.0.4+] An optional Map can be supplied to control how the body is generated. The option values are available: | Option | Description | |--------|-------------| | mimeType | The mime type of the body. Defaults to `application/json` | | prettyPrint | Boolean value controlling whether to pretty-print the body or not. Defaults to true | If the prettyPrint option is not specified, the bodies will be pretty printed unless the mime type corresponds to one that requires compact bodies. Currently only `application/x-thrift+json` is classed as requiring a compact body. For an example of turning off pretty printing: ```groovy service { uponReceiving(&apos;a request&apos;) withAttributes(method: &apos;get&apos;, path: &apos;/&apos;) withBody(prettyPrint: false) { name &apos;harry&apos; surname &apos;larry&apos; } } ``` #### willRespondWith(Map responseData) Defines the response for the interaction. The response data map can contain the following: | key | Description | Default Value | |----------------------------|-------------------------------------------|-----------------------------| | status | The HTTP status code to return | 200 | | headers | Map of key-value pairs for the response headers | | | body | The body of the response. If it is not a string, it will be converted to JSON. Also accepts a PactBodyBuilder. | | | prettyPrint | Boolean value to control if the body is pretty printed. See note on Pretty Printed Bodies above | For the headers (version 2.2.2+), you can use regular expressions to match. You can either provide a regex `Pattern` class or use the `regexp` method to construct a `RegexpMatcher` (you can use any of the defined matcher methods, see DSL methods below). If you use a `Pattern`, or the `regexp` method but don&apos;t provide a value, a random one will be generated from the regular expression. This value is used when generating responses. For example: ```groovy .willRespondWith(headers: [LOCATION: ~&apos;/transaction/[0-9]+&apos;]) // This will generate a random location value // or .willRespondWith(headers: [LOCATION: regexp(&apos;/transaction/[0-9]+&apos;, &apos;/transaction/1234567890&apos;)]) ``` #### VerificationResult run(Closure closure) The `run` method starts the mock server, and then executes the provided closure. It then returns the pact verification result for the pact run. If you require access to the mock server configuration for the URL, it is passed into the closure, e.g., ```groovy VerificationResult result = alice_service.run() { config -&gt; def client = new RESTClient(config.url()) def alice_response = client.get(path: &apos;/mallory&apos;) } ``` ### Body DSL For building JSON bodies there is a `PactBodyBuilder` that provides as DSL that includes matching with regular expressions and by types. For a more complete example look at `PactBodyBuilderTest`. For an example: ```groovy service { uponReceiving(&apos;a request&apos;) withAttributes(method: &apos;get&apos;, path: &apos;/&apos;) withBody { name(~/\w+/, &apos;harry&apos;) surname regexp(~/\w+/, &apos;larry&apos;) position regexp(~/staff|contractor/, &apos;staff&apos;) happy(true) } } ``` This will return the following body: ```json { &quot;name&quot;: &quot;harry&quot;, &quot;surname&quot;: &quot;larry&quot;, &quot;position&quot;: &quot;staff&quot;, &quot;happy&quot;: true } ``` and add the following matchers: ```json { &quot;$.body.name&quot;: {&quot;regex&quot;: &quot;\\w+&quot;}, &quot;$.body.surname&quot;: {&quot;regex&quot;: &quot;\\w+&quot;}, &quot;$.body.position&quot;: {&quot;regex&quot;: &quot;staff|contractor&quot;} } ``` #### DSL Methods The DSL supports the following matching methods: * regexp(Pattern re, String value = null), regexp(String regexp, String value = null) Defines a regular expression matcher. If the value is not provided, a random one will be generated. * hexValue(String value = null) Defines a matcher that accepts hexidecimal values. If the value is not provided, a random hexidcimal value will be generated. * identifier(def value = null) Defines a matcher that accepts integer values. If the value is not provided, a random value will be generated. * ipAddress(String value = null) Defines a matcher that accepts IP addresses. If the value is not provided, a 127.0.0.1 will be used. * numeric(Number value = null) Defines a matcher that accepts any numerical values. If the value is not provided, a random integer will be used. * integer(def value = null) Defines a matcher that accepts any integer values. If the value is not provided, a random integer will be used. * real(def value = null) Defines a matcher that accepts any real numbers. If the value is not provided, a random double will be used. * timestamp(String pattern = null, def value = null) If pattern is not provided the ISO_DATETIME_FORMAT is used (&quot;yyyy-MM-dd&apos;T&apos;HH:mm:ss&quot;) . If the value is not provided, the current date and time is used. * time(String pattern = null, def value = null) If pattern is not provided the ISO_TIME_FORMAT is used (&quot;&apos;T&apos;HH:mm:ss&quot;) . If the value is not provided, the current date and time is used. * date(String pattern = null, def value = null) If pattern is not provided the ISO_DATE_FORMAT is used (&quot;yyyy-MM-dd&quot;) . If the value is not provided, the current date and time is used. * uuid(String value = null) Defines a matcher that accepts UUIDs. A random one will be generated if no value is provided. #### What if a field matches a matcher name in the DSL? When using the body DSL, if there is a field that matches a matcher name (e.g. a field named &apos;date&apos;) then you can do the following: ```groovy withBody { date = date() } ``` ### Ensuring all items in a list match an example (2.2.0+) Lots of the time you might not know the number of items that will be in a list, but you want to ensure that the list has a minimum or maximum size and that each item in the list matches a given example. You can do this with the `eachLike`, `minLike` and `maxLike` functions. | function | description | |----------|-------------| | `eachLike()` | Ensure that each item in the list matches the provided example | | `maxLike(integer max)` | Ensure that each item in the list matches the provided example and the list is no bigger than the provided max | | `minLike(integer min)` | Ensure that each item in the list matches the provided example and the list is no smaller than the provided min | For example: ```groovy withBody { users minLike(1) { id identifier name string(&apos;Fred&apos;) } } ``` This will ensure that the user list is never empty and that each user has an identifier that is a number and a name that is a string. __Version 3.2.4/2.4.6+__ You can specify the number of example items to generate in the array. The default is 1. ```groovy withBody { users minLike(1, 3) { id identifier name string(&apos;Fred&apos;) } } ``` This will create an example user list with 3 users. __Version 3.2.13/2.4.14+__ The each like matchers have been updated to work with primitive types. ```groovy withBody { permissions eachLike(3, &apos;GRANT&apos;) } ``` will generate the following JSON ```json { &quot;permissions&quot;: [&quot;GRANT&quot;, &quot;GRANT&quot;, &quot;GRANT&quot;] } ``` and matchers ```json { &quot;$.body.permissions&quot;: {&quot;match&quot;: &quot;type&quot;} } ``` and now you can even get more fancy ```groovy withBody { permissions eachLike(3, regexp(~/\w+/)) permissions2 minLike(2, 3, integer()) permissions3 maxLike(4, 3, ~/\d+/) } ``` ### Matching any key in a map (3.3.1/2.5.0+) The DSL has been extended for cases where the keys in a map are IDs. For an example of this, see [#313](https://github.com/DiUS/pact-jvm/issues/131). In this case you can use the `keyLike` method, which takes an example key as a parameter. For example: ```groovy withBody { example { one { keyLike &apos;001&apos;, &apos;value&apos; // key like an id mapped to a value } two { keyLike &apos;ABC001&apos;, regexp(&apos;\\w+&apos;) // key like an id mapped to a matcher } three { keyLike &apos;XYZ001&apos;, { // key like an id mapped to a closure id identifier() } } four { keyLike &apos;001XYZ&apos;, eachLike { // key like an id mapped to an array where each item is matched by the following id identifier() // example } } } } ``` For an example, have a look at [WildcardPactSpec](src/test/au/com/dius/pact/consumer/groovy/WildcardPactSpec.groovy). **NOTE:** The `keyLike` method adds a `*` to the matching path, so the matching definition will be applied to all keys of the map if there is not a more specific matcher defined for a particular key. Having more than one `keyLike` condition applied to a map will result in only one being applied when the pact is verified (probably the last). ## Changing the directory pact files are written to (2.1.9+) By default, pact files are written to `target/pacts`, but this can be overwritten with the `pact.rootDir` system property. This property needs to be set on the test JVM as most build tools will fork a new JVM to run the tests. For Gradle, add this to your build.gradle: ```groovy test { systemProperties[&apos;pact.rootDir&apos;] = &quot;$buildDir/pacts&quot; } ``` # Publishing your pact files to a pact broker If you use Gradle, you can use the [pact Gradle plugin](https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-gradle#publishing-pact-files-to-a-pact-broker) to publish your pact files. # Pact Specification V3 Version 3 of the pact specification changes the format of pact files in the following ways: * Query parameters are stored in a map form and are un-encoded (see [#66](https://github.com/DiUS/pact-jvm/issues/66) and [#97](https://github.com/DiUS/pact-jvm/issues/97) for information on what this can cause). * Introduces a new message pact format for testing interactions via a message queue. ## Generating V3 spec pact files (3.1.0+, 2.3.0+) To have your consumer tests generate V3 format pacts, you can pass an option into the `run` method. For example: ```groovy VerificationResult result = service.run(specificationVersion: PactSpecVersion.V3) { config -&gt; def client = new RESTClient(config.url()) def response = client.get(path: &apos;/&apos;) } ``` ## Consumer test for a message consumer For testing a consumer of messages from a message queue, the `PactMessageBuilder` class provides a DSL for defining your message expectations. It works in much the same way as the `PactBuilder` class for Request-Response interactions, but will generate a V3 format message pact file. The following steps demonstrate how to use it. ### Step 1 - define the message expectations Create a test that uses the `PactMessageBuilder` to define a message expectation, and then call `run`. This will invoke the given closure with a message for each one defined in the pact. ```groovy def eventStream = new PactMessageBuilder().call { serviceConsumer &apos;messageConsumer&apos; hasPactWith &apos;messageProducer&apos; given &apos;order with id 10000004 exists&apos; expectsToReceive &apos;an order confirmation message&apos; withMetaData(type: &apos;OrderConfirmed&apos;) // Can define any key-value pairs here withContent(contentType: &apos;application/json&apos;) { type &apos;OrderConfirmed&apos; audit { userCode &apos;messageService&apos; } origin &apos;message-service&apos; referenceId &apos;10000004-2&apos; timeSent: &apos;2015-07-22T10:14:28+00:00&apos; value { orderId &apos;10000004&apos; value &apos;10.000000&apos; fee &apos;10.00&apos; gst &apos;15.00&apos; } } } ``` ### Step 2 - call your message handler with the generated messages This example tests a message handler that gets messages from a Kafka topic. In this case the Pact message is wrapped as a Kafka `MessageAndMetadata`. ```groovy eventStream.run { Message message -&gt; messageHandler.handleMessage(new MessageAndMetadata(&apos;topic&apos;, 1, new kafka.message.Message(message.contentsAsBytes()), 0, null, valueDecoder)) } ``` ### Step 3 - validate that the message was handled correctly ```groovy def order = orderRepository.getOrder(&apos;10000004&apos;) assert order.status == &apos;confirmed&apos; assert order.value == 10.0 ``` ### Step 4 - Publish the pact file If the test was successful, a pact file would have been produced with the message from step 1.

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

0 downloads
Artifact pact-jvm-consumer-groovy_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 4
Dependencies slf4j-api, scala-library, pact-jvm-consumer_2.10, groovy-all,
There are maybe transitive dependencies!

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

# Pact junit runner ## Overview Library provides ability to play contract tests against a provider service in JUnit fashionable way. Supports: - Out-of-the-box convenient ways to load pacts - Easy way to change assertion strategy - **org.junit.BeforeClass**, **org.junit.AfterClass** and **org.junit.ClassRule** JUnit annotations, that will be run once - before/after whole contract test suite. - **org.junit.Before**, **org.junit.After** and **org.junit.Rule** JUnit annotations, that will be run before/after each test of an interaction. - **au.com.dius.pact.provider.junit.State** custom annotation - before each interaction that requires a state change, all methods annotated by `@State` with appropriate the state listed will be invoked. These methods must either take no parameters or a single Map parameter. ## Example of HTTP test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactFolder(&quot;pacts&quot;) // Point where to find pacts (See also section Pacts source in documentation) public class ContractTest { // NOTE: this is just an example of embedded service that listens to requests, you should start here real service @ClassRule //Rule will be applied once: before/after whole contract test suite public static final ClientDriverRule embeddedService = new ClientDriverRule(8332); @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Rest data // Mock dependent service responses // ... embeddedService.addExpectation( onRequestTo(&quot;/data&quot;), giveEmptyResponse() ); } @State(&quot;default&quot;, &quot;no-data&quot;) // Method will be run before testing interactions that require &quot;default&quot; or &quot;no-data&quot; state public void toDefaultState() { // Prepare service before interaction that require &quot;default&quot; state // ... System.out.println(&quot;Now service in default state&quot;); } @State(&quot;with-data&quot;) // Method will be run before testing interactions that require &quot;with-data&quot; state public void toStateWithData(Map data) { // Prepare service before interaction that require &quot;with-data&quot; state. The provider state data will be passed // in the data parameter // ... System.out.println(&quot;Now service in state using data &quot; + data); } @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new HttpTarget(8332); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) } ``` ## Example of AMQP Message test ```java @RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner @Provider(&quot;myAwesomeService&quot;) // Set up name of tested provider @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;) public class ConfirmationKafkaContractTest { @TestTarget // Annotation denotes Target that will be used for tests public final Target target = new AmqpTarget(); // Out-of-the-box implementation of Target (for more information take a look at Test Target section) @BeforeClass //Method will be run once: before whole contract test suite public static void setUpService() { //Run DB, create schema //Run service //... } @Before //Method will be run before each test of interaction public void before() { // Message data preparation // ... } @PactVerifyProvider(&apos;an order confirmation message&apos;) String verifyMessageForOrder() { Order order = new Order() order.setId(10000004) order.setPrice(BigDecimal.TEN) order.setUnits(15) def message = new ConfirmationKafkaMessageBuilder() .withOrder(order) .build() JsonOutput.toJson(message) } } ``` ## Provider state callback methods For the provider states in the pact being verified, you can define methods to be invoked to setup the correct state for each interaction. Just annotate a method with the `au.com.dius.pact.provider.junit.State` annotation and the method will be invoked before the interaction is verified. For example: ```java @State(&quot;SomeProviderState&quot;) // Must match the state description in the pact file public void someProviderState() { // Do what you need to set the correct state } ``` If there are parameters in the pact file, just add a Map parameter to the method to be able to access those parameters. ```java @State(&quot;SomeProviderState&quot;) public void someProviderState(Map&lt;String, Object&gt; providerStateParameters) { // Do what you need to set the correct state } ``` ### Provider state teardown methods [3.5.22+] If you need to tear down your provider state, you can annotate a method with the `@State` annotation with the action set to `StateChangeAction.TEARDOWN` and it will be invoked after the interaction is verified. ```java @State(&quot;SomeProviderState&quot;, action = StateChangeAction.TEARDOWN) public void someProviderStateCleanup() { // Do what you need to to teardown the state } ``` #### 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 this to work, just make your provider state method return a Map of the values. ### Using multiple classes for the state change methods If you have a large number of state change methods, you can split things up by moving them to other classes. There are two ways you can do this: #### Use interfaces You can put the state change methods on interfaces and then have your test class implement those interfaces. See [StateAnnotationsOnInterfaceTest](src/test/java/au/com/dius/pact/provider/junit/StateAnnotationsOnInterfaceTest.java) for an example. #### Specify the additional classes on the test target You can provide the additional classes to the test target with the `withStateHandler` or `setStateHandlers` methods. See [BooksPactProviderTest](pact-jvm-provider-spring/src/test/java/au/com/dius/pact/provider/spring/BooksPactProviderTest.java) for an example. ## Pact source The Pact runner will automatically collect pacts based on annotations on the test class. For this purpose there are 3 out-of-the-box options (files from a directory, files from a set of URLs or a pact broker) or you can easily add your own Pact source. If you need to load a single pact file from the file system, use the `PactUrl` with the URL set to the file path. **Note:** You can only define one source of pacts per test class. ### Download pacts from a pact-broker To use pacts from a Pact Broker, annotate the test class with `@PactBroker(host=&quot;host.of.pact.broker.com&quot;, port = &quot;80&quot;)`. From _version 3.2.2/2.4.3+_ you can also specify the protocol, which defaults to &quot;http&quot;. The pact broker will be queried for all pacts with the same name as the provider annotation. For example, test all pacts for the &quot;Activity Service&quot; in the pact broker: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### _Version 3.2.3/2.4.4+_ - Using Java System properties The pact broker loader was updated to allow system properties to be used for the hostname, port or protocol. The port was changed to a string to allow expressions to be set. To use a system property or environment variable, you can place the property name in `${}` expression de-markers: ```java @PactBroker(host=&quot;${pactbroker.hostname}&quot;, port = &quot;80&quot;) ``` You can provide a default value by separating the property name with a colon (`:`): ```java @PactBroker(host=&quot;${pactbroker.hostname:localhost}&quot;, port = &quot;80&quot;) ``` #### _Version 3.5.3+_ - More Java System properties The default values of the `@PactBroker` annotation now enable variable interpolation. The following keys may be managed through the environment * `pactbroker.host` * `pactbroker.port` * `pactbroker.protocol` * `pactbroker.tags` (comma separated) * `pactbroker.auth.username` (for basic auth) * `pactbroker.auth.password` (for basic auth) * `pactbroker.auth.token` (for bearer auth) * `pactbroker.consumers` (comma separated list to filter pacts by consumer; if not provided, will fetch all pacts for the provider) #### _Version 3.2.4/2.4.6+_ - Using tags with the pact broker The pact broker allows different versions to be tagged. To load all the pacts: ```java @PactBroker(host=&quot;pactbroker&quot;, port = &quot;80&quot;, tags = {&quot;latest&quot;, &quot;dev&quot;, &quot;prod&quot;}) ``` The default value for tags is `latest` which is not actually a tag but instead corresponds to the latest version ignoring the tags. If there are multiple consumers matching the name specified in the provider annotation then the latest pact for each of the consumers is loaded. For any other value the latest pact tagged with the specified tag is loaded. Specifying multiple tags is an OR operation. For example if you specify `tags = {&quot;dev&quot;, &quot;prod&quot;}` then both the latest pact file tagged with `dev` and the latest pact file taggged with `prod` is loaded. #### _Version 3.3.4/2.4.19+_ - Using basic auth with the with the pact broker You can use basic authentication with the `@PactBroker` annotation by setting the `authentication` value to a `@PactBrokerAuth` annotation. For example: ```java @PactBroker(host = &quot;${pactbroker.url:localhost}&quot;, port = &quot;1234&quot;, tags = {&quot;latest&quot;, &quot;prod&quot;, &quot;dev&quot;}, authentication = @PactBrokerAuth(username = &quot;test&quot;, password = &quot;test&quot;)) ``` Bearer tokens are also supported. For example: ```java @PactBroker(host = &quot;${pactbroker.url:localhost}&quot;, port = &quot;1234&quot;, tags = {&quot;latest&quot;, &quot;prod&quot;, &quot;dev&quot;}, authentication = @PactBrokerAuth(token = &quot;test&quot;)) ``` The `token`, `username` and `password` values also take Java system property expressions. Preemptive Authentication can be enabled by setting the `pact.pactbroker.httpclient.usePreemptiveAuthentication` Java system property to `true`. ### Pact Url To use pacts from urls annotate the test class with ```java @PactUrl(urls = {&quot;http://build.server/zoo_app-animal_service.json&quot;} ) ``` If you need to load a single pact file from the file system, you can use the `PactUrl` with the URL set to the file path. ### Pact folder To use pacts from a resource folder of the project annotate test class with ```java @PactFolder(&quot;subfolder/in/resource/directory&quot;) ``` ### Custom pacts source It&apos;s possible to use a custom Pact source. For this, implement interface `au.com.dius.pact.provider.junit.loader.PactLoader` and annotate the test class with `@PactSource(MyOwnPactLoader.class)`. **Note:** class `MyOwnPactLoader` must have a default empty constructor or a constructor with one argument of class `Class` which at runtime will be the test class so you can get custom annotations of test class. ### Filtering the interactions that are verified [version 3.5.3+] By default, the pact runner will verify all pacts for the given provider. You can filter the pacts and interactions by the following methods. #### Filtering by Consumer You can run only those pacts for a particular consumer by adding a `@Consumer` annotation to the test class. For example: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @Consumer(&quot;Activity Consumer&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` #### Filtering by Provider State You can filter the interactions that are executed by adding a `@PactFilter` annotation to your test class. The pact filter annotation will then only verify interactions that have a matching provider state. You can provide multiple states to match with. For example: ```java @RunWith(PactRunner.class) @Provider(&quot;Activity Service&quot;) @PactBroker(host = &quot;localhost&quot;, port = &quot;80&quot;) @PactFilter(&apos;Activity 100 exists in the database&apos;) public class PactJUnitTest { @TestTarget public final Target target = new HttpTarget(5050); } ``` You can also use regular expressions with the filter [version 3.5.3+]. For example: ```java @RunWith(PactRunner.class) @PactFilter(&apos;Activity \\d+ exists in the database&apos;) public class PactJUnitTest { } ``` ### Setting the test to not fail when no pacts are found [version 3.5.3+] By default the pact runner will fail the verification test if no pact files are found to verify. To change the failure into a warning, add a `@IgnoreNoPactsToVerify` annotation to your test class. #### Ignoring IO errors loading pact files [version 3.5.24+] You can also set the test to ignore any IO and parser exceptions when loading the pact files by setting the `ignoreIoErrors` attribute on the annotation to `&quot;true&quot;` or setting the JVM system property `pact.verification.ignoreIoErrors` to `true`. ** WARNING! Do not enable this on your CI server, as this could result in your build passing with no providers having been verified due to a configuration error. ** ## Test target The field in test class of type `au.com.dius.pact.provider.junit.target.Target` annotated with `au.com.dius.pact.provider.junit.target.TestTarget` will be used for actual Interaction execution and asserting of contract. **Note:** there must be exactly 1 such field, otherwise an `InitializationException` will be thrown. ### HttpTarget `au.com.dius.pact.provider.junit.target.HttpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as http request and assert response from service by matching rules from pact. _Version 3.2.2/2.4.3+_ you can also specify the protocol, defaults to &quot;http&quot;. ### AmqpTarget `au.com.dius.pact.provider.junit.target.AmqpTarget` - out-of-the-box implementation of `au.com.dius.pact.provider.junit.target.Target` that will play pacts as an AMQP message and assert response from service by matching rules from pact. **Note for Maven users:** If you use Maven to run your tests, you will have to make sure that the Maven Surefire plugin is at least version 2.22.1 uses an isolated classpath. For example, configure it by adding the following to your POM: ```xml &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.22.1&lt;/version&gt; &lt;configuration&gt; &lt;useSystemClassLoader&gt;false&lt;/useSystemClassLoader&gt; &lt;/configuration&gt; &lt;/plugin&gt; ``` #### Modifying the requests before they are sent [Version 3.2.3/2.4.5+] 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 HttpTarget supports request filters by annotating methods on the test class with `@TargetRequestFilter`. These methods must be public void methods that take a single HttpRequest parameter. For example: ```java @TargetRequestFilter public void exampleRequestFilter(HttpRequest request) { request.addHeader(&quot;Authorization&quot;, &quot;OAUTH hdsagasjhgdjashgdah...&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! #### 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. ### Custom Test Target It&apos;s possible to use custom `Target`, for that interface `Target` should be implemented and this class can be used instead of `HttpTarget`. # Verification Reports [versions 3.2.7/2.4.9+] The default test behaviour is to display the verification being done to the console, and pass or fail the test via the normal JUnit mechanism. From versions 3.2.7/2.4.9+, additional reports can be generated from the tests. ## Enabling additional reports via annotations on the test classes A `@VerificationReports` annotation can be added to any pact test class which will control the verification output. The annotation takes a list report types and an optional report directory (defaults to &quot;target/pact/reports&quot;). The currently supported report types are `console`, `markdown` and `json`. For example: ```java @VerificationReports({&quot;console&quot;, &quot;markdown&quot;}) public class MyPactTest { ``` will enable the markdown report in addition to the normal console output. And, ```java @VerificationReports(value = {&quot;markdown&quot;}, reportDir = &quot;/myreports&quot;) public class MyPactTest { ``` will disable the normal console output and write the markdown reports to &quot;/myreports&quot;. ## Enabling additional reports via Java system properties or environment variables The additional reports can also be enabled with Java System properties or environment variables. The following two properties have been introduced: `pact.verification.reports` and `pact.verification.reportDir`. `pact.verification.reports` is the comma separated list of report types to enable (e.g. `console,json,markdown`). `pact.verification.reportDir` is the directory to write reports to (defaults to &quot;target/pact/reports&quot;). ## Additional Reports The following report types are available in addition to console output (`console`, which is enabled by default): `markdown`, `json`. You can also provide a fully qualified classname as report so custom reports are also supported. This class must implement `au.com.dius.pact.provider.reporters.VerifierReporter` interface in order to be correct custom implementation of a report. # 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. You need to set the version of the provider that is verified using the `pact.provider.version` system property. To enable publishing of results, set the property `pact.verifier.publishResults` to `true` [version 3.5.18+].

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

2 downloads
Artifact pact-jvm-provider-junit_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 10
Dependencies pact-jvm-support, pact-jvm-provider_2.12, fluent-hc, httpclient, junit, commons-lang3, jool, slf4j-api, guava-retrying, mail,
There are maybe transitive dependencies!



Page 274 from 275 (items total 2748)


© 2015 - 2024 Weber Informatics LLC | Privacy Policy