Skip to content

Commit

Permalink
Merge pull request #1209 from paweusz/docs/webflux-support
Browse files Browse the repository at this point in the history
Add Spring WebFlux example
  • Loading branch information
uglyog authored Sep 19, 2020
2 parents 0f76d71 + 87cf316 commit d802e09
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 d802e09

Please sign in to comment.