Review all unit tests

- Replace deprecated org.junit.Assert.assertThat by org.hamcrest.MatcherAssert.assertThat
- Other minor checkstyle fixes
pull/98/head
Richard Körber 2020-10-24 18:05:06 +02:00
parent f0c50f43d2
commit 2cff3a5c90
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
47 changed files with 117 additions and 112 deletions

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -41,8 +41,8 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class AccountBuilderTest { public class AccountBuilderTest {
private URL resourceUrl = url("http://example.com/acme/resource"); private final URL resourceUrl = url("http://example.com/acme/resource");
private URL locationUrl = url("http://example.com/acme/account"); private final URL locationUrl = url("http://example.com/acme/account");
/** /**
* Test if a new account can be created. * Test if a new account can be created.

View File

@ -13,8 +13,10 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
@ -25,9 +27,7 @@ import java.net.HttpURLConnection;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.security.KeyPair; import java.security.KeyPair;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -51,9 +51,9 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class AccountTest { public class AccountTest {
private URL resourceUrl = url("http://example.com/acme/resource"); private final URL resourceUrl = url("http://example.com/acme/resource");
private URL locationUrl = url(TestUtils.ACCOUNT_URL); private final URL locationUrl = url(TestUtils.ACCOUNT_URL);
private URL agreementUrl = url("http://example.com/agreement.pdf"); private final URL agreementUrl = url("http://example.com/agreement.pdf");
/** /**
* Test that a account can be updated. * Test that a account can be updated.
@ -76,7 +76,7 @@ public class AccountTest {
public int sendSignedPostAsGetRequest(URL url, Login login) { public int sendSignedPostAsGetRequest(URL url, Login login) {
if (url("https://example.com/acme/acct/1/orders").equals(url)) { if (url("https://example.com/acme/acct/1/orders").equals(url)) {
jsonResponse = new JSONBuilder() jsonResponse = new JSONBuilder()
.array("orders", Arrays.asList("https://example.com/acme/order/1")) .array("orders", singletonList("https://example.com/acme/order/1"))
.toJSON(); .toJSON();
} else { } else {
jsonResponse = getJSON("updateAccountResponse"); jsonResponse = getJSON("updateAccountResponse");
@ -96,7 +96,7 @@ public class AccountTest {
@Override @Override
public Collection<URL> getLinks(String relation) { public Collection<URL> getLinks(String relation) {
return Collections.emptyList(); return emptyList();
} }
@Override @Override
@ -154,8 +154,8 @@ public class AccountTest {
@Override @Override
public Collection<URL> getLinks(String relation) { public Collection<URL> getLinks(String relation) {
switch(relation) { switch(relation) {
case "termsOfService": return Arrays.asList(agreementUrl); case "termsOfService": return singletonList(agreementUrl);
default: return null; default: return emptyList();
} }
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import org.junit.Test; import org.junit.Test;
import org.shredzone.acme4j.toolbox.TestUtils; import org.shredzone.acme4j.toolbox.TestUtils;
@ -73,7 +74,7 @@ public class AcmeResourceTest {
} }
// Make sure there is no PrivateKey in the stream // Make sure there is no PrivateKey in the stream
String str = new String(serialized, "iso-8859-1"); String str = new String(serialized, StandardCharsets.ISO_8859_1);
if (str.contains("Ljava/security/PrivateKey")) { if (str.contains("Ljava/security/PrivateKey")) {
fail("serialized stream contains a PrivateKey"); fail("serialized stream contains a PrivateKey");
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
@ -47,7 +47,7 @@ public class AuthorizationTest {
private static final String SNAILMAIL_TYPE = "snail-01"; // a non-existent challenge private static final String SNAILMAIL_TYPE = "snail-01"; // a non-existent challenge
private static final String DUPLICATE_TYPE = "duplicate-01"; // a duplicate challenge private static final String DUPLICATE_TYPE = "duplicate-01"; // a duplicate challenge
private URL locationUrl = url("http://example.com/acme/account"); private final URL locationUrl = url("http://example.com/acme/account");
/** /**
* Test that {@link Authorization#findChallenge(String)} finds challenges. * Test that {@link Authorization#findChallenge(String)} finds challenges.

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -45,8 +45,8 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class CertificateTest { public class CertificateTest {
private URL resourceUrl = url("http://example.com/acme/resource"); private final URL resourceUrl = url("http://example.com/acme/resource");
private URL locationUrl = url("http://example.com/acme/certificate"); private final URL locationUrl = url("http://example.com/acme/certificate");
/** /**
* Test that a certificate can be downloaded. * Test that a certificate can be downloaded.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.net.InetAddress; import java.net.InetAddress;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
@ -39,7 +39,7 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class LoginTest { public class LoginTest {
private static final URL resourceUrl = url("https://example.com/acme/resource/123"); private final URL resourceUrl = url("https://example.com/acme/resource/123");
/** /**
* Test the constructor. * Test the constructor.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
@ -41,8 +41,8 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class OrderBuilderTest { public class OrderBuilderTest {
private URL resourceUrl = url("http://example.com/acme/resource"); private final URL resourceUrl = url("http://example.com/acme/resource");
private URL locationUrl = url(TestUtils.ACCOUNT_URL); private final URL locationUrl = url(TestUtils.ACCOUNT_URL);
/** /**
* Test that a new {@link Order} can be created. * Test that a new {@link Order} can be created.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
@ -38,8 +38,8 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class OrderTest { public class OrderTest {
private URL locationUrl = url("http://example.com/acme/order/1234"); private final URL locationUrl = url("http://example.com/acme/order/1234");
private URL finalizeUrl = url("https://example.com/acme/acct/1/order/1/finalize"); private final URL finalizeUrl = url("https://example.com/acme/acct/1/order/1/finalize");
/** /**
* Test that order is properly updated. * Test that order is properly updated.

View File

@ -14,8 +14,8 @@
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.shredzone.acme4j.toolbox.TestUtils.*; import static org.shredzone.acme4j.toolbox.TestUtils.*;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j; package org.shredzone.acme4j;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test; import org.junit.Test;

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j.challenge; package org.shredzone.acme4j.challenge;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
@ -44,7 +44,7 @@ import org.shredzone.acme4j.toolbox.TestUtils;
* Unit tests for {@link Challenge}. * Unit tests for {@link Challenge}.
*/ */
public class ChallengeTest { public class ChallengeTest {
private URL locationUrl = url("https://example.com/acme/some-location"); private final URL locationUrl = url("https://example.com/acme/some-location");
/** /**
* Test that after unmarshaling, the challenge properties are set correctly. * Test that after unmarshaling, the challenge properties are set correctly.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.challenge; package org.shredzone.acme4j.challenge;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -29,7 +29,7 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class DnsChallengeTest { public class DnsChallengeTest {
private Login login = TestUtils.login(); private final Login login = TestUtils.login();
/** /**
* Test that {@link Dns01Challenge} generates a correct authorization key. * Test that {@link Dns01Challenge} generates a correct authorization key.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.challenge; package org.shredzone.acme4j.challenge;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -34,7 +34,7 @@ public class HttpChallengeTest {
private static final String KEY_AUTHORIZATION = private static final String KEY_AUTHORIZATION =
"rSoI9JpyvFi-ltdnBW0W1DjKstzG7cHixjzcOjwzAEQ.HnWjTDnyqlCrm6tZ-6wX-TrEXgRdeNu9G71gqxSO6o0"; "rSoI9JpyvFi-ltdnBW0W1DjKstzG7cHixjzcOjwzAEQ.HnWjTDnyqlCrm6tZ-6wX-TrEXgRdeNu9G71gqxSO6o0";
private Login login = TestUtils.login(); private final Login login = TestUtils.login();
/** /**
* Test that {@link Http01Challenge} generates a correct authorization key. * Test that {@link Http01Challenge} generates a correct authorization key.

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.challenge; package org.shredzone.acme4j.challenge;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -34,7 +34,7 @@ public class TlsAlpn01ChallengeTest {
private static final String KEY_AUTHORIZATION = private static final String KEY_AUTHORIZATION =
"rSoI9JpyvFi-ltdnBW0W1DjKstzG7cHixjzcOjwzAEQ.HnWjTDnyqlCrm6tZ-6wX-TrEXgRdeNu9G71gqxSO6o0"; "rSoI9JpyvFi-ltdnBW0W1DjKstzG7cHixjzcOjwzAEQ.HnWjTDnyqlCrm6tZ-6wX-TrEXgRdeNu9G71gqxSO6o0";
private Login login = TestUtils.login(); private final Login login = TestUtils.login();
/** /**
* Test that {@link TlsAlpn01Challenge} generates a correct authorization key. * Test that {@link TlsAlpn01Challenge} generates a correct authorization key.

View File

@ -15,8 +15,9 @@ package org.shredzone.acme4j.connector;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME; import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.any; import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ -75,9 +76,8 @@ public class DefaultConnectionTest {
private static final Base64.Encoder URL_ENCODER = Base64.getUrlEncoder().withoutPadding(); private static final Base64.Encoder URL_ENCODER = Base64.getUrlEncoder().withoutPadding();
private static final Base64.Decoder URL_DECODER = Base64.getUrlDecoder(); private static final Base64.Decoder URL_DECODER = Base64.getUrlDecoder();
private URL requestUrl = TestUtils.url("http://example.com/acme/"); private final URL requestUrl = TestUtils.url("http://example.com/acme/");
private URL accountUrl = TestUtils.url(TestUtils.ACCOUNT_URL); private final URL accountUrl = TestUtils.url(TestUtils.ACCOUNT_URL);
private NetworkSettings settings = new NetworkSettings();
private HttpURLConnection mockUrlConnection; private HttpURLConnection mockUrlConnection;
private HttpConnector mockHttpConnection; private HttpConnector mockHttpConnection;
private Session session; private Session session;
@ -247,8 +247,8 @@ public class DefaultConnectionTest {
@Test @Test
public void testGetLink() throws Exception { public void testGetLink() throws Exception {
Map<String, List<String>> headers = new HashMap<>(); Map<String, List<String>> headers = new HashMap<>();
headers.put("Content-Type", Arrays.asList("application/json")); headers.put("Content-Type", singletonList("application/json"));
headers.put("Location", Arrays.asList("https://example.com/acme/acct/asdf")); headers.put("Location", singletonList("https://example.com/acme/acct/asdf"));
headers.put("Link", Arrays.asList( headers.put("Link", Arrays.asList(
"<https://example.com/acme/new-authz>;rel=\"next\"", "<https://example.com/acme/new-authz>;rel=\"next\"",
"</recover-acct>;rel=recover", "</recover-acct>;rel=recover",
@ -441,7 +441,7 @@ public class DefaultConnectionTest {
when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length());
when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN);
when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream()); when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream());
when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes("utf-8"))); when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes(UTF_8)));
when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1")); when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1"));
session.setNonce(TestUtils.DUMMY_NONCE); session.setNonce(TestUtils.DUMMY_NONCE);
@ -471,14 +471,14 @@ public class DefaultConnectionTest {
String jsonData = "{\"type\":\"urn:ietf:params:acme:error:userActionRequired\",\"detail\":\"Accept the TOS\"}"; String jsonData = "{\"type\":\"urn:ietf:params:acme:error:userActionRequired\",\"detail\":\"Accept the TOS\"}";
Map<String, List<String>> linkHeader = new HashMap<>(); Map<String, List<String>> linkHeader = new HashMap<>();
linkHeader.put("Link", Arrays.asList("<https://example.com/tos.pdf>; rel=\"terms-of-service\"")); linkHeader.put("Link", singletonList("<https://example.com/tos.pdf>; rel=\"terms-of-service\""));
when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/problem+json"); when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/problem+json");
when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length());
when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader); when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader);
when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN);
when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream()); when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream());
when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes("utf-8"))); when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes(UTF_8)));
when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1")); when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1"));
session.setNonce(TestUtils.DUMMY_NONCE); session.setNonce(TestUtils.DUMMY_NONCE);
@ -510,7 +510,7 @@ public class DefaultConnectionTest {
String jsonData = "{\"type\":\"urn:ietf:params:acme:error:rateLimited\",\"detail\":\"Too many invocations\"}"; String jsonData = "{\"type\":\"urn:ietf:params:acme:error:rateLimited\",\"detail\":\"Too many invocations\"}";
Map<String, List<String>> linkHeader = new HashMap<>(); Map<String, List<String>> linkHeader = new HashMap<>();
linkHeader.put("Link", Arrays.asList("<https://example.com/rates.pdf>; rel=\"help\"")); linkHeader.put("Link", singletonList("<https://example.com/rates.pdf>; rel=\"help\""));
Instant retryAfter = Instant.now().plusSeconds(30L).truncatedTo(ChronoUnit.MILLIS); Instant retryAfter = Instant.now().plusSeconds(30L).truncatedTo(ChronoUnit.MILLIS);
@ -521,7 +521,7 @@ public class DefaultConnectionTest {
when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader); when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader);
when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN);
when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream()); when(mockUrlConnection.getOutputStream()).thenReturn(new ByteArrayOutputStream());
when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes("utf-8"))); when(mockUrlConnection.getErrorStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes(UTF_8)));
when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1")); when(mockUrlConnection.getURL()).thenReturn(url("https://example.com/acme/1"));
session.setNonce(TestUtils.DUMMY_NONCE); session.setNonce(TestUtils.DUMMY_NONCE);
@ -762,7 +762,7 @@ public class DefaultConnectionTest {
verify(mockUrlConnection, atLeast(0)).getHeaderFields(); verify(mockUrlConnection, atLeast(0)).getHeaderFields();
verifyNoMoreInteractions(mockUrlConnection); verifyNoMoreInteractions(mockUrlConnection);
JSON data = JSON.parse(new String(outputStream.toByteArray(), "utf-8")); JSON data = JSON.parse(new String(outputStream.toByteArray(), UTF_8));
String encodedHeader = data.get("protected").asString(); String encodedHeader = data.get("protected").asString();
String encodedSignature = data.get("signature").asString(); String encodedSignature = data.get("signature").asString();
String encodedPayload = data.get("payload").asString(); String encodedPayload = data.get("payload").asString();
@ -835,7 +835,7 @@ public class DefaultConnectionTest {
verify(mockUrlConnection, atLeast(0)).getHeaderFields(); verify(mockUrlConnection, atLeast(0)).getHeaderFields();
verifyNoMoreInteractions(mockUrlConnection); verifyNoMoreInteractions(mockUrlConnection);
JSON data = JSON.parse(new String(outputStream.toByteArray(), "utf-8")); JSON data = JSON.parse(new String(outputStream.toByteArray(), UTF_8));
String encodedHeader = data.get("protected").asString(); String encodedHeader = data.get("protected").asString();
String encodedSignature = data.get("signature").asString(); String encodedSignature = data.get("signature").asString();
String encodedPayload = data.get("payload").asString(); String encodedPayload = data.get("payload").asString();
@ -961,7 +961,7 @@ public class DefaultConnectionTest {
verify(mockUrlConnection, atLeast(0)).getHeaderFields(); verify(mockUrlConnection, atLeast(0)).getHeaderFields();
verifyNoMoreInteractions(mockUrlConnection); verifyNoMoreInteractions(mockUrlConnection);
JSON data = JSON.parse(new String(outputStream.toByteArray(), "utf-8")); JSON data = JSON.parse(new String(outputStream.toByteArray(), UTF_8));
String encodedHeader = data.get("protected").asString(); String encodedHeader = data.get("protected").asString();
String encodedSignature = data.get("signature").asString(); String encodedSignature = data.get("signature").asString();
String encodedPayload = data.get("payload").asString(); String encodedPayload = data.get("payload").asString();
@ -1013,7 +1013,7 @@ public class DefaultConnectionTest {
when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/json"); when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/json");
when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length());
when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
when(mockUrlConnection.getInputStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes("utf-8"))); when(mockUrlConnection.getInputStream()).thenReturn(new ByteArrayInputStream(jsonData.getBytes(UTF_8)));
try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) { try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) {
conn.conn = mockUrlConnection; conn.conn = mockUrlConnection;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -37,7 +37,7 @@ public class HttpConnectorTest {
* This is just a mock to check that the parameters are properly set. * This is just a mock to check that the parameters are properly set.
*/ */
@Test @Test
public void testMockOpenConnection() throws IOException { public void testMockOpenConnection() {
NetworkSettings settings = new NetworkSettings(); NetworkSettings settings = new NetworkSettings();
settings.setTimeout(Duration.ofSeconds(50)); settings.setTimeout(Duration.ofSeconds(50));

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;

View File

@ -13,15 +13,14 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -41,12 +40,12 @@ import org.shredzone.acme4j.toolbox.JSONBuilder;
*/ */
public class ResourceIteratorTest { public class ResourceIteratorTest {
private final int PAGES = 4; private static final int PAGES = 4;
private final int RESOURCES_PER_PAGE = 5; private static final int RESOURCES_PER_PAGE = 5;
private final String TYPE = "authorizations"; private static final String TYPE = "authorizations";
private List<URL> resourceURLs = new ArrayList<>(PAGES * RESOURCES_PER_PAGE); private final List<URL> resourceURLs = new ArrayList<>(PAGES * RESOURCES_PER_PAGE);
private List<URL> pageURLs = new ArrayList<>(PAGES); private final List<URL> pageURLs = new ArrayList<>(PAGES);
@Before @Before
public void setup() { public void setup() {
@ -154,7 +153,7 @@ public class ResourceIteratorTest {
@Override @Override
public Collection<URL> getLinks(String relation) { public Collection<URL> getLinks(String relation) {
if ("next".equals(relation) && (ix + 1 < pageURLs.size())) { if ("next".equals(relation) && (ix + 1 < pageURLs.size())) {
return Arrays.asList(pageURLs.get(ix + 1)); return Collections.singletonList(pageURLs.get(ix + 1));
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test; import org.junit.Test;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.connector; package org.shredzone.acme4j.connector;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import java.net.URL; import java.net.URL;
@ -29,7 +29,7 @@ import org.shredzone.acme4j.toolbox.TestUtils;
*/ */
public class AcmeLazyLoadingExceptionTest { public class AcmeLazyLoadingExceptionTest {
private URL resourceUrl = TestUtils.url("http://example.com/acme/resource/123"); private final URL resourceUrl = TestUtils.url("http://example.com/acme/resource/123");
@Test @Test
public void testAcmeLazyLoadingException() { public void testAcmeLazyLoadingException() {
@ -42,7 +42,7 @@ public class AcmeLazyLoadingExceptionTest {
assertThat(ex, is(instanceOf(RuntimeException.class))); assertThat(ex, is(instanceOf(RuntimeException.class)));
assertThat(ex.getMessage(), containsString(resourceUrl.toString())); assertThat(ex.getMessage(), containsString(resourceUrl.toString()));
assertThat(ex.getMessage(), containsString(TestResource.class.getSimpleName())); assertThat(ex.getMessage(), containsString(TestResource.class.getSimpleName()));
assertThat(ex.getCause(), is((Throwable) cause)); assertThat(ex.getCause(), is(cause));
assertThat(ex.getType(), is(equalTo(TestResource.class))); assertThat(ex.getType(), is(equalTo(TestResource.class)));
assertThat(ex.getLocation(), is(resourceUrl)); assertThat(ex.getLocation(), is(resourceUrl));
} }

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
@ -33,7 +33,7 @@ public class AcmeNetworkExceptionTest {
AcmeNetworkException ex = new AcmeNetworkException(cause); AcmeNetworkException ex = new AcmeNetworkException(cause);
assertThat(ex.getMessage(), notNullValue()); assertThat(ex.getMessage(), notNullValue());
assertThat(ex.getCause(), is((Throwable) cause)); assertThat(ex.getCause(), is(cause));
} }
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import org.junit.Test; import org.junit.Test;
@ -38,7 +38,7 @@ public class AcmeProtocolExceptionTest {
NumberFormatException cause = new NumberFormatException("Not a number: abc"); NumberFormatException cause = new NumberFormatException("Not a number: abc");
AcmeProtocolException ex = new AcmeProtocolException(message, cause); AcmeProtocolException ex = new AcmeProtocolException(message, cause);
assertThat(ex.getMessage(), is(message)); assertThat(ex.getMessage(), is(message));
assertThat(ex.getCause(), is((Throwable) cause)); assertThat(ex.getCause(), is(cause));
} }
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.createProblem; import static org.shredzone.acme4j.toolbox.TestUtils.createProblem;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j.exception; package org.shredzone.acme4j.exception;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.createProblem; import static org.shredzone.acme4j.toolbox.TestUtils.createProblem;
import java.net.MalformedURLException; import java.net.MalformedURLException;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.provider; package org.shredzone.acme4j.provider;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.any; import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.provider; package org.shredzone.acme4j.provider;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.provider.letsencrypt; package org.shredzone.acme4j.provider.letsencrypt;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.provider.pebble; package org.shredzone.acme4j.provider.pebble;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;

View File

@ -13,9 +13,9 @@
*/ */
package org.shredzone.acme4j.toolbox; package org.shredzone.acme4j.toolbox;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.AcmeUtils.*; import static org.shredzone.acme4j.toolbox.AcmeUtils.*;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.toolbox; package org.shredzone.acme4j.toolbox;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
import java.security.KeyPair; import java.security.KeyPair;
@ -67,7 +67,7 @@ public class JSONBuilderTest {
Map<String, Object> map = cb.toMap(); Map<String, Object> map = cb.toMap();
assertThat(map.keySet(), hasSize(2)); assertThat(map.keySet(), hasSize(2));
assertThat(map, allOf( assertThat(map, allOf(
hasEntry("fooInt", (Object) 456), hasEntry("fooInt", 456),
hasEntry("fooStr", (Object) "String") hasEntry("fooStr", (Object) "String")
)); ));
@ -161,7 +161,7 @@ public class JSONBuilderTest {
assertThat(cb1.toString(), is("{\"ar\":[]}")); assertThat(cb1.toString(), is("{\"ar\":[]}"));
JSONBuilder cb2 = new JSONBuilder(); JSONBuilder cb2 = new JSONBuilder();
res = cb2.array("ar", Arrays.asList(123)); res = cb2.array("ar", Collections.singletonList(123));
assertThat(res, is(sameInstance(cb2))); assertThat(res, is(sameInstance(cb2)));
assertThat(cb2.toString(), is("{\"ar\":[123]}")); assertThat(cb2.toString(), is("{\"ar\":[123]}"));

View File

@ -13,8 +13,9 @@
*/ */
package org.shredzone.acme4j.toolbox; package org.shredzone.acme4j.toolbox;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
@ -25,7 +26,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.time.Duration; import java.time.Duration;
@ -77,7 +77,7 @@ public class JSONTest {
assertThat(map.get("foo"), is("a-text")); assertThat(map.get("foo"), is("a-text"));
assertThat(map.get("bar"), is(123L)); assertThat(map.get("bar"), is(123L));
try (InputStream in = new ByteArrayInputStream(json.getBytes("utf-8"))) { try (InputStream in = new ByteArrayInputStream(json.getBytes(UTF_8))) {
JSON fromStream = JSON.parse(in); JSON fromStream = JSON.parse(in);
assertThat(fromStream.toString(), is(sameJSONAs(json))); assertThat(fromStream.toString(), is(sameJSONAs(json)));
Map<String, Object> map2 = fromStream.toMap(); Map<String, Object> map2 = fromStream.toMap();
@ -92,7 +92,7 @@ public class JSONTest {
* Test that bad JSON fails. * Test that bad JSON fails.
*/ */
@Test(expected = AcmeProtocolException.class) @Test(expected = AcmeProtocolException.class)
public void testParsersBadJSON() throws IOException { public void testParsersBadJSON() {
JSON.parse("This is no JSON."); JSON.parse("This is no JSON.");
} }
@ -247,7 +247,7 @@ public class JSONTest {
* Test that getters are null safe. * Test that getters are null safe.
*/ */
@Test @Test
public void testNullGetter() throws MalformedURLException { public void testNullGetter() {
JSON json = TestUtils.getJSON("datatypes"); JSON json = TestUtils.getJSON("datatypes");
assertThat(json.get("none"), is(notNullValue())); assertThat(json.get("none"), is(notNullValue()));
@ -344,7 +344,7 @@ public class JSONTest {
* Test that wrong getters return an exception. * Test that wrong getters return an exception.
*/ */
@Test @Test
public void testWrongGetter() throws MalformedURLException { public void testWrongGetter() {
JSON json = TestUtils.getJSON("datatypes"); JSON json = TestUtils.getJSON("datatypes");
try { try {

View File

@ -14,8 +14,8 @@
package org.shredzone.acme4j.toolbox; package org.shredzone.acme4j.toolbox;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.shredzone.acme4j.toolbox.TestUtils.url; import static org.shredzone.acme4j.toolbox.TestUtils.url;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;

View File

@ -15,8 +15,9 @@ package org.shredzone.acme4j.it.boulder;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.fail;
import java.net.URI; import java.net.URI;
import java.security.KeyPair; import java.security.KeyPair;
@ -46,7 +47,7 @@ public class OrderHttpIT {
private final String bammbammUrl = System.getProperty("bammbammUrl", "http://localhost:14001"); private final String bammbammUrl = System.getProperty("bammbammUrl", "http://localhost:14001");
private BammBammClient client = new BammBammClient(bammbammUrl); private final BammBammClient client = new BammBammClient(bammbammUrl);
/** /**
* Test if a certificate can be ordered via http-01 challenge. * Test if a certificate can be ordered via http-01 challenge.

View File

@ -13,8 +13,10 @@
*/ */
package org.shredzone.acme4j.it.pebble; package org.shredzone.acme4j.it.pebble;
import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.fail;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;

View File

@ -15,8 +15,9 @@ package org.shredzone.acme4j.it.pebble;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.fail;
import java.net.URI; import java.net.URI;
import java.security.KeyPair; import java.security.KeyPair;
@ -154,7 +155,7 @@ public class OrderIT extends PebbleITBase {
KeyPair domainKeyPair = createKeyPair(); KeyPair domainKeyPair = createKeyPair();
Instant notBefore = Instant.now().truncatedTo(ChronoUnit.MILLIS); Instant notBefore = Instant.now().truncatedTo(ChronoUnit.SECONDS);
Instant notAfter = notBefore.plus(Duration.ofDays(20L)); Instant notAfter = notBefore.plus(Duration.ofDays(20L));
Order order = account.newOrder() Order order = account.newOrder()
@ -208,8 +209,8 @@ public class OrderIT extends PebbleITBase {
Certificate certificate = order.getCertificate(); Certificate certificate = order.getCertificate();
X509Certificate cert = certificate.getCertificate(); X509Certificate cert = certificate.getCertificate();
assertThat(cert, not(nullValue())); assertThat(cert, not(nullValue()));
assertThat(cert.getNotAfter(), not(nullValue())); assertThat(cert.getNotBefore().toInstant(), is(notNullValue()));
assertThat(cert.getNotBefore(), not(nullValue())); assertThat(cert.getNotAfter().toInstant(), is(notNullValue()));
assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + domain)); assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + domain));
for (Authorization auth : order.getAuthorizations()) { for (Authorization auth : order.getAuthorizations()) {
@ -260,12 +261,12 @@ public class OrderIT extends PebbleITBase {
} }
@FunctionalInterface @FunctionalInterface
private static interface Validator { private interface Validator {
Challenge prepare(Authorization auth) throws Exception; Challenge prepare(Authorization auth) throws Exception;
} }
@FunctionalInterface @FunctionalInterface
private static interface Revoker { private interface Revoker {
void revoke(Session session, Certificate certificate, KeyPair keyPair, void revoke(Session session, Certificate certificate, KeyPair keyPair,
KeyPair domainKeyPair) throws Exception; KeyPair domainKeyPair) throws Exception;
} }

View File

@ -16,8 +16,9 @@ package org.shredzone.acme4j.it.pebble;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.junit.Assert.fail;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.it.pebble; package org.shredzone.acme4j.it.pebble;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
@ -133,7 +133,7 @@ public abstract class PebbleITBase {
} }
@FunctionalInterface @FunctionalInterface
public static interface CleanupCallback { public interface CleanupCallback {
void cleanup() throws Exception; void cleanup() throws Exception;
} }

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.it.pebble; package org.shredzone.acme4j.it.pebble;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.net.URI; import java.net.URI;

View File

@ -14,8 +14,8 @@
package org.shredzone.acme4j.util; package org.shredzone.acme4j.util;
import static java.time.temporal.ChronoUnit.SECONDS; import static java.time.temporal.ChronoUnit.SECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

View File

@ -13,8 +13,8 @@
*/ */
package org.shredzone.acme4j.util; package org.shredzone.acme4j.util;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;