Download JAR files tagged by port with all dependencies
jtidy from group net.sf.jtidy (version r938)
JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be
used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the
document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML.
Artifact jtidy
Group net.sf.jtidy
Version r938
Last update 20. July 2010
Organization sourceforge
URL http://jtidy.sourceforge.net
License Java HTML Tidy License
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
Group net.sf.jtidy
Version r938
Last update 20. July 2010
Organization sourceforge
URL http://jtidy.sourceforge.net
License Java HTML Tidy License
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
restConnector-2.0 from group io.openliberty.features (version 24.0.0.10)
A secure, REST administrative connector that can be used locally or remotely using any Java developer kit. This connector enables remote access from a Java client or directly through an HTTPS call. The administrator and reader roles protect the connector. The connector requires TLS to keep the communication confidential. The HTTPS port used by the connector is defined through the default HTTP endpoint. This feature supersedes the restConnector-1.0 feature. It enables the REST handler configuration APIs. When this feature is combined with features supporting configuration validation, the corresponding REST handler validation APIs are enabled.
Group: io.openliberty.features Artifact: restConnector-2.0
Show all versions
Show all versions
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact restConnector-2.0
Group io.openliberty.features
Version 24.0.0.10
Last update 26. September 2024
Organization not specified
URL https://openliberty.io/
License Eclipse Public License 2.0
Dependencies amount 5
Dependencies com.ibm.websphere.appserver.restHandler-1.0, io.openliberty.restConnector2.0.internal.ee-6.0, servlet-3.1, com.ibm.websphere.appserver.api.restConnector, com.ibm.websphere.appserver.spi.restHandler,
There are maybe transitive dependencies!
Group io.openliberty.features
Version 24.0.0.10
Last update 26. September 2024
Organization not specified
URL https://openliberty.io/
License Eclipse Public License 2.0
Dependencies amount 5
Dependencies com.ibm.websphere.appserver.restHandler-1.0, io.openliberty.restConnector2.0.internal.ee-6.0, servlet-3.1, com.ibm.websphere.appserver.api.restConnector, com.ibm.websphere.appserver.spi.restHandler,
There are maybe transitive dependencies!
gwt-commons-lang3 from group de.knightsoft-net (version 3.17.0-0)
Apache Commons Lang, a package of Java utility classes for the
classes that are in java.lang's hierarchy, or are considered to be so
standard as to justify existence in java.lang.
This is a port for GWT, which enables program, to use Apache Commons Lang
also in the frontend compiled by the gwt compiler to java-script.
The code is tested using the latest revision of the JDK for supported
LTS releases: 8, 11, 17 and 21 currently.
See https://github.com/apache/commons-lang/blob/master/.github/workflows/maven.yml
Please ensure your build environment is up-to-date and kindly report any build issues.
Group: de.knightsoft-net Artifact: gwt-commons-lang3
Show all versions Show documentation Show source
Show all versions Show documentation Show source
5 downloads
Artifact gwt-commons-lang3
Group de.knightsoft-net
Version 3.17.0-0
Last update 18. September 2024
Organization not specified
URL https://gitlab.com/ManfredTremmel/gwt-commons-lang3
License Apache License, Version 2.0
Dependencies amount 3
Dependencies gwt-core, gwt-mt-jre-emulation, gwt-user,
There are maybe transitive dependencies!
Group de.knightsoft-net
Version 3.17.0-0
Last update 18. September 2024
Organization not specified
URL https://gitlab.com/ManfredTremmel/gwt-commons-lang3
License Apache License, Version 2.0
Dependencies amount 3
Dependencies gwt-core, gwt-mt-jre-emulation, gwt-user,
There are maybe transitive dependencies!
ziggurat from group org.cicirello (version 1.1.0)
Java implementation of the Ziggurat algorithm
for generating Gaussian distributed pseudorandom numbers.
The Ziggurat algorithm is significantly faster than the
more commonly encountered Polar method, and
has some other desirable statistical properties. The
ZigguratGaussian class is a Java port of the GNU Scientific
Library's C implementation (Voss, 2005) of the Ziggurat method.
In porting to Java, we have made several optimizations, the details of
which can be found in the source code comments, which highlights any
differences between this Java implementation and the
C implementation on which it is based. This package also includes
an implementation of the Polar Method, included to enable comparing
speed advantage of the Ziggurat algorithm.
Artifact ziggurat
Group org.cicirello
Version 1.1.0
Last update 31. May 2024
Organization Cicirello.Org
URL https://github.com/cicirello/ZigguratGaussian
License GPL-3.0-or-later
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
Group org.cicirello
Version 1.1.0
Last update 31. May 2024
Organization Cicirello.Org
URL https://github.com/cicirello/ZigguratGaussian
License GPL-3.0-or-later
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
sshapi-ganymed from group com.sshtools (version 1.1.2)
Ganymed SSH-2 for Java is a library which implements the SSH-2 protocol in pure Java (tested on J2SE 1.4.2 and 5.0). It allows one to connect to SSH servers from within Java programs. It supports SSH sessions (remote command execution and shell access), local and remote port forwarding, local stream forwarding, X11 forwarding, SCP and SFTP. There are no dependencies on any JCE provider, as all crypto functionality is included.
Originally, Ganymed SSH-2 for Java was developed for the Ganymed replication project at ETH Zurich (Switzerland).
Downloads and more information about JSch may be found at http://www.cleondris.ch/opensource/ssh2/.
This library is the provider bridge for SSHAPI.
0 downloads
Artifact sshapi-ganymed
Group com.sshtools
Version 1.1.2
Last update 16. August 2018
Organization not specified
URL ${scmWebRoot}/${project.artifactId}/
License not specified
Dependencies amount 2
Dependencies sshapi-core, ganymed-ssh2,
There are maybe transitive dependencies!
Group com.sshtools
Version 1.1.2
Last update 16. August 2018
Organization not specified
URL ${scmWebRoot}/${project.artifactId}/
License not specified
Dependencies amount 2
Dependencies sshapi-core, ganymed-ssh2,
There are maybe transitive dependencies!
degen from group com.peterlavalle (version 1.3.0)
A Maven Mojo to download and "degenerate" non-maven projects into sources and binaries
This MOJO is supposed to scrape and "de-generate" a zip file containing jars into a project's generated-sources folder, skipping items provided in the `src/` folder.
It is intended to "mavenize-with-changes" an existing project and allow the user (of the Mojo) to replace classes which they do not have the ability/desire to recompile without setting up a full build.
It can also be used to import non-maven projects by not changing anything.
The itch I wanted to scratch was mostly to port libGDX to Maven, while replacing the native methods on Matrix4, without rebuilding the whole project.
In essence - it's an alternative to patching someone else's project.
Artifact degen
Group com.peterlavalle
Version 1.3.0
Last update 28. January 2013
Organization not specified
URL https://github.com/g-pechorin/degen
License GNU AFFERO GENERAL PUBLIC LICENSE
Dependencies amount 3
Dependencies maven-plugin-api, maven-project, guava,
There are maybe transitive dependencies!
Group com.peterlavalle
Version 1.3.0
Last update 28. January 2013
Organization not specified
URL https://github.com/g-pechorin/degen
License GNU AFFERO GENERAL PUBLIC LICENSE
Dependencies amount 3
Dependencies maven-plugin-api, maven-project, guava,
There are maybe transitive dependencies!
pragautox10 from group com.pragmaticautomation (version 1.0)
Group: com.pragmaticautomation Artifact: pragautox10
There is no JAR file uploaded. A download is not possible! Please choose another version.
0 downloads
Artifact pragautox10
Group com.pragmaticautomation
Version 1.0
Last update 07. October 2008
Organization not specified
URL Not specified
License not specified
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
Group com.pragmaticautomation
Version 1.0
Last update 07. October 2008
Organization not specified
URL Not specified
License not specified
Dependencies amount 0
Dependencies No dependencies
There are maybe transitive dependencies!
pact-jvm-provider-spring_2.12 from group au.com.dius (version 3.6.15)
# Pact Spring/JUnit runner
## Overview
Library provides ability to play contract tests against a provider using Spring & JUnit.
This library is based on and references the JUnit package, so see the [Pact JUnit 4](../pact-jvm-provider-junit) or [Pact JUnit 5](../pact-jvm-provider-junit5) providers for more details regarding configuration using JUnit.
Supports:
- Standard ways to load pacts from folders and broker
- Easy way to change assertion strategy
- Spring Test MockMVC Controllers and ControllerAdvice using MockMvc standalone setup.
- MockMvc debugger output
- Multiple @State runs to test a particular Provider State multiple times
- **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.
**NOTE:** For publishing provider verification results to a pact broker, make sure the Java system property `pact.provider.version`
is set with the version of your provider.
## Example of MockMvc test
```java
@RunWith(RestPactRunner.class) // Custom pact runner, child of PactRunner which runs only REST tests
@Provider("myAwesomeService") // Set up name of tested provider
@PactFolder("pacts") // Point where to find pacts (See also section Pacts source in documentation)
public class ContractTest {
//Create an instance of your controller. We cannot autowire this as we're not using (and don't want to use) a Spring test runner.
@InjectMocks
private AwesomeController awesomeController = new AwesomeController();
//Mock your service logic class. We'll use this to create scenarios for respective provider states.
@Mock
private AwesomeBusinessLogic awesomeBusinessLogic;
//Create an instance of your controller advice (if you have one). This will be passed to the MockMvcTarget constructor to be wired up with MockMvc.
@InjectMocks
private AwesomeControllerAdvice awesomeControllerAdvice = new AwesomeControllerAdvice();
//Create a new instance of the MockMvcTarget and annotate it as the TestTarget for PactRunner
@TestTarget
public final MockMvcTarget target = new MockMvcTarget();
@Before //Method will be run before each test of interaction
public void before() {
//initialize your mocks using your mocking framework
MockitoAnnotations.initMocks(this);
//configure the MockMvcTarget with your controller and controller advice
target.setControllers(awesomeController);
target.setControllerAdvice(awesomeControllerAdvice);
}
@State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state
public void toDefaultState() {
target.setRunTimes(3); //let's loop through this state a few times for a 3 data variants
when(awesomeBusinessLogic.getById(any(UUID.class)))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.ONE))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.TWO))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.THREE));
}
@State("error-case")
public void SingleUploadExistsState_Success() {
target.setRunTimes(1); //tell the runner to only loop one time for this state
//you might want to throw exceptions to be picked off by your controller advice
when(awesomeBusinessLogic.getById(any(UUID.class)))
.then(i -> { throw new NotCoolException(i.getArgumentAt(0, UUID.class).toString()); });
}
}
```
## Using a Spring runner (version 3.5.7+)
You can use `SpringRestPactRunner` instead of the default Pact runner to use the Spring test annotations. This will
allow you to inject or mock spring beans.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("pricing")
@PactBroker(protocol = "https", host = "${pactBrokerHost}", port = "443",
authentication = @PactBrokerAuth(username = "${pactBrokerUser}", password = "${pactBrokerPassword}"))
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class PricingServiceProviderPactTest {
@MockBean
private ProductClient productClient; // This will replace the bean with a mock in the application context
@TestTarget
@SuppressWarnings(value = "VisibilityModifier")
public final Target target = new HttpTarget(8091);
@State("Product X010000021 exists")
public void setupProductX010000021() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X010000021");
when(productClient.fetch((Set<String>) argThat(contains("X010000021")), any())).thenReturn(product);
}
@State("the product code X00001 can be priced")
public void theProductCodeX00001CanBePriced() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X00001");
when(productClient.find((Set<String>) argThat(contains("X00001")), any())).thenReturn(product);
}
}
```
### Using Spring Context Properties (version 3.5.14+)
From version 3.5.14 onwards, the SpringRestPactRunner will look up any annotation expressions (like `${pactBrokerHost}`)
above) from the Spring context. For Springboot, this will allow you to define the properties in the application test properties.
For instance, if you create the following `application.yml` in the test resources:
```yaml
pactbroker:
host: "your.broker.local"
port: "443"
protocol: "https"
auth:
username: "<your broker username>"
password: "<your broker password>"
```
Then you can use the defaults on the `@PactBroker` annotation.
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker(
authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}")
)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
```
### Using a random port with a Springboot test (version 3.5.14+)
If you use a random port in a springboot test (by setting `SpringBootTest.WebEnvironment.RANDOM_PORT`), you can use the
`SpringBootHttpTarget` which will get the application port from the spring application context.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
@TestTarget
public final Target target = new SpringBootHttpTarget();
}
```
Group: au.com.dius Artifact: pact-jvm-provider-spring_2.12
Show all versions Show documentation Show source
Show all versions Show documentation Show source
1 downloads
Artifact pact-jvm-provider-spring_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 5
Dependencies pact-jvm-provider-junit_2.12, spring-boot-starter-test, spring-webmvc, javax.servlet-api, jackson-datatype-joda,
There are maybe transitive dependencies!
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 5
Dependencies pact-jvm-provider-junit_2.12, spring-boot-starter-test, spring-webmvc, javax.servlet-api, jackson-datatype-joda,
There are maybe transitive dependencies!
pact-jvm-provider-spring_2.11 from group au.com.dius (version 3.5.24)
# Pact Spring/JUnit runner
## Overview
Library provides ability to play contract tests against a provider using Spring & JUnit.
This library is based on and references the JUnit package, so see [junit provider support](pact-jvm-provider-junit) for more details regarding configuration using JUnit.
Supports:
- Standard ways to load pacts from folders and broker
- Easy way to change assertion strategy
- Spring Test MockMVC Controllers and ControllerAdvice using MockMvc standalone setup.
- MockMvc debugger output
- Multiple @State runs to test a particular Provider State multiple times
- **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.
**NOTE:** For publishing provider verification results to a pact broker, make sure the Java system property `pact.provider.version`
is set with the version of your provider.
## Example of MockMvc test
```java
@RunWith(RestPactRunner.class) // Custom pact runner, child of PactRunner which runs only REST tests
@Provider("myAwesomeService") // Set up name of tested provider
@PactFolder("pacts") // Point where to find pacts (See also section Pacts source in documentation)
public class ContractTest {
//Create an instance of your controller. We cannot autowire this as we're not using (and don't want to use) a Spring test runner.
@InjectMocks
private AwesomeController awesomeController = new AwesomeController();
//Mock your service logic class. We'll use this to create scenarios for respective provider states.
@Mock
private AwesomeBusinessLogic awesomeBusinessLogic;
//Create an instance of your controller advice (if you have one). This will be passed to the MockMvcTarget constructor to be wired up with MockMvc.
@InjectMocks
private AwesomeControllerAdvice awesomeControllerAdvice = new AwesomeControllerAdvice();
//Create a new instance of the MockMvcTarget and annotate it as the TestTarget for PactRunner
@TestTarget
public final MockMvcTarget target = new MockMvcTarget();
@Before //Method will be run before each test of interaction
public void before() {
//initialize your mocks using your mocking framework
MockitoAnnotations.initMocks(this);
//configure the MockMvcTarget with your controller and controller advice
target.setControllers(awesomeController);
target.setControllerAdvice(awesomeControllerAdvice);
}
@State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state
public void toDefaultState() {
target.setRunTimes(3); //let's loop through this state a few times for a 3 data variants
when(awesomeBusinessLogic.getById(any(UUID.class)))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.ONE))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.TWO))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.THREE));
}
@State("error-case")
public void SingleUploadExistsState_Success() {
target.setRunTimes(1); //tell the runner to only loop one time for this state
//you might want to throw exceptions to be picked off by your controller advice
when(awesomeBusinessLogic.getById(any(UUID.class)))
.then(i -> { throw new NotCoolException(i.getArgumentAt(0, UUID.class).toString()); });
}
}
```
## Using a Spring runner (version 3.5.7+)
You can use `SpringRestPactRunner` instead of the default Pact runner to use the Spring test annotations. This will
allow you to inject or mock spring beans.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("pricing")
@PactBroker(protocol = "https", host = "${pactBrokerHost}", port = "443",
authentication = @PactBrokerAuth(username = "${pactBrokerUser}", password = "${pactBrokerPassword}"))
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class PricingServiceProviderPactTest {
@MockBean
private ProductClient productClient; // This will replace the bean with a mock in the application context
@TestTarget
@SuppressWarnings(value = "VisibilityModifier")
public final Target target = new HttpTarget(8091);
@State("Product X010000021 exists")
public void setupProductX010000021() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X010000021");
when(productClient.fetch((Set<String>) argThat(contains("X010000021")), any())).thenReturn(product);
}
@State("the product code X00001 can be priced")
public void theProductCodeX00001CanBePriced() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X00001");
when(productClient.find((Set<String>) argThat(contains("X00001")), any())).thenReturn(product);
}
}
```
### Using Spring Context Properties (version 3.5.14+)
From version 3.5.14 onwards, the SpringRestPactRunner will look up any annotation expressions (like `${pactBrokerHost}`)
above) from the Spring context. For Springboot, this will allow you to define the properties in the application test properties.
For instance, if you create the following `application.yml` in the test resources:
```yaml
pactbroker:
host: "your.broker.local"
port: "443"
protocol: "https"
auth:
username: "<your broker username>"
password: "<your broker password>"
```
Then you can use the defaults on the `@PactBroker` annotation.
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker(
authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}")
)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
```
### Using a random port with a Springboot test (version 3.5.14+)
If you use a random port in a springboot test (by setting `SpringBootTest.WebEnvironment.RANDOM_PORT`), you can use the
`SpringBootHttpTarget` which will get the application port from the spring application context.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
@TestTarget
public final Target target = new SpringBootHttpTarget();
}
```
Group: au.com.dius Artifact: pact-jvm-provider-spring_2.11
Show all versions Show documentation Show source
Show all versions Show documentation Show source
2 downloads
Artifact pact-jvm-provider-spring_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 13
Dependencies kotlin-stdlib-jdk8, kotlin-reflect, slf4j-api, groovy-all, kotlin-logging, scala-library, scala-logging_2.11, pact-jvm-provider-junit_2.11, spring-boot-starter-test, spring-web, spring-webmvc, javax.servlet-api, jackson-datatype-joda,
There are maybe transitive dependencies!
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 13
Dependencies kotlin-stdlib-jdk8, kotlin-reflect, slf4j-api, groovy-all, kotlin-logging, scala-library, scala-logging_2.11, pact-jvm-provider-junit_2.11, spring-boot-starter-test, spring-web, spring-webmvc, javax.servlet-api, jackson-datatype-joda,
There are maybe transitive dependencies!
pact-jvm-provider-spring from group au.com.dius (version 4.0.10)
# Pact Spring/JUnit runner
## Overview
Library provides ability to play contract tests against a provider using Spring & JUnit.
This library is based on and references the JUnit package, so see the [Pact JUnit 4](../pact-jvm-provider-junit) or [Pact JUnit 5](../pact-jvm-provider-junit5) providers for more details regarding configuration using JUnit.
Supports:
- Standard ways to load pacts from folders and broker
- Easy way to change assertion strategy
- Spring Test MockMVC Controllers and ControllerAdvice using MockMvc standalone setup.
- MockMvc debugger output
- Multiple @State runs to test a particular Provider State multiple times
- **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.
**NOTE:** For publishing provider verification results to a pact broker, make sure the Java system property `pact.provider.version`
is set with the version of your provider.
## Example of MockMvc test
```java
@RunWith(RestPactRunner.class) // Custom pact runner, child of PactRunner which runs only REST tests
@Provider("myAwesomeService") // Set up name of tested provider
@PactFolder("pacts") // Point where to find pacts (See also section Pacts source in documentation)
public class ContractTest {
//Create an instance of your controller. We cannot autowire this as we're not using (and don't want to use) a Spring test runner.
@InjectMocks
private AwesomeController awesomeController = new AwesomeController();
//Mock your service logic class. We'll use this to create scenarios for respective provider states.
@Mock
private AwesomeBusinessLogic awesomeBusinessLogic;
//Create an instance of your controller advice (if you have one). This will be passed to the MockMvcTarget constructor to be wired up with MockMvc.
@InjectMocks
private AwesomeControllerAdvice awesomeControllerAdvice = new AwesomeControllerAdvice();
//Create a new instance of the MockMvcTarget and annotate it as the TestTarget for PactRunner
@TestTarget
public final MockMvcTarget target = new MockMvcTarget();
@Before //Method will be run before each test of interaction
public void before() {
//initialize your mocks using your mocking framework
MockitoAnnotations.initMocks(this);
//configure the MockMvcTarget with your controller and controller advice
target.setControllers(awesomeController);
target.setControllerAdvice(awesomeControllerAdvice);
}
@State("default", "no-data") // Method will be run before testing interactions that require "default" or "no-data" state
public void toDefaultState() {
target.setRunTimes(3); //let's loop through this state a few times for a 3 data variants
when(awesomeBusinessLogic.getById(any(UUID.class)))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.ONE))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.TWO))
.thenReturn(myTestHelper.generateRandomReturnData(UUID.randomUUID(), ExampleEnum.THREE));
}
@State("error-case")
public void SingleUploadExistsState_Success() {
target.setRunTimes(1); //tell the runner to only loop one time for this state
//you might want to throw exceptions to be picked off by your controller advice
when(awesomeBusinessLogic.getById(any(UUID.class)))
.then(i -> { throw new NotCoolException(i.getArgumentAt(0, UUID.class).toString()); });
}
}
```
## Using Spring runners
You can use `SpringRestPactRunner` or `SpringMessagePactRunner` instead of the default Pact runner to use the Spring test annotations. This will
allow you to inject or mock spring beans. `SpringRestPactRunner` is for restful webapps and `SpringMessagePactRunner` is
for async message tests.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("pricing")
@PactBroker(protocol = "https", host = "${pactBrokerHost}", port = "443",
authentication = @PactBrokerAuth(username = "${pactBrokerUser}", password = "${pactBrokerPassword}"))
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class PricingServiceProviderPactTest {
@MockBean
private ProductClient productClient; // This will replace the bean with a mock in the application context
@TestTarget
@SuppressWarnings(value = "VisibilityModifier")
public final Target target = new HttpTarget(8091);
@State("Product X010000021 exists")
public void setupProductX010000021() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X010000021");
when(productClient.fetch((Set<String>) argThat(contains("X010000021")), any())).thenReturn(product);
}
@State("the product code X00001 can be priced")
public void theProductCodeX00001CanBePriced() throws IOException {
reset(productClient);
ProductBuilder product = new ProductBuilder()
.withProductCode("X00001");
when(productClient.find((Set<String>) argThat(contains("X00001")), any())).thenReturn(product);
}
}
```
### Using Spring Context Properties
The SpringRestPactRunner will look up any annotation expressions (like `${pactBrokerHost}`)
above) from the Spring context. For Springboot, this will allow you to define the properties in the application test properties.
For instance, if you create the following `application.yml` in the test resources:
```yaml
pactbroker:
host: "your.broker.local"
port: "443"
protocol: "https"
auth:
username: "<your broker username>"
password: "<your broker password>"
```
Then you can use the defaults on the `@PactBroker` annotation.
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker(
authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}")
)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
```
### Using a random port with a Springboot test
If you use a random port in a springboot test (by setting `SpringBootTest.WebEnvironment.RANDOM_PORT`), you need to set it to the `TestTarget`. How this works is different for JUnit4 and JUnit5.
#### JUnit4
You can use the
`SpringBootHttpTarget` which will get the application port from the spring application context.
For example:
```java
@RunWith(SpringRestPactRunner.class)
@Provider("My Service")
@PactBroker
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
@TestTarget
public final Target target = new SpringBootHttpTarget();
}
```
#### JUnit5
You actually don't need to dependend on `pact-jvm-provider-spring` for this. It's sufficient to depend on `pact-jvm-provider-junit5`.
You can set the port to the `HttpTestTarget` object in the before method.
```java
@Provider("My Service")
@PactBroker
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PactVerificationTest {
@LocalServerPort
private int port;
@BeforeEach
void before(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", port));
}
}
```
Group: au.com.dius Artifact: pact-jvm-provider-spring
Show all versions Show documentation Show source
Show all versions Show documentation Show source
0 downloads
Artifact pact-jvm-provider-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 5
Dependencies spring-boot-starter-test, spring-webmvc, javax.servlet-api, jackson-datatype-joda, pact-jvm-provider-junit,
There are maybe transitive dependencies!
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 5
Dependencies spring-boot-starter-test, spring-webmvc, javax.servlet-api, jackson-datatype-joda, pact-jvm-provider-junit,
There are maybe transitive dependencies!
Page 90 from 3 (items total 936)