Skip to content

Commit

Permalink
Add Jetty 12 supporting documentation (#271)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored Apr 2, 2024
1 parent a499abc commit d39ab4a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions _docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ At the moment, we provide the following quick starts for beginners:

- [API Mocking with Java and JUnit 4](../quickstart/java-junit)
- [Downloading and Installing WireMock](../download-and-installation)
- [Using WireMock with Jetty 12](../jetty-12)

<!-- TODO: Add standalone in Docker -->

Expand Down
62 changes: 62 additions & 0 deletions _docs/jetty-12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
layout: docs
title: "Using WireMock with Jetty 12"
meta_title: Using WireMock with Jetty 12 | WireMock
description: WireMock ships with Jetty 11 by default but fully supports Jetty 12 as well.
---

WireMock ships with Jetty 11 by default but fully supports Jetty 12 as well with a new module `wiremock-jetty12`. In this tutorial we are going to see how Wiremock could be configured to use Jetty 12.

## Prerequisites

- Java 17
- Maven or Gradle, recent versions
- A Java project, based on Maven or Gradle

## Add WireMock Dependency to your project

{% codetabs %}

{% codetab Maven %}

```xml
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-jetty12</artifactId>
<version>{{ site.wiremock_version }}</version>
<scope>test</scope>
</dependency>
```

{% endcodetab %}

{% codetab Gradle Groovy %}

```groovy
testImplementation "org.wiremock:wiremock-jetty12:{{ site.wiremock_version }}"
```

{% endcodetab %}

{% endcodetab %}

## Limitations

There are few limitations that usage of Jetty 12 is imposing with respect to stubbing behavior.

- status message will not be returned to the client even if set by the stub explicitly
```java
stubFor(get("/my/resource")
.willReturn(status(400)
.withStatusMessage("ERROR")));

URI uri = URI.create(wireMockRule.url("/my/resource"));
HttpURLConnection connection = (HttpURLConnection) uri.toURL ().openConnection ();
connection.setRequestMethod ("GET");

assertThat(connection.getResponseCode()).isEqualTo(400);
assertThat(connection.getResponseMessage()).isEqualTo("Bad Request"); /* the status message is not returned */
```
- when using multipart form data, the body is not decoded into plain text in case of `base64` (or other encodings)

- serving files from configured file locations always ends up with redirect when folder (without trailing `/`) is requested

0 comments on commit d39ab4a

Please sign in to comment.