Skip to content

Commit

Permalink
Upgrade WireMock to 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Dec 9, 2023
1 parent 189b2b8 commit ee0c5df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<jackson.version>2.16.0</jackson.version>
<junit.jupiter.version>5.10.1</junit.jupiter.version>
<slf4j.version>2.0.9</slf4j.version>
<wiremock-jre8.version>2.35.1</wiremock-jre8.version>
<wiremock.version>3.3.1</wiremock.version>

<!-- Plugin versions -->
<formatter.plugin.version>2.18.0</formatter.plugin.version>
Expand Down Expand Up @@ -111,9 +111,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>${wiremock-jre8.version}</version>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

Expand Down Expand Up @@ -139,7 +138,7 @@ protected byte[] getStubbedResponse(String resourceName) throws IOException {
throw new IllegalStateException("Resource: " + resourceName + " could not be found");
}

return IOUtils.toByteArray(resourceAsStream);
return resourceAsStream.readAllBytes();
}

protected static final class QueryParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;

public class ZulipCommonsHttpClientTest extends ZulipApiTestBase {
Expand Down Expand Up @@ -174,18 +173,19 @@ void start() {
OutputStream outputStream = accept.getOutputStream();

if (secure && !proxyAuthHeaderSent) {
IOUtils.write("HTTP/1.1 407 Proxy Authentication Required\r\n", outputStream,
StandardCharsets.UTF_8.name());
IOUtils.write("Proxy-Authenticate: Basic\r\n", outputStream, StandardCharsets.UTF_8.name());
outputStream
.write("HTTP/1.1 407 Proxy Authentication Required\r\n".getBytes(StandardCharsets.UTF_8));
outputStream.write("Proxy-Authenticate: Basic\r\n".getBytes(StandardCharsets.UTF_8));
proxyAuthHeaderSent = true;
continue;
}

IOUtils.write("HTTP/1.1 200 OK\r\n", outputStream, StandardCharsets.UTF_8.name());
IOUtils.write("Content-Length: " + response.length + "\r\n", outputStream,
StandardCharsets.UTF_8.name());
IOUtils.write("Content-Type: Application/json\r\n\r\n", outputStream, StandardCharsets.UTF_8.name());
IOUtils.write(new String(response), outputStream, StandardCharsets.UTF_8.name());
outputStream.write("HTTP/1.1 200 OK\r\n".getBytes(StandardCharsets.UTF_8));
outputStream.write("Content-Length: ".getBytes(StandardCharsets.UTF_8));
outputStream.write(
String.format("Content-Length: %d\r\n", response.length).getBytes(StandardCharsets.UTF_8));
outputStream.write("Content-Type: Application/json\r\n\r\n".getBytes(StandardCharsets.UTF_8));
outputStream.write(new String(response).getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
return;
}
Expand Down

0 comments on commit ee0c5df

Please sign in to comment.