Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malkusch committed Nov 6, 2023
1 parent 399829d commit d1f8d2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/java/de/malkusch/km200/KM200Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ public void updateShouldFailOnBadResponse(Fault fault) throws Exception {
assertThrows(IOException.class, () -> km200.update("/update-bad-response", 42));
}

@ParameterizedTest
@ValueSource(strings = { "", "\r\n", "\r\n\r\n", "bad", "dGVzdAo=" })
public void queryShouldFailOnBadBody(String body) throws Exception {
stubFor(get("/bad-body").willReturn(ok(body)));
var km200 = new KM200(URI, TIMEOUT, GATEWAY_PASSWORD, PRIVATE_PASSWORD, SALT);

assertThrows(KM200Exception.class, () -> km200.queryString("/bad-body"));
}

@Test
public void queryShouldTimeout() throws Exception {
stubFor(get("/timeout").willReturn(ok(loadBody("gateway.DateTime")).withFixedDelay(100)));
Expand Down

0 comments on commit d1f8d2a

Please sign in to comment.