Review all unit tests

- Replace deprecated org.junit.Assert.assertThat by org.hamcrest.MatcherAssert.assertThat
- Other minor checkstyle fixes
This commit is contained in:
Richard Körber
2020-10-24 18:05:06 +02:00
parent f0c50f43d2
commit 2cff3a5c90
47 changed files with 117 additions and 112 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;