From 49ca953b37abd172576a9da9f7efee0e9a7e9e08 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 17 Sep 2021 15:20:06 +0200 Subject: [PATCH] Update to JUnit 5 --- pom.xml | 49 ++++++++++--------- .../noise/tests/CipherStateTests.java | 10 ++-- .../noise/tests/Curve25519Tests.java | 8 ++- .../noise/tests/Curve448Tests.java | 8 ++- .../southernstorm/noise/tests/GHASHTests.java | 8 ++- .../southernstorm/noise/tests/HashTests.java | 8 ++- .../noise/tests/Poly1305Tests.java | 8 ++- .../noise/tests/RijndaelAESTests.java | 8 ++- .../noise/tests/UnitVectorTests.java | 5 +- .../noise/tests/VectorTests.java | 13 +++-- 10 files changed, 57 insertions(+), 68 deletions(-) diff --git a/pom.xml b/pom.xml index 42f6770..625e632 100644 --- a/pom.xml +++ b/pom.xml @@ -1,34 +1,22 @@ - - noise-java - com.southerstorm - 1.0-SNAPSHOT + + 4.0.0 - - UTF-8 - + noise-java + com.southerstorm + 1.0-SNAPSHOT + + + UTF-8 + - - - junit - junit - 4.13.1 - test - - - javax.xml.bind - jaxb-api - 2.3.0 - - maven-compiler-plugin - 3.7.0 + 3.8.1 1.8 1.8 @@ -36,4 +24,19 @@ + + + + org.junit.jupiter + junit-jupiter + 5.8.0 + test + + + javax.xml.bind + jaxb-api + 2.3.0 + + + diff --git a/src/test/java/com/southernstorm/noise/tests/CipherStateTests.java b/src/test/java/com/southernstorm/noise/tests/CipherStateTests.java index 239c891..17484bc 100644 --- a/src/test/java/com/southernstorm/noise/tests/CipherStateTests.java +++ b/src/test/java/com/southernstorm/noise/tests/CipherStateTests.java @@ -19,10 +19,10 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.protocol.CipherState; +import com.southernstorm.noise.protocol.Noise; import java.security.NoSuchAlgorithmException; import java.util.Arrays; @@ -30,10 +30,8 @@ import javax.crypto.BadPaddingException; import javax.crypto.ShortBufferException; -import org.junit.Test; - -import com.southernstorm.noise.protocol.CipherState; -import com.southernstorm.noise.protocol.Noise; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * Perform tests on the cipher algorithms used by Noise. diff --git a/src/test/java/com/southernstorm/noise/tests/Curve25519Tests.java b/src/test/java/com/southernstorm/noise/tests/Curve25519Tests.java index d54a887..49243dd 100644 --- a/src/test/java/com/southernstorm/noise/tests/Curve25519Tests.java +++ b/src/test/java/com/southernstorm/noise/tests/Curve25519Tests.java @@ -19,16 +19,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.crypto.Curve25519; import java.util.Arrays; -import org.junit.Test; - -import com.southernstorm.noise.crypto.Curve25519; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import org.junit.jupiter.api.Test; public class Curve25519Tests { diff --git a/src/test/java/com/southernstorm/noise/tests/Curve448Tests.java b/src/test/java/com/southernstorm/noise/tests/Curve448Tests.java index b1ec1a0..610c458 100644 --- a/src/test/java/com/southernstorm/noise/tests/Curve448Tests.java +++ b/src/test/java/com/southernstorm/noise/tests/Curve448Tests.java @@ -19,16 +19,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.crypto.Curve448; import java.util.Arrays; -import org.junit.Test; - -import com.southernstorm.noise.crypto.Curve448; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class Curve448Tests { diff --git a/src/test/java/com/southernstorm/noise/tests/GHASHTests.java b/src/test/java/com/southernstorm/noise/tests/GHASHTests.java index 36ad0a3..5bdc019 100644 --- a/src/test/java/com/southernstorm/noise/tests/GHASHTests.java +++ b/src/test/java/com/southernstorm/noise/tests/GHASHTests.java @@ -19,16 +19,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.crypto.GHASH; import java.util.Arrays; -import org.junit.Test; - -import com.southernstorm.noise.crypto.GHASH; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class GHASHTests { diff --git a/src/test/java/com/southernstorm/noise/tests/HashTests.java b/src/test/java/com/southernstorm/noise/tests/HashTests.java index 824d14b..8377b2d 100644 --- a/src/test/java/com/southernstorm/noise/tests/HashTests.java +++ b/src/test/java/com/southernstorm/noise/tests/HashTests.java @@ -19,18 +19,16 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.protocol.Noise; import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import org.junit.Test; - -import com.southernstorm.noise.protocol.Noise; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * Perform tests on the hash algorithms used by Noise. diff --git a/src/test/java/com/southernstorm/noise/tests/Poly1305Tests.java b/src/test/java/com/southernstorm/noise/tests/Poly1305Tests.java index 0c82782..adbe5f9 100644 --- a/src/test/java/com/southernstorm/noise/tests/Poly1305Tests.java +++ b/src/test/java/com/southernstorm/noise/tests/Poly1305Tests.java @@ -19,16 +19,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.crypto.Poly1305; import java.util.Arrays; -import org.junit.Test; - -import com.southernstorm.noise.crypto.Poly1305; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import org.junit.jupiter.api.Test; /** * Perform tests on the Poly1305 implementation in isolation from ChaChaPoly. diff --git a/src/test/java/com/southernstorm/noise/tests/RijndaelAESTests.java b/src/test/java/com/southernstorm/noise/tests/RijndaelAESTests.java index 10d1365..7e2be00 100644 --- a/src/test/java/com/southernstorm/noise/tests/RijndaelAESTests.java +++ b/src/test/java/com/southernstorm/noise/tests/RijndaelAESTests.java @@ -19,16 +19,14 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.noise.crypto.RijndaelAES; import java.util.Arrays; -import org.junit.Test; - -import com.southernstorm.noise.crypto.RijndaelAES; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * AES test cases to verify the fallback RijndaelAES implementation. diff --git a/src/test/java/com/southernstorm/noise/tests/UnitVectorTests.java b/src/test/java/com/southernstorm/noise/tests/UnitVectorTests.java index 14fc470..c06ade0 100644 --- a/src/test/java/com/southernstorm/noise/tests/UnitVectorTests.java +++ b/src/test/java/com/southernstorm/noise/tests/UnitVectorTests.java @@ -2,7 +2,8 @@ import java.io.InputStream; import java.net.URL; -import org.junit.Assert; + +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; public class UnitVectorTests { @@ -16,7 +17,7 @@ void testBasicVector() throws Exception { + "/tests/vector/noise-c-basic.txt").openStream()) { VectorTests vectorTests = new VectorTests(); vectorTests.processInputStream(stream); - Assert.assertEquals(vectorTests.getFailed(), 0); + assertEquals(vectorTests.getFailed(), 0); } } } diff --git a/src/test/java/com/southernstorm/noise/tests/VectorTests.java b/src/test/java/com/southernstorm/noise/tests/VectorTests.java index 3815eb0..70d894d 100644 --- a/src/test/java/com/southernstorm/noise/tests/VectorTests.java +++ b/src/test/java/com/southernstorm/noise/tests/VectorTests.java @@ -19,10 +19,12 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - package com.southernstorm.noise.tests; -import static org.junit.Assert.*; +import com.southernstorm.json.JsonReader; +import com.southernstorm.noise.protocol.CipherState; +import com.southernstorm.noise.protocol.CipherStatePair; +import com.southernstorm.noise.protocol.HandshakeState; import java.io.BufferedReader; import java.io.FileInputStream; @@ -37,10 +39,7 @@ import javax.crypto.ShortBufferException; import javax.xml.bind.DatatypeConverter; -import com.southernstorm.json.JsonReader; -import com.southernstorm.noise.protocol.CipherState; -import com.southernstorm.noise.protocol.CipherStatePair; -import com.southernstorm.noise.protocol.HandshakeState; +import static org.junit.jupiter.api.Assertions.*; /** * Executes Noise vector tests in JSON format. @@ -116,7 +115,7 @@ public void addMessage(TestMessage msg) private void assertSubArrayEquals(String msg, byte[] expected, byte[] actual) { for (int index = 0; index < expected.length; ++index) - assertEquals(msg + "[" + Integer.toString(index) + "]", expected[index], actual[index]); + assertEquals(expected[index], actual[index],msg + "[" + index + "]"); } /**