Skip to content

Commit

Permalink
Add Spring WebFlux example
Browse files Browse the repository at this point in the history
  • Loading branch information
paweusz committed Sep 17, 2020
1 parent 7841232 commit 87cf316
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions provider/spring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Supports:

- MockMvc debugger output

- Spring WebFlux Controllers and RouterFunctions

- 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,
Expand Down Expand Up @@ -75,6 +77,31 @@ is set with the version of your provider.
}
```

## Example of Spring WebFlux 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 AwesomeRouterContractTest {

//Create a new instance of the WebFluxTarget and annotate it as the TestTarget for PactRunner
@TestTarget
public WebFluxTarget target = new WebFluxTarget();

//Create instance of your RouterFunction
public RouterFunction<ServerResponse> routerFunction
= new AwesomeRouter(new AwesomeHandler()).routes();

//Configure the WebFluxTarget with routerFunction
@Before
public void setup() {
target.setRouterFunction(routerFunction);
}

}
```

## Using Spring runners

You can use `SpringRestPactRunner` or `SpringMessagePactRunner` instead of the default Pact runner to use the Spring test annotations. This will
Expand Down

0 comments on commit 87cf316

Please sign in to comment.