mirror of https://github.com/shred/acme4j
Fix unit tests for Java 9
parent
a7ce6a5f08
commit
8f7b45a69f
|
@ -27,6 +27,7 @@ import java.net.URL;
|
|||
import java.security.cert.X509Certificate;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -255,7 +256,7 @@ public class DefaultConnectionTest {
|
|||
*/
|
||||
@Test
|
||||
public void testHandleRetryAfterHeaderDate() throws AcmeException, IOException {
|
||||
Instant retryDate = Instant.now().plus(Duration.ofHours(10));
|
||||
Instant retryDate = Instant.now().plus(Duration.ofHours(10)).truncatedTo(ChronoUnit.MILLIS);
|
||||
String retryMsg = "absolute date";
|
||||
|
||||
when(mockUrlConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_ACCEPTED);
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.time.ZoneId;
|
|||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
|
@ -57,20 +55,10 @@ public class AcmeUtilsTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test sha-256 hash.
|
||||
* Test sha-256 hash and hex encode.
|
||||
*/
|
||||
@Test
|
||||
public void testSha256Hash() {
|
||||
byte[] hash = sha256hash("foobar");
|
||||
byte[] expected = DatatypeConverter.parseHexBinary("c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2");
|
||||
assertThat(hash, is(expected));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test hex encode.
|
||||
*/
|
||||
@Test
|
||||
public void testHexEncode() {
|
||||
public void testSha256HashHexEncode() {
|
||||
String hexEncode = hexEncode(sha256hash("foobar"));
|
||||
assertThat(hexEncode, is("c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue