diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java index 7a59346b..9b5361c3 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountBuilderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; 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.url; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -41,8 +41,8 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class AccountBuilderTest { - private URL resourceUrl = url("http://example.com/acme/resource"); - private URL locationUrl = url("http://example.com/acme/account"); + private final URL resourceUrl = url("http://example.com/acme/resource"); + private final URL locationUrl = url("http://example.com/acme/account"); /** * Test if a new account can be created. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java index 56fd1f21..b23edecd 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AccountTest.java @@ -13,8 +13,10 @@ */ 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.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.url; @@ -25,9 +27,7 @@ import java.net.HttpURLConnection; import java.net.URI; import java.net.URL; import java.security.KeyPair; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.concurrent.atomic.AtomicBoolean; @@ -51,9 +51,9 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class AccountTest { - private URL resourceUrl = url("http://example.com/acme/resource"); - private URL locationUrl = url(TestUtils.ACCOUNT_URL); - private URL agreementUrl = url("http://example.com/agreement.pdf"); + private final URL resourceUrl = url("http://example.com/acme/resource"); + private final URL locationUrl = url(TestUtils.ACCOUNT_URL); + private final URL agreementUrl = url("http://example.com/agreement.pdf"); /** * Test that a account can be updated. @@ -76,7 +76,7 @@ public class AccountTest { public int sendSignedPostAsGetRequest(URL url, Login login) { if (url("https://example.com/acme/acct/1/orders").equals(url)) { jsonResponse = new JSONBuilder() - .array("orders", Arrays.asList("https://example.com/acme/order/1")) + .array("orders", singletonList("https://example.com/acme/order/1")) .toJSON(); } else { jsonResponse = getJSON("updateAccountResponse"); @@ -96,7 +96,7 @@ public class AccountTest { @Override public Collection getLinks(String relation) { - return Collections.emptyList(); + return emptyList(); } @Override @@ -154,8 +154,8 @@ public class AccountTest { @Override public Collection getLinks(String relation) { switch(relation) { - case "termsOfService": return Arrays.asList(agreementUrl); - default: return null; + case "termsOfService": return singletonList(agreementUrl); + default: return emptyList(); } } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeJsonResourceTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeJsonResourceTest.java index 8307682d..4278a07d 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeJsonResourceTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeJsonResourceTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; 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.url; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeResourceTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeResourceTest.java index cd64dfac..65d2d8da 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeResourceTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AcmeResourceTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; @@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.URL; +import java.nio.charset.StandardCharsets; import org.junit.Test; import org.shredzone.acme4j.toolbox.TestUtils; @@ -73,7 +74,7 @@ public class AcmeResourceTest { } // 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")) { fail("serialized stream contains a PrivateKey"); } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/AuthorizationTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/AuthorizationTest.java index f609090c..a7f928a9 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/AuthorizationTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/AuthorizationTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; 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 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. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/CertificateTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/CertificateTest.java index 2c4c04d7..92b58b17 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/CertificateTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/CertificateTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; 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.url; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -45,8 +45,8 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class CertificateTest { - private URL resourceUrl = url("http://example.com/acme/resource"); - private URL locationUrl = url("http://example.com/acme/certificate"); + private final URL resourceUrl = url("http://example.com/acme/resource"); + private final URL locationUrl = url("http://example.com/acme/certificate"); /** * Test that a certificate can be downloaded. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java index 214b2c87..42251460 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.net.InetAddress; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/LoginTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/LoginTest.java index b0d3a3ae..42051f5d 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/LoginTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/LoginTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.*; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.url; @@ -39,7 +39,7 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ 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. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/OrderBuilderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/OrderBuilderTest.java index eaf2c1b7..caba6664 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/OrderBuilderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/OrderBuilderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; @@ -41,8 +41,8 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class OrderBuilderTest { - private URL resourceUrl = url("http://example.com/acme/resource"); - private URL locationUrl = url(TestUtils.ACCOUNT_URL); + private final URL resourceUrl = url("http://example.com/acme/resource"); + private final URL locationUrl = url(TestUtils.ACCOUNT_URL); /** * Test that a new {@link Order} can be created. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/OrderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/OrderTest.java index 34e912d0..578cac11 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/OrderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/OrderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; 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.TestUtils.getJSON; import static org.shredzone.acme4j.toolbox.TestUtils.url; @@ -38,8 +38,8 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class OrderTest { - private 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 locationUrl = url("http://example.com/acme/order/1234"); + private final URL finalizeUrl = url("https://example.com/acme/acct/1/order/1/finalize"); /** * Test that order is properly updated. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/ProblemTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/ProblemTest.java index 7adc3585..c82e0cc6 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/ProblemTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/ProblemTest.java @@ -14,8 +14,8 @@ package org.shredzone.acme4j; import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.url; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/SessionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/SessionTest.java index 8b6d9435..870a7dda 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/SessionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/SessionTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; import static org.shredzone.acme4j.toolbox.TestUtils.*; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/StatusTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/StatusTest.java index 20b4acb4..1c79e509 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/StatusTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/StatusTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java index f46bece8..eb5d9063 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/ChallengeTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j.challenge; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; @@ -44,7 +44,7 @@ import org.shredzone.acme4j.toolbox.TestUtils; * Unit tests for {@link Challenge}. */ 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. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/DnsChallengeTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/DnsChallengeTest.java index 40a09911..2cf8a201 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/DnsChallengeTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/DnsChallengeTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.challenge; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -29,7 +29,7 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ public class DnsChallengeTest { - private Login login = TestUtils.login(); + private final Login login = TestUtils.login(); /** * Test that {@link Dns01Challenge} generates a correct authorization key. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/HttpChallengeTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/HttpChallengeTest.java index 3f68a66d..633e3a56 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/HttpChallengeTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/HttpChallengeTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.challenge; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -34,7 +34,7 @@ public class HttpChallengeTest { private static final String KEY_AUTHORIZATION = "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. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/TlsAlpn01ChallengeTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/TlsAlpn01ChallengeTest.java index 0ea03bed..f08fe6ea 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/TlsAlpn01ChallengeTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/challenge/TlsAlpn01ChallengeTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.challenge; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.getJSON; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -34,7 +34,7 @@ public class TlsAlpn01ChallengeTest { private static final String KEY_AUTHORIZATION = "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. diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/DefaultConnectionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/DefaultConnectionTest.java index 0ee99c31..a78d1440 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/DefaultConnectionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/DefaultConnectionTest.java @@ -15,8 +15,9 @@ package org.shredzone.acme4j.connector; import static java.nio.charset.StandardCharsets.UTF_8; 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.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.any; 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.Decoder URL_DECODER = Base64.getUrlDecoder(); - private URL requestUrl = TestUtils.url("http://example.com/acme/"); - private URL accountUrl = TestUtils.url(TestUtils.ACCOUNT_URL); - private NetworkSettings settings = new NetworkSettings(); + private final URL requestUrl = TestUtils.url("http://example.com/acme/"); + private final URL accountUrl = TestUtils.url(TestUtils.ACCOUNT_URL); private HttpURLConnection mockUrlConnection; private HttpConnector mockHttpConnection; private Session session; @@ -247,8 +247,8 @@ public class DefaultConnectionTest { @Test public void testGetLink() throws Exception { Map> headers = new HashMap<>(); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Location", Arrays.asList("https://example.com/acme/acct/asdf")); + headers.put("Content-Type", singletonList("application/json")); + headers.put("Location", singletonList("https://example.com/acme/acct/asdf")); headers.put("Link", Arrays.asList( ";rel=\"next\"", ";rel=recover", @@ -441,7 +441,7 @@ public class DefaultConnectionTest { when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); 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")); 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\"}"; Map> linkHeader = new HashMap<>(); - linkHeader.put("Link", Arrays.asList("; rel=\"terms-of-service\"")); + linkHeader.put("Link", singletonList("; rel=\"terms-of-service\"")); when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/problem+json"); when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); 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")); 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\"}"; Map> linkHeader = new HashMap<>(); - linkHeader.put("Link", Arrays.asList("; rel=\"help\"")); + linkHeader.put("Link", singletonList("; rel=\"help\"")); Instant retryAfter = Instant.now().plusSeconds(30L).truncatedTo(ChronoUnit.MILLIS); @@ -521,7 +521,7 @@ public class DefaultConnectionTest { when(mockUrlConnection.getHeaderFields()).thenReturn(linkHeader); when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN); 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")); session.setNonce(TestUtils.DUMMY_NONCE); @@ -762,7 +762,7 @@ public class DefaultConnectionTest { verify(mockUrlConnection, atLeast(0)).getHeaderFields(); 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 encodedSignature = data.get("signature").asString(); String encodedPayload = data.get("payload").asString(); @@ -835,7 +835,7 @@ public class DefaultConnectionTest { verify(mockUrlConnection, atLeast(0)).getHeaderFields(); 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 encodedSignature = data.get("signature").asString(); String encodedPayload = data.get("payload").asString(); @@ -961,7 +961,7 @@ public class DefaultConnectionTest { verify(mockUrlConnection, atLeast(0)).getHeaderFields(); 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 encodedSignature = data.get("signature").asString(); String encodedPayload = data.get("payload").asString(); @@ -1013,7 +1013,7 @@ public class DefaultConnectionTest { when(mockUrlConnection.getHeaderField("Content-Type")).thenReturn("application/json"); when(mockUrlConnection.getContentLength()).thenReturn(jsonData.length()); 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)) { conn.conn = mockUrlConnection; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/HttpConnectorTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/HttpConnectorTest.java index e28cec04..952dc71c 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/HttpConnectorTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/HttpConnectorTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; 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. */ @Test - public void testMockOpenConnection() throws IOException { + public void testMockOpenConnection() { NetworkSettings settings = new NetworkSettings(); settings.setTimeout(Duration.ofSeconds(50)); diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/NetworkSettingsTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/NetworkSettingsTest.java index 03d92c55..c6aa35f3 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/NetworkSettingsTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/NetworkSettingsTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.net.InetSocketAddress; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceIteratorTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceIteratorTest.java index c9904981..ad00bfeb 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceIteratorTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceIteratorTest.java @@ -13,15 +13,14 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.url; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -41,12 +40,12 @@ import org.shredzone.acme4j.toolbox.JSONBuilder; */ public class ResourceIteratorTest { - private final int PAGES = 4; - private final int RESOURCES_PER_PAGE = 5; - private final String TYPE = "authorizations"; + private static final int PAGES = 4; + private static final int RESOURCES_PER_PAGE = 5; + private static final String TYPE = "authorizations"; - private List resourceURLs = new ArrayList<>(PAGES * RESOURCES_PER_PAGE); - private List pageURLs = new ArrayList<>(PAGES); + private final List resourceURLs = new ArrayList<>(PAGES * RESOURCES_PER_PAGE); + private final List pageURLs = new ArrayList<>(PAGES); @Before public void setup() { @@ -154,7 +153,7 @@ public class ResourceIteratorTest { @Override public Collection getLinks(String relation) { 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(); } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java index 4cc78024..c47328fe 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/ResourceTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/SessionProviderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/SessionProviderTest.java index 014a8579..68190827 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/SessionProviderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/SessionProviderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.net.URI; import java.net.URL; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/TrimmingInputStreamTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/TrimmingInputStreamTest.java index a38228d4..d57fa9fb 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/connector/TrimmingInputStreamTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/connector/TrimmingInputStreamTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.connector; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeExceptionTest.java index ce6c825e..85910055 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeExceptionTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import java.io.IOException; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeLazyLoadingExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeLazyLoadingExceptionTest.java index 7d642ac5..e2fcf455 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeLazyLoadingExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeLazyLoadingExceptionTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import java.net.URL; @@ -29,7 +29,7 @@ import org.shredzone.acme4j.toolbox.TestUtils; */ 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 public void testAcmeLazyLoadingException() { @@ -42,7 +42,7 @@ public class AcmeLazyLoadingExceptionTest { assertThat(ex, is(instanceOf(RuntimeException.class))); assertThat(ex.getMessage(), containsString(resourceUrl.toString())); 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.getLocation(), is(resourceUrl)); } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeNetworkExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeNetworkExceptionTest.java index be6c7ba9..c58ea9af 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeNetworkExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeNetworkExceptionTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; import java.io.IOException; @@ -33,7 +33,7 @@ public class AcmeNetworkExceptionTest { AcmeNetworkException ex = new AcmeNetworkException(cause); assertThat(ex.getMessage(), notNullValue()); - assertThat(ex.getCause(), is((Throwable) cause)); + assertThat(ex.getCause(), is(cause)); } } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeProtocolExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeProtocolExceptionTest.java index c29aa0eb..3c89cb64 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeProtocolExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeProtocolExceptionTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import org.junit.Test; @@ -38,7 +38,7 @@ public class AcmeProtocolExceptionTest { NumberFormatException cause = new NumberFormatException("Not a number: abc"); AcmeProtocolException ex = new AcmeProtocolException(message, cause); assertThat(ex.getMessage(), is(message)); - assertThat(ex.getCause(), is((Throwable) cause)); + assertThat(ex.getCause(), is(cause)); } } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRateLimitedExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRateLimitedExceptionTest.java index 94cbe9cb..31b0d531 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRateLimitedExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRateLimitedExceptionTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; 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.url; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRetryAfterExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRetryAfterExceptionTest.java index 90752226..67c39758 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRetryAfterExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeRetryAfterExceptionTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import java.time.Duration; import java.time.Instant; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeUserActionRequiredExceptionTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeUserActionRequiredExceptionTest.java index 3ff7b7ba..bde92479 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeUserActionRequiredExceptionTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/exception/AcmeUserActionRequiredExceptionTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j.exception; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import static org.shredzone.acme4j.toolbox.TestUtils.createProblem; import java.net.MalformedURLException; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/AbstractAcmeProviderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/AbstractAcmeProviderTest.java index da4dd57c..029a932b 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/AbstractAcmeProviderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/AbstractAcmeProviderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.provider; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.any; import static org.mockito.Mockito.*; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/GenericAcmeProviderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/GenericAcmeProviderTest.java index c75a685c..bf01a64c 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/GenericAcmeProviderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/GenericAcmeProviderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.provider; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.net.URI; import java.net.URISyntaxException; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/letsencrypt/LetsEncryptAcmeProviderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/letsencrypt/LetsEncryptAcmeProviderTest.java index 6685e4e7..f541142a 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/letsencrypt/LetsEncryptAcmeProviderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/letsencrypt/LetsEncryptAcmeProviderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.provider.letsencrypt; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.TestUtils.url; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/pebble/PebbleAcmeProviderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/pebble/PebbleAcmeProviderTest.java index a73ca4d6..88518856 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/provider/pebble/PebbleAcmeProviderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/provider/pebble/PebbleAcmeProviderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.provider.pebble; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.TestUtils.url; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/AcmeUtilsTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/AcmeUtilsTest.java index cc60cb0d..a73a8382 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/AcmeUtilsTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/AcmeUtilsTest.java @@ -13,9 +13,9 @@ */ package org.shredzone.acme4j.toolbox; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.AcmeUtils.*; diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONBuilderTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONBuilderTest.java index a357c7d0..c4e1acb3 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONBuilderTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONBuilderTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.toolbox; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.io.IOException; import java.security.KeyPair; @@ -67,7 +67,7 @@ public class JSONBuilderTest { Map map = cb.toMap(); assertThat(map.keySet(), hasSize(2)); assertThat(map, allOf( - hasEntry("fooInt", (Object) 456), + hasEntry("fooInt", 456), hasEntry("fooStr", (Object) "String") )); @@ -161,7 +161,7 @@ public class JSONBuilderTest { assertThat(cb1.toString(), is("{\"ar\":[]}")); JSONBuilder cb2 = new JSONBuilder(); - res = cb2.array("ar", Arrays.asList(123)); + res = cb2.array("ar", Collections.singletonList(123)); assertThat(res, is(sameInstance(cb2))); assertThat(cb2.toString(), is("{\"ar\":[123]}")); diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONTest.java index 4e312971..9a0dd201 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JSONTest.java @@ -13,8 +13,9 @@ */ 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.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.TestUtils.url; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; @@ -25,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.time.Duration; @@ -77,7 +77,7 @@ public class JSONTest { assertThat(map.get("foo"), is("a-text")); 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); assertThat(fromStream.toString(), is(sameJSONAs(json))); Map map2 = fromStream.toMap(); @@ -92,7 +92,7 @@ public class JSONTest { * Test that bad JSON fails. */ @Test(expected = AcmeProtocolException.class) - public void testParsersBadJSON() throws IOException { + public void testParsersBadJSON() { JSON.parse("This is no JSON."); } @@ -247,7 +247,7 @@ public class JSONTest { * Test that getters are null safe. */ @Test - public void testNullGetter() throws MalformedURLException { + public void testNullGetter() { JSON json = TestUtils.getJSON("datatypes"); assertThat(json.get("none"), is(notNullValue())); @@ -344,7 +344,7 @@ public class JSONTest { * Test that wrong getters return an exception. */ @Test - public void testWrongGetter() throws MalformedURLException { + public void testWrongGetter() { JSON json = TestUtils.getJSON("datatypes"); try { diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JoseUtilsTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JoseUtilsTest.java index 88600a55..2a09ce50 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JoseUtilsTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/toolbox/JoseUtilsTest.java @@ -14,8 +14,8 @@ 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.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.shredzone.acme4j.toolbox.TestUtils.url; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/boulder/OrderHttpIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/boulder/OrderHttpIT.java index 476aab3b..0b44e763 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/boulder/OrderHttpIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/boulder/OrderHttpIT.java @@ -15,8 +15,9 @@ package org.shredzone.acme4j.it.boulder; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import java.net.URI; import java.security.KeyPair; @@ -46,7 +47,7 @@ public class OrderHttpIT { 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. diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/AccountIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/AccountIT.java index 81f98370..11d22f6f 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/AccountIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/AccountIT.java @@ -13,8 +13,10 @@ */ package org.shredzone.acme4j.it.pebble; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; +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.URL; diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderIT.java index 00b9564c..2226e810 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderIT.java @@ -15,8 +15,9 @@ package org.shredzone.acme4j.it.pebble; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import java.net.URI; import java.security.KeyPair; @@ -154,7 +155,7 @@ public class OrderIT extends PebbleITBase { KeyPair domainKeyPair = createKeyPair(); - Instant notBefore = Instant.now().truncatedTo(ChronoUnit.MILLIS); + Instant notBefore = Instant.now().truncatedTo(ChronoUnit.SECONDS); Instant notAfter = notBefore.plus(Duration.ofDays(20L)); Order order = account.newOrder() @@ -208,8 +209,8 @@ public class OrderIT extends PebbleITBase { Certificate certificate = order.getCertificate(); X509Certificate cert = certificate.getCertificate(); assertThat(cert, not(nullValue())); - assertThat(cert.getNotAfter(), not(nullValue())); - assertThat(cert.getNotBefore(), not(nullValue())); + assertThat(cert.getNotBefore().toInstant(), is(notNullValue())); + assertThat(cert.getNotAfter().toInstant(), is(notNullValue())); assertThat(cert.getSubjectX500Principal().getName(), containsString("CN=" + domain)); for (Authorization auth : order.getAuthorizations()) { @@ -260,12 +261,12 @@ public class OrderIT extends PebbleITBase { } @FunctionalInterface - private static interface Validator { + private interface Validator { Challenge prepare(Authorization auth) throws Exception; } @FunctionalInterface - private static interface Revoker { + private interface Revoker { void revoke(Session session, Certificate certificate, KeyPair keyPair, KeyPair domainKeyPair) throws Exception; } diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderWildcardIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderWildcardIT.java index 1e21adc2..0cc3d001 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderWildcardIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/OrderWildcardIT.java @@ -16,8 +16,9 @@ package org.shredzone.acme4j.it.pebble; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toList; import static org.awaitility.Awaitility.await; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.fail; import java.security.KeyPair; import java.security.cert.X509Certificate; diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/PebbleITBase.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/PebbleITBase.java index d2caf5ce..30f99888 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/PebbleITBase.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/PebbleITBase.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.it.pebble; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.net.URI; import java.net.URL; @@ -133,7 +133,7 @@ public abstract class PebbleITBase { } @FunctionalInterface - public static interface CleanupCallback { + public interface CleanupCallback { void cleanup() throws Exception; } diff --git a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/SessionIT.java b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/SessionIT.java index f22ef4aa..1baef4dd 100644 --- a/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/SessionIT.java +++ b/acme4j-it/src/test/java/org/shredzone/acme4j/it/pebble/SessionIT.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.it.pebble; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; import java.net.URI; diff --git a/acme4j-utils/src/test/java/org/shredzone/acme4j/util/CertificateUtilsTest.java b/acme4j-utils/src/test/java/org/shredzone/acme4j/util/CertificateUtilsTest.java index 9d43e9e0..095cbf9b 100644 --- a/acme4j-utils/src/test/java/org/shredzone/acme4j/util/CertificateUtilsTest.java +++ b/acme4j-utils/src/test/java/org/shredzone/acme4j/util/CertificateUtilsTest.java @@ -14,8 +14,8 @@ package org.shredzone.acme4j.util; import static java.time.temporal.ChronoUnit.SECONDS; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/acme4j-utils/src/test/java/org/shredzone/acme4j/util/KeyPairUtilsTest.java b/acme4j-utils/src/test/java/org/shredzone/acme4j/util/KeyPairUtilsTest.java index f6005925..ff14b144 100644 --- a/acme4j-utils/src/test/java/org/shredzone/acme4j/util/KeyPairUtilsTest.java +++ b/acme4j-utils/src/test/java/org/shredzone/acme4j/util/KeyPairUtilsTest.java @@ -13,8 +13,8 @@ */ package org.shredzone.acme4j.util; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; import java.io.IOException; import java.io.StringReader;