From 7b913e0cd410920aac6ebfc5b4031a32e4a9befc Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Fri, 21 Jun 2019 16:06:32 +0200 Subject: Surefire 2.22 and junit5 dependency management, with POC --- .../java/ai/vespa/hosted/api/MultiPartStreamerTest.java | 16 ++++++---------- .../test/java/ai/vespa/hosted/api/SignaturesTest.java | 14 +++++++------- 2 files changed, 13 insertions(+), 17 deletions(-) (limited to 'hosted-api/src/test') diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java index a55c0d91cd3..bfc544e82f8 100644 --- a/hosted-api/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java +++ b/hosted-api/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java @@ -1,9 +1,8 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.hosted.api; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import java.io.IOException; import java.net.URI; @@ -12,16 +11,13 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class MultiPartStreamerTest { - - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); +class MultiPartStreamerTest { @Test - public void test() throws IOException { - Path file = tmp.newFile().toPath(); + void test(@TempDir Path tmp) throws IOException { + Path file = tmp.resolve("file"); Files.write(file, new byte[]{0x48, 0x69}); MultiPartStreamer streamer = new MultiPartStreamer("My boundary"); diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/SignaturesTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/SignaturesTest.java index 0a0d4a48edf..6749fb902f9 100644 --- a/hosted-api/src/test/java/ai/vespa/hosted/api/SignaturesTest.java +++ b/hosted-api/src/test/java/ai/vespa/hosted/api/SignaturesTest.java @@ -1,7 +1,7 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.hosted.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -16,9 +16,9 @@ import java.time.ZoneOffset; import static ai.vespa.hosted.api.Signatures.sha256Digest; import static ai.vespa.hosted.api.Signatures.sha256Digester; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that messages can be signed and verified, and that the keys used for this can be parsed. @@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; * * @author jonmv */ -public class SignaturesTest { +class SignaturesTest { private static final String ecPemPublicKey = "-----BEGIN PUBLIC KEY-----\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuKVFA8dXk43kVfYKzkUqhEY2rDT9\n" + @@ -58,7 +58,7 @@ public class SignaturesTest { "∠( ᐛ 」∠)_").getBytes(UTF_8); @Test - public void testHashing() throws Exception { + void testHashing() throws Exception { byte[] hash1 = MessageDigest.getInstance("SHA-256").digest(message); byte[] hash2 = sha256Digest(() -> new ByteArrayInputStream(message)); DigestInputStream digester = sha256Digester(new ByteArrayInputStream(message)); @@ -70,7 +70,7 @@ public class SignaturesTest { } @Test - public void testSigning() { + void testSigning() { Clock clock = Clock.fixed(Instant.EPOCH, ZoneOffset.UTC); RequestSigner signer = new RequestSigner(ecPemPrivateKey, "myKey", clock); -- cgit v1.2.3