This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 993513e0618fb70b84b74087c57f0b5c68c1aae5 Author: Andrus Adamchik <[email protected]> AuthorDate: Sun May 10 11:42:03 2026 -0400 JUnit 5 migration of "cayenne-crypto" module --- cayenne-crypto/pom.xml | 7 +--- .../cayenne/crypto/CryptoModuleExtenderTest.java | 10 +++--- .../cayenne/crypto/CryptoModuleProviderTest.java | 4 +-- .../crypto/Runtime_AES128_GZIP_HMAC_IT.java | 4 +-- .../cayenne/crypto/Runtime_AES128_GZIP_IT.java | 30 ++++++++-------- .../cayenne/crypto/Runtime_AES128_HMAC_IT.java | 4 +-- .../apache/cayenne/crypto/Runtime_AES128_IT.java | 42 +++++++++++----------- .../apache/cayenne/crypto/Runtime_LazyInit_IT.java | 20 +++++------ .../crypto/cipher/DefaultCipherFactoryTest.java | 32 ++++++++--------- .../cayenne/crypto/key/JceksKeySourceTest.java | 17 ++++----- .../crypto/map/PatternColumnMapperTest.java | 8 ++--- .../crypto/transformer/bytes/CbcDecryptorTest.java | 14 ++++---- .../crypto/transformer/bytes/CbcEncryptorTest.java | 19 +++++----- .../bytes/DefaultBytesTransformerFactoryTest.java | 12 +++---- .../transformer/bytes/GzipDecryptorTest.java | 10 +++--- .../transformer/bytes/GzipEncryptorTest.java | 10 +++--- .../transformer/bytes/HeaderEncryptorTest.java | 6 ++-- .../crypto/transformer/bytes/HeaderTest.java | 23 ++++++------ .../crypto/transformer/bytes/HmacCreatorTest.java | 4 +-- .../transformer/bytes/HmacDecryptorTest.java | 4 +-- .../transformer/bytes/HmacEncryptorTest.java | 4 +-- .../transformer/value/BigDecimalConverterTest.java | 16 ++++----- .../transformer/value/BigIntegerConverterTest.java | 10 +++--- .../transformer/value/BooleanConverterTest.java | 19 +++++----- .../transformer/value/ByteConverterTest.java | 17 ++++----- .../transformer/value/DefaultEncryptorTest.java | 16 ++++----- .../value/DefaultValueTransformerFactoryIT.java | 30 ++++++++-------- .../transformer/value/DoubleConverterTest.java | 14 ++++---- .../transformer/value/DurationConverterTest.java | 10 +++--- .../transformer/value/FloatConverterTest.java | 14 ++++---- .../transformer/value/IntegerConverterTest.java | 21 +++++------ .../transformer/value/LocalDateConverterTest.java | 10 +++--- .../value/LocalDateTimeConverterTest.java | 18 +++++----- .../transformer/value/LocalTimeConverterTest.java | 10 +++--- .../transformer/value/LongConverterTest.java | 12 +++---- .../transformer/value/PeriodConverterTest.java | 10 +++--- .../transformer/value/ShortConverterTest.java | 19 +++++----- .../transformer/value/UtilDateConverterTest.java | 10 +++--- .../cayenne/crypto/unit/CryptoUnitUtilsTest.java | 6 ++-- .../crypto/unit/SwapBytesTransformerTest.java | 8 ++--- 40 files changed, 271 insertions(+), 283 deletions(-) diff --git a/cayenne-crypto/pom.xml b/cayenne-crypto/pom.xml index 3d54a44b2..e26e5f2f2 100644 --- a/cayenne-crypto/pom.xml +++ b/cayenne-crypto/pom.xml @@ -39,12 +39,7 @@ <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <scope>test</scope> - </dependency> - <dependency> +<dependency> <groupId>org.apache.cayenne.build-tools</groupId> <artifactId>cayenne-test-utilities</artifactId> <version>${project.version}</version> diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleExtenderTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleExtenderTest.java index b44d91f95..640941117 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleExtenderTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleExtenderTest.java @@ -24,18 +24,18 @@ import org.apache.cayenne.crypto.transformer.value.DefaultValueTransformerFactor import org.apache.cayenne.di.DIBootstrap; import org.apache.cayenne.di.Injector; import org.apache.cayenne.di.Module; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URL; import java.security.Key; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class CryptoModuleExtenderTest { @Test - public void testBuild_KeySource() { + public void build_KeySource() { URL ksUrl = JceksKeySourceTest.class.getResource(JceksKeySourceTest.KS1_JCEKS); Module m = b -> new CryptoModuleExtender(b).keyStore(ksUrl, JceksKeySourceTest.TEST_KEY_PASS, "k1") .valueTransformer(DefaultValueTransformerFactory.class); @@ -53,7 +53,7 @@ public class CryptoModuleExtenderTest { } @Test - public void testTypeName() { + public void typeName() { assertEquals("java.lang.String", CryptoModuleExtender.typeName(String.class)); assertEquals("byte", CryptoModuleExtender.typeName(Byte.TYPE)); assertEquals("java.lang.Byte", CryptoModuleExtender.typeName(Byte.class)); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleProviderTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleProviderTest.java index 31fc1831b..0054b2440 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleProviderTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/CryptoModuleProviderTest.java @@ -20,12 +20,12 @@ package org.apache.cayenne.crypto; import org.apache.cayenne.runtime.CayenneRuntimeModuleProvider; import org.apache.cayenne.unit.util.ModuleProviderChecker; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CryptoModuleProviderTest { @Test - public void testProviderPresent() { + public void providerPresent() { ModuleProviderChecker.testProviderPresent(CryptoModuleProvider.class, CayenneRuntimeModuleProvider.class); } } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_HMAC_IT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_HMAC_IT.java index 5b7b8d8e3..b594e0b8b 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_HMAC_IT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_HMAC_IT.java @@ -19,14 +19,14 @@ package org.apache.cayenne.crypto; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; /** * @since 4.0 */ public class Runtime_AES128_GZIP_HMAC_IT extends Runtime_AES128_GZIP_IT { - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(true, true); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_IT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_IT.java index a4803358d..e205ec2d6 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_IT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_GZIP_IT.java @@ -24,31 +24,31 @@ import org.apache.cayenne.crypto.db.Table8; import org.apache.cayenne.crypto.transformer.bytes.Header; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; import org.apache.cayenne.query.ObjectSelect; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { private static final int GZIP_THRESHOLD = 150; - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(true, false); } @Test - public void testInsert() throws SQLException { + public void insert() throws SQLException { ObjectContext context = runtime.newContext(); @@ -71,7 +71,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void testInsert_Small() throws SQLException { + public void insert_Small() throws SQLException { ObjectContext context = runtime.newContext(); @@ -93,7 +93,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void testInsert_MultipleObjects() throws SQLException { + public void insert_MultipleObjects() throws SQLException { ObjectContext context = runtime.newContext(); @@ -131,7 +131,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void test_SelectQuery() throws SQLException { + public void selectQuery() throws SQLException { // make sure compression is on... byte[] cryptoBytes1 = CryptoUnitUtils.bytesOfSize(GZIP_THRESHOLD + 101); @@ -165,7 +165,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void test_SelectQueryWithOptimisticLocking() throws SQLException { + public void selectQueryWithOptimisticLocking() throws SQLException { ObjectContext context = runtime.newContext(); StringBuilder builder = new StringBuilder(); @@ -191,7 +191,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void test_ScalarColumnQuery() throws SQLException { + public void scalarColumnQuery() throws SQLException { // make sure compression is on... byte[] cryptoBytes1 = CryptoUnitUtils.bytesOfSize(GZIP_THRESHOLD + 101); byte[] cryptoBytes2 = CryptoUnitUtils.bytesOfSize(GZIP_THRESHOLD + 102); @@ -224,7 +224,7 @@ public class Runtime_AES128_GZIP_IT extends Runtime_AES128_Base { } @Test - public void test_MultipleColumnsQuery() throws SQLException { + public void multipleColumnsQuery() throws SQLException { // make sure compression is on... byte[] cryptoBytes1 = CryptoUnitUtils.bytesOfSize(GZIP_THRESHOLD + 101); byte[] cryptoBytes2 = CryptoUnitUtils.bytesOfSize(GZIP_THRESHOLD + 102); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_HMAC_IT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_HMAC_IT.java index dec357249..bf6117b31 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_HMAC_IT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_HMAC_IT.java @@ -19,14 +19,14 @@ package org.apache.cayenne.crypto; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; /** * @since 4.0 */ public class Runtime_AES128_HMAC_IT extends Runtime_AES128_IT { - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(false, true); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_IT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_IT.java index 336d9a7a0..9e38fb891 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_IT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_AES128_IT.java @@ -31,23 +31,23 @@ import org.apache.cayenne.crypto.transformer.value.IntegerConverter; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; import org.apache.cayenne.exp.property.PropertyFactory; import org.apache.cayenne.query.ObjectSelect; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Runtime_AES128_IT extends Runtime_AES128_Base { - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(false, false); } @Test - public void testInsert() throws SQLException { + public void insert() throws SQLException { ObjectContext context = runtime.newContext(); @@ -63,7 +63,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void testInsert_Numeric() throws SQLException { + public void insert_Numeric() throws SQLException { ObjectContext context = runtime.newContext(); @@ -79,7 +79,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void testInsert_MultipleObjects() throws SQLException { + public void insert_MultipleObjects() throws SQLException { ObjectContext context = runtime.newContext(); @@ -111,7 +111,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_SelectQuery() { + public void selectQuery() { ObjectContext context = runtime.newContext(); @@ -142,7 +142,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { @Test - public void test_SelectNumeric() { + public void selectNumeric() { ObjectContext context = runtime.newContext(); @@ -160,7 +160,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQueryObject() { + public void columnQueryObject() { ObjectContext context = runtime.newContext(); @@ -179,7 +179,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQueryObjectWithPlainScalar() { + public void columnQueryObjectWithPlainScalar() { ObjectContext context = runtime.newContext(); @@ -202,7 +202,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQueryObjectWithEncryptedScalar() { + public void columnQueryObjectWithEncryptedScalar() { ObjectContext context = runtime.newContext(); @@ -226,7 +226,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void testColumnQueryWithRelationshipWithTheSameNames() { + public void columnQueryWithRelationshipWithTheSameNames() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); @@ -261,7 +261,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void testSelectWith2Objects() { + public void selectWith2Objects() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); @@ -290,7 +290,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void testObjectSelectWithPrefetch() { + public void objectSelectWithPrefetch() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); @@ -317,7 +317,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQuerySingleScalar() { + public void columnQuerySingleScalar() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); @@ -334,7 +334,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQuerySingleScalarNull() { + public void columnQuerySingleScalarNull() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); @@ -351,7 +351,7 @@ public class Runtime_AES128_IT extends Runtime_AES128_Base { } @Test - public void test_ColumnQueryMultipleScalars() { + public void columnQueryMultipleScalars() { ObjectContext context = runtime.newContext(); Table1 t1 = context.newObject(Table1.class); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_LazyInit_IT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_LazyInit_IT.java index 9ed97795b..4a781f0a0 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_LazyInit_IT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/Runtime_LazyInit_IT.java @@ -26,19 +26,19 @@ import org.apache.cayenne.di.Inject; import org.apache.cayenne.di.Module; import org.apache.cayenne.query.ObjectSelect; import org.apache.cayenne.runtime.CayenneRuntime; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.security.Key; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class Runtime_LazyInit_IT extends Runtime_AES128_Base { protected static boolean UNLOCKED; - @Before + @BeforeEach public void before() throws Exception { setUp(false, false); UNLOCKED = false; @@ -55,7 +55,7 @@ public class Runtime_LazyInit_IT extends Runtime_AES128_Base { } @Test - public void testCryptoLocked() { + public void cryptoLocked() { assertFalse(UNLOCKED); @@ -68,23 +68,19 @@ public class Runtime_LazyInit_IT extends Runtime_AES128_Base { } @Test - public void testCryptoLocked_Unlocked() { + public void cryptoLocked_Unlocked() { assertFalse(UNLOCKED); - try { + assertThrows(CayenneRuntimeException.class, () -> { Table1 t1 = runtime.newContext().newObject(Table1.class); t1.setPlainInt(56); t1.setCryptoInt(77); t1.setPlainString("XX"); t1.setCryptoString("YY"); t1.getObjectContext().commitChanges(); - - fail("Must have thrown on crypto access"); - } catch (CayenneRuntimeException e) { - // expected - } + }); UNLOCKED = true; diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/cipher/DefaultCipherFactoryTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/cipher/DefaultCipherFactoryTest.java index af45b517c..22ed67a83 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/cipher/DefaultCipherFactoryTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/cipher/DefaultCipherFactoryTest.java @@ -18,8 +18,9 @@ ****************************************************************/ package org.apache.cayenne.crypto.cipher; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; import java.util.Map; @@ -28,12 +29,12 @@ import javax.crypto.Cipher; import org.apache.cayenne.crypto.CayenneCryptoException; import org.apache.cayenne.crypto.CryptoConstants; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DefaultCipherFactoryTest { @Test - public void testConstructor() { + public void constructor() { Map<String, String> properties = new HashMap<>(); properties.put(CryptoConstants.CIPHER_ALGORITHM, "AES"); @@ -44,32 +45,29 @@ public class DefaultCipherFactoryTest { assertEquals("AES/CBC/PKCS5Padding", f.transformation); } - @Test(expected = CayenneCryptoException.class) - public void testConstructor_Missing3Props() { + @Test + public void constructor_Missing3Props() { Map<String, String> properties = new HashMap<>(); - - new DefaultCipherFactory(properties); + assertThrows(CayenneCryptoException.class, () -> new DefaultCipherFactory(properties)); } - @Test(expected = CayenneCryptoException.class) - public void testConstructor_Missing2Props() { + @Test + public void constructor_Missing2Props() { Map<String, String> properties = new HashMap<>(); properties.put(CryptoConstants.CIPHER_ALGORITHM, "AES"); - - new DefaultCipherFactory(properties); + assertThrows(CayenneCryptoException.class, () -> new DefaultCipherFactory(properties)); } - @Test(expected = CayenneCryptoException.class) - public void testConstructor_Missing1Props() { + @Test + public void constructor_Missing1Props() { Map<String, String> properties = new HashMap<>(); properties.put(CryptoConstants.CIPHER_ALGORITHM, "AES"); properties.put(CryptoConstants.CIPHER_MODE, "CBC"); - - new DefaultCipherFactory(properties); + assertThrows(CayenneCryptoException.class, () -> new DefaultCipherFactory(properties)); } @Test - public void testGetCipher() { + public void getCipher() { Map<String, String> properties = new HashMap<>(); properties.put(CryptoConstants.CIPHER_ALGORITHM, "AES"); properties.put(CryptoConstants.CIPHER_MODE, "CBC"); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/key/JceksKeySourceTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/key/JceksKeySourceTest.java index 6f183c32f..6bf3c101b 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/key/JceksKeySourceTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/key/JceksKeySourceTest.java @@ -18,9 +18,10 @@ ****************************************************************/ package org.apache.cayenne.crypto.key; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.net.URL; import java.security.Key; @@ -29,22 +30,22 @@ import java.util.Map; import org.apache.cayenne.crypto.CayenneCryptoException; import org.apache.cayenne.crypto.CryptoConstants; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JceksKeySourceTest { public static final char[] TEST_KEY_PASS = "testkeypass".toCharArray(); public static final String KS1_JCEKS = "ks1.jceks"; - @Test(expected = CayenneCryptoException.class) - public void testConstructor_NoUrl() { + @Test + public void constructor_NoUrl() { Map<String, String> props = new HashMap<>(); Map<String, char[]> creds = new HashMap<>(); - new JceksKeySource(props, creds); + assertThrows(CayenneCryptoException.class, () -> new JceksKeySource(props, creds)); } @Test - public void testGetKey_JCEKS_DES() { + public void getKey_JCEKS_DES() { URL url = getClass().getResource(KS1_JCEKS); assertNotNull(url); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/map/PatternColumnMapperTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/map/PatternColumnMapperTest.java index 46838d613..17134f869 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/map/PatternColumnMapperTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/map/PatternColumnMapperTest.java @@ -18,16 +18,16 @@ ****************************************************************/ package org.apache.cayenne.crypto.map; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.cayenne.map.DbAttribute; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class PatternColumnMapperTest { @Test - public void testIsEncrypted() { + public void isEncrypted() { PatternColumnMapper mapper = new PatternColumnMapper("^bla_"); assertTrue(mapper.isEncrypted(new DbAttribute("bla_"))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcDecryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcDecryptorTest.java index f6e5716dc..c2fbe3cf1 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcDecryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcDecryptorTest.java @@ -18,8 +18,8 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -34,15 +34,15 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class CbcDecryptorTest { private Cipher cipher; private Key key; - @Before + @BeforeEach public void before() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { byte[] keyBytes = CryptoUnitUtils.hexToBytes("a4cb499fa31a6a228e16b7e4741d4fa3"); this.key = new SecretKeySpec(keyBytes, "AES"); @@ -52,7 +52,7 @@ public class CbcDecryptorTest { } @Test - public void testIv() { + public void iv() { CbcDecryptor decryptor = new CbcDecryptor(cipher); @@ -64,7 +64,7 @@ public class CbcDecryptorTest { } @Test - public void testDecrypt() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, + public void decrypt() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { CbcDecryptor decryptor = new CbcDecryptor(cipher); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcEncryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcEncryptorTest.java index 82c2fa480..f2c7da785 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcEncryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/CbcEncryptorTest.java @@ -18,11 +18,11 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; -import java.io.UnsupportedEncodingException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; @@ -38,24 +38,21 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.cayenne.crypto.CayenneCryptoException; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CbcEncryptorTest { - @Test(expected = CayenneCryptoException.class) - public void testConstructor() throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException { - + @Test + public void constructor() throws NoSuchAlgorithmException, NoSuchPaddingException { byte[] iv = { 1, 2, 3, 4, 5, 6 }; Key key = mock(Key.class); Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); assertEquals(8, cipher.getBlockSize()); - - // must throw as IV sie and block size are different - new CbcEncryptor(cipher, key, iv); + assertThrows(CayenneCryptoException.class, () -> new CbcEncryptor(cipher, key, iv)); } @Test - public void testEncrypt_AES() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, + public void encrypt_AES() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { byte[] ivBytes = CryptoUnitUtils.hexToBytes("0591849d87c93414f4405d32f4d69220"); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/DefaultBytesTransformerFactoryTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/DefaultBytesTransformerFactoryTest.java index da8462238..36d8beb8c 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/DefaultBytesTransformerFactoryTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/DefaultBytesTransformerFactoryTest.java @@ -18,10 +18,10 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -30,12 +30,12 @@ import java.util.Map; import org.apache.cayenne.crypto.CryptoConstants; import org.apache.cayenne.crypto.key.KeySource; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DefaultBytesTransformerFactoryTest { @Test - public void testCreateEncryptionHeader() { + public void createEncryptionHeader() { Map<String, String> properties = new HashMap<>(); KeySource keySource = mock(KeySource.class); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipDecryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipDecryptorTest.java index fe3cbd3a8..afd6ba1ec 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipDecryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipDecryptorTest.java @@ -19,19 +19,19 @@ package org.apache.cayenne.crypto.transformer.bytes; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class GzipDecryptorTest { @Test - public void testGunzip() throws IOException { + public void gunzip() throws IOException { byte[] input1 = CryptoUnitUtils.hexToBytes("1f8b0800000000000000f348cdc9c957f0409000a91a078c11000000"); byte[] output1 = GzipDecryptor.gunzip(input1); @@ -41,7 +41,7 @@ public class GzipDecryptorTest { } @Test - public void testGunzip_Large() throws IOException { + public void gunzip_Large() throws IOException { byte[] input1 = readResource("plain.gz"); byte[] output1 = GzipDecryptor.gunzip(input1); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipEncryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipEncryptorTest.java index 0560f1b93..64fe42c7c 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipEncryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/GzipEncryptorTest.java @@ -18,8 +18,8 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; @@ -29,13 +29,13 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; public class GzipEncryptorTest { @Test - public void testGzip() throws IOException { + public void gzip() throws IOException { byte[] input1 = "Hello Hello Hello".getBytes(StandardCharsets.UTF_8); byte[] output1 = GzipEncryptor.gzip(input1); @@ -51,7 +51,7 @@ public class GzipEncryptorTest { } @Test - public void testEncrypt() { + public void encrypt() { BytesEncryptor delegate = mock(BytesEncryptor.class); when(delegate.encrypt(any(byte[].class), anyInt(), any(byte[].class))).thenAnswer((Answer<byte[]>) invocation -> { diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderEncryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderEncryptorTest.java index c26c273c4..c15d96c21 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderEncryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderEncryptorTest.java @@ -18,17 +18,17 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import java.io.UnsupportedEncodingException; import org.apache.cayenne.crypto.unit.SwapBytesTransformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HeaderEncryptorTest { @Test - public void testTransform() throws UnsupportedEncodingException { + public void transform() throws UnsupportedEncodingException { Header encryptionHeader = Header.create("mykey", false, false); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderTest.java index 7288e5223..eb1b6c365 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HeaderTest.java @@ -18,17 +18,18 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.bytes; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.cayenne.crypto.CayenneCryptoException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class HeaderTest { @Test - public void testSetCompressed() { + public void setCompressed() { assertEquals(1, Header.setCompressed((byte) 0, true)); assertEquals(0, Header.setCompressed((byte) 0, false)); @@ -43,7 +44,7 @@ public class HeaderTest { } @Test - public void testCreate_WithKeyName() { + public void create_WithKeyName() { Header h1 = Header.create("bcd", false, false); Header h2 = Header.create("bc", true, false); @@ -65,19 +66,17 @@ public class HeaderTest { assertTrue(h4.haveHMAC()); } - @Test(expected = CayenneCryptoException.class) - public void testCreate_WithKeyName_TooLong() { - + @Test + public void create_WithKeyName_TooLong() { StringBuilder buf = new StringBuilder(); for (int i = 0; i < Byte.MAX_VALUE + 1; i++) { buf.append("a"); } - - Header.create(buf.toString(), false, false); + assertThrows(CayenneCryptoException.class, () -> Header.create(buf.toString(), false, false)); } @Test - public void testCreate_WithData() { + public void create_WithData() { byte[] input1 = { 'C', 'C', '1', 9, 0, 'a', 'b', 'c', 'd', 'e' }; Header h1 = Header.create(input1, 0); assertEquals("abcd", h1.getKeyName()); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacCreatorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacCreatorTest.java index 6d65b59d4..c5c0ee5ad 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacCreatorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacCreatorTest.java @@ -23,11 +23,11 @@ import java.security.Key; import javax.crypto.spec.SecretKeySpec; import org.apache.cayenne.crypto.unit.CryptoUnitUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyByte; import static org.mockito.ArgumentMatchers.anyInt; diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacDecryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacDecryptorTest.java index c4340f8c7..7e9bccaa0 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacDecryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacDecryptorTest.java @@ -22,9 +22,9 @@ package org.apache.cayenne.crypto.transformer.bytes; import java.security.Key; import org.apache.cayenne.crypto.unit.SwapBytesTransformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacEncryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacEncryptorTest.java index 23c8dda1e..8824a96f3 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacEncryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/bytes/HmacEncryptorTest.java @@ -20,9 +20,9 @@ package org.apache.cayenne.crypto.transformer.bytes; import org.apache.cayenne.crypto.unit.SwapBytesTransformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigDecimalConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigDecimalConverterTest.java index acdc5a751..fceb38c4e 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigDecimalConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigDecimalConverterTest.java @@ -18,12 +18,12 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.math.BigInteger; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BigDecimalConverterTest { @@ -31,42 +31,42 @@ public class BigDecimalConverterTest { private BigInteger negativeInt = BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.valueOf(Long.MIN_VALUE)); @Test - public void testConverter() { + public void converter() { BigDecimal originalValue = new BigDecimal(positiveInt); BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Negative() { + public void converter_Negative() { BigDecimal originalValue = new BigDecimal(negativeInt); BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Zero() { + public void converter_Zero() { BigDecimal originalValue = BigDecimal.ZERO; BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Decimal_PositiveScale() { + public void converter_Decimal_PositiveScale() { BigDecimal originalValue = new BigDecimal(negativeInt, Integer.MAX_VALUE / 2); BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Decimal_NegativeScale() { + public void converter_Decimal_NegativeScale() { BigDecimal originalValue = new BigDecimal(negativeInt, Integer.MIN_VALUE / 2); BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Decimal_Irrational() { + public void converter_Decimal_Irrational() { BigDecimal originalValue = new BigDecimal(Math.sqrt(2)); BigDecimalConverter converter = new BigDecimalConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigIntegerConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigIntegerConverterTest.java index dbeffce17..1da181bd9 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigIntegerConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BigIntegerConverterTest.java @@ -18,11 +18,11 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigInteger; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BigIntegerConverterTest { @@ -30,19 +30,19 @@ public class BigIntegerConverterTest { private BigInteger negativeInt = BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.valueOf(Long.MIN_VALUE)); @Test - public void testConverter() { + public void converter() { BigIntegerConverter converter = new BigIntegerConverter(); assertEquals(positiveInt, converter.fromBytes(converter.toBytes(positiveInt))); } @Test - public void testConverter_Negative() { + public void converter_Negative() { BigIntegerConverter converter = new BigIntegerConverter(); assertEquals(negativeInt, converter.fromBytes(converter.toBytes(negativeInt))); } @Test - public void testConverter_Zero() { + public void converter_Zero() { BigInteger originalValue = BigInteger.ZERO; BigIntegerConverter converter = new BigIntegerConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BooleanConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BooleanConverterTest.java index e28afaa16..0309249ec 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BooleanConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/BooleanConverterTest.java @@ -18,28 +18,27 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import java.text.ParseException; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class BooleanConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(true, BooleanConverter.INSTANCE.fromBytes(new byte[]{1})); assertEquals(false, BooleanConverter.INSTANCE.fromBytes(new byte[]{0})); } - @Test(expected = IllegalArgumentException.class) - public void testFromBytes_InvalidArray() { - BooleanConverter.INSTANCE.fromBytes(new byte[]{1, 0}); + @Test + public void fromBytes_InvalidArray() { + assertThrows(IllegalArgumentException.class, () -> BooleanConverter.INSTANCE.fromBytes(new byte[]{1, 0})); } @Test - public void testToBytes() throws ParseException { + public void toBytes() { assertArrayEquals(new byte[]{0}, BooleanConverter.INSTANCE.toBytes(false)); assertArrayEquals(new byte[]{1}, BooleanConverter.INSTANCE.toBytes(true)); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ByteConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ByteConverterTest.java index df34bcfd6..4582e1373 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ByteConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ByteConverterTest.java @@ -19,26 +19,27 @@ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ByteConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(Byte.valueOf((byte) 6), ByteConverter.INSTANCE.fromBytes(new byte[]{6})); assertEquals(Byte.valueOf((byte) -7), ByteConverter.INSTANCE.fromBytes(new byte[]{-7})); } - @Test(expected = IllegalArgumentException.class) - public void testFromBytes_TooLong() { - ByteConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4}); + @Test + public void fromBytes_TooLong() { + assertThrows(IllegalArgumentException.class, () -> ByteConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{6}, ByteConverter.INSTANCE.toBytes((byte) 6)); assertArrayEquals(new byte[]{-7}, ByteConverter.INSTANCE.toBytes((byte) -7)); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultEncryptorTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultEncryptorTest.java index fa4eb589c..17c0402f4 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultEncryptorTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultEncryptorTest.java @@ -29,24 +29,24 @@ import java.util.Base64; import org.apache.cayenne.crypto.transformer.bytes.BytesDecryptor; import org.apache.cayenne.crypto.transformer.bytes.BytesEncryptor; import org.apache.cayenne.crypto.unit.SwapBytesTransformer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DefaultEncryptorTest { private BytesEncryptor encryptor; private BytesDecryptor decryptor; - @Before + @BeforeEach public void before() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { this.encryptor = SwapBytesTransformer.encryptor(); this.decryptor = SwapBytesTransformer.decryptor(); } @Test - public void testEncrypt_BytesToBytes() throws IllegalBlockSizeException, BadPaddingException { + public void encrypt_BytesToBytes() throws IllegalBlockSizeException, BadPaddingException { DefaultValueEncryptor e = new DefaultValueEncryptor(BytesToBytesConverter.INSTANCE, BytesToBytesConverter.INSTANCE); @@ -65,14 +65,14 @@ public class DefaultEncryptorTest { } @Test - public void testEncrypt_BytesToBytes_null() throws IllegalBlockSizeException, BadPaddingException { + public void encrypt_BytesToBytes_null() throws IllegalBlockSizeException, BadPaddingException { DefaultValueEncryptor e = new DefaultValueEncryptor(BytesToBytesConverter.INSTANCE, BytesToBytesConverter.INSTANCE); assertNull(e.encrypt(encryptor, null)); } @Test - public void testEncrypt_StringToBytes() throws UnsupportedEncodingException, IllegalBlockSizeException, + public void encrypt_StringToBytes() throws UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { DefaultValueEncryptor e = new DefaultValueEncryptor(Utf8StringConverter.INSTANCE, BytesToBytesConverter.INSTANCE); @@ -92,7 +92,7 @@ public class DefaultEncryptorTest { } @Test - public void testEncrypt_StringToString() throws UnsupportedEncodingException, IllegalBlockSizeException, + public void encrypt_StringToString() throws UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { DefaultValueEncryptor e = new DefaultValueEncryptor(Utf8StringConverter.INSTANCE, Base64StringConverter.INSTANCE); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultValueTransformerFactoryIT.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultValueTransformerFactoryIT.java index 5c023f2bc..4c2e99bf9 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultValueTransformerFactoryIT.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DefaultValueTransformerFactoryIT.java @@ -22,9 +22,9 @@ import org.apache.cayenne.crypto.key.KeySource; import org.apache.cayenne.map.DbAttribute; import org.apache.cayenne.map.DbEntity; import org.apache.cayenne.runtime.CayenneRuntime; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.math.BigInteger; @@ -33,10 +33,10 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -51,7 +51,7 @@ public class DefaultValueTransformerFactoryIT { private DefaultValueTransformerFactory f; - @BeforeClass + @BeforeAll public static void beforeClass() throws Exception { CayenneRuntime runtime = CayenneRuntime.builder().addConfig("cayenne-crypto.xml").build(); t1 = runtime.getChannel().getEntityResolver().getDbEntity("TABLE1"); @@ -63,13 +63,13 @@ public class DefaultValueTransformerFactoryIT { objectToBytes = getDefaultObjectConverters(); } - @Before + @BeforeEach public void before() { f = new DefaultValueTransformerFactory(mock(KeySource.class), dbToBytes, objectToBytes); } @Test - public void testGetJavaType() { + public void getJavaType() { DbAttribute t1_ct = t1.getAttribute("CRYPTO_STRING"); assertEquals("java.lang.String", f.getJavaType(t1_ct)); @@ -96,7 +96,7 @@ public class DefaultValueTransformerFactoryIT { } @Test - public void testGetAmbiguousJavaType() { + public void getAmbiguousJavaType() { // this one have two bound ObjAttributes, warn should be in log DbAttribute a1 = t5.getAttribute("CRYPTO_INT1"); assertEquals("java.lang.String", f.getJavaType(a1)); @@ -115,7 +115,7 @@ public class DefaultValueTransformerFactoryIT { } @Test - public void testCreateEncryptor() { + public void createEncryptor() { DbAttribute t1_ct = t1.getAttribute("CRYPTO_STRING"); @@ -135,7 +135,7 @@ public class DefaultValueTransformerFactoryIT { } @Test - public void testCreateDecryptor() { + public void createDecryptor() { DbAttribute t1_ct = t1.getAttribute("CRYPTO_STRING"); @@ -163,7 +163,7 @@ public class DefaultValueTransformerFactoryIT { } @Test - public void testEncryptor() { + public void encryptor() { DbAttribute t1_ct = t1.getAttribute("CRYPTO_STRING"); @@ -181,7 +181,7 @@ public class DefaultValueTransformerFactoryIT { } @Test - public void testDecryptor() { + public void decryptor() { DbAttribute t1_ct = t1.getAttribute("CRYPTO_STRING"); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DoubleConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DoubleConverterTest.java index 4e421f009..ed7834350 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DoubleConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DoubleConverterTest.java @@ -18,42 +18,42 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DoubleConverterTest { @Test - public void testConverter() { + public void converter() { Double originalValue = 36.6d; DoubleConverter converter = new DoubleConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Negative() { + public void converter_Negative() { Double originalValue = -36.6d; DoubleConverter converter = new DoubleConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_MaxValue() { + public void converter_MaxValue() { Double originalValue = Double.MAX_VALUE; DoubleConverter converter = new DoubleConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_MinValue() { + public void converter_MinValue() { Double originalValue = Double.MIN_VALUE; DoubleConverter converter = new DoubleConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Zero() { + public void converter_Zero() { Double originalValue = 0d; DoubleConverter converter = new DoubleConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DurationConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DurationConverterTest.java index 18512e82b..44f5bf8dd 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DurationConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/DurationConverterTest.java @@ -21,10 +21,10 @@ package org.apache.cayenne.crypto.transformer.value; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @since 4.2 @@ -32,14 +32,14 @@ import static org.junit.Assert.assertEquals; public class DurationConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(Duration.ofDays(10), DurationConverter.INSTANCE.fromBytes(new byte[]{51, 127, -104, 0})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[] {51, 127, -104, 0}, DurationConverter.INSTANCE.toBytes(Duration.ofDays(10))); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/FloatConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/FloatConverterTest.java index e3bc93d96..77772b40b 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/FloatConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/FloatConverterTest.java @@ -18,42 +18,42 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FloatConverterTest { @Test - public void testConverter() { + public void converter() { Float originalValue = 36.6f; FloatConverter converter = new FloatConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Negative() { + public void converter_Negative() { Float originalValue = -36.6f; FloatConverter converter = new FloatConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_MaxValue() { + public void converter_MaxValue() { Float originalValue = Float.MAX_VALUE; FloatConverter converter = new FloatConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_MinValue() { + public void converter_MinValue() { Float originalValue = Float.MIN_VALUE; FloatConverter converter = new FloatConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); } @Test - public void testConverter_Zero() { + public void converter_Zero() { Float originalValue = 0f; FloatConverter converter = new FloatConverter(); assertEquals(originalValue, converter.fromBytes(converter.toBytes(originalValue))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/IntegerConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/IntegerConverterTest.java index 5f42f4a52..5d6991cf2 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/IntegerConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/IntegerConverterTest.java @@ -18,37 +18,38 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class IntegerConverterTest { @Test - public void testFromBytes_InByteRange() { + public void fromBytes_InByteRange() { assertEquals(Integer.valueOf(6), new IntegerConverter().fromBytes(new byte[]{6})); } @Test - public void testFromBytes_InShortRange() { + public void fromBytes_InShortRange() { assertEquals(Integer.valueOf(1542), new IntegerConverter().fromBytes(new byte[]{6, 6})); } @Test - public void testFromBytes_InIntRange() { + public void fromBytes_InIntRange() { // 16 + 256*7 + 256*256* 6 assertEquals(Integer.valueOf(395024), new IntegerConverter().fromBytes(new byte[]{0, 6, 7, 16})); } - @Test(expected = IllegalArgumentException.class) - public void testFromBytes_TooLong() { - IntegerConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4}); + @Test + public void fromBytes_TooLong() { + assertThrows(IllegalArgumentException.class, () -> IntegerConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{127, -1, -1, -2}, new IntegerConverter().toBytes(Integer.MAX_VALUE - 1)); assertArrayEquals(new byte[]{127, -2}, new IntegerConverter().toBytes(Short.MAX_VALUE - 1)); assertArrayEquals(new byte[]{-7}, new IntegerConverter().toBytes(-7)); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateConverterTest.java index 29a94d00c..d31c63994 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateConverterTest.java @@ -18,23 +18,23 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.LocalDate; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalDateConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(LocalDate.of(2015, 1, 7), LocalDateConverter.INSTANCE.fromBytes(new byte[]{64, 58})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{64, 58}, LocalDateConverter.INSTANCE.toBytes(LocalDate.of(2015, 1, 7))); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java index ae2bed311..da64bd629 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalDateTimeConverterTest.java @@ -18,51 +18,51 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalDateTimeConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(LocalDateTime.of(2015, 1, 7, 11, 0, 2), LocalDateTimeConverter.INSTANCE.fromBytes(new byte[]{2, 64, 58, 0, 0, 36, 4, -113, 36, 116, 0})); } @Test - public void testToBytes() { + public void toBytes() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.of(2015, 1, 7, 11, 0, 2)); assertArrayEquals(new byte[]{2, 64, 58, 0, 0, 36, 4, -113, 36, 116, 0}, bytes); } @Test - public void testToBytesBig() { + public void toBytesBig() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.MAX); assertArrayEquals(new byte[]{8, 0, 0, 0, 85, 10, 27, 72, -9, 0, 0, 78, -108, -111, 78, -1, -1}, bytes); } @Test - public void testFromBytesBig() { + public void fromBytesBig() { LocalDateTime localDateTime = LocalDateTimeConverter.INSTANCE .fromBytes(new byte[]{8, 0, 0, 0, 85, 10, 27, 72, -9, 0, 0, 78, -108, -111, 78, -1, -1}); assertEquals(LocalDateTime.MAX, localDateTime); } @Test - public void testToBytesSmall() { + public void toBytesSmall() { byte[] bytes = LocalDateTimeConverter.INSTANCE .toBytes(LocalDateTime.of(0, 1, 1, 0, 0, 0)); assertArrayEquals(new byte[]{4, -1, -11, 5, 88, 0}, bytes); } @Test - public void testFromBytesSmall() { + public void fromBytesSmall() { LocalDateTime localDateTime = LocalDateTimeConverter.INSTANCE .fromBytes(new byte[]{4, -1, -11, 5, 88, 0}); assertEquals(LocalDateTime.of(0, 1, 1, 0, 0, 0), localDateTime); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalTimeConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalTimeConverterTest.java index fcf30ab79..d0a987aef 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalTimeConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LocalTimeConverterTest.java @@ -18,17 +18,17 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.LocalTime; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalTimeConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(LocalTime.of(11, 0, 2), LocalTimeConverter.INSTANCE.fromBytes(new byte[]{0, 0, 36, 4, -113, 36, 116, 0})); @@ -37,7 +37,7 @@ public class LocalTimeConverterTest { } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{0, 0, 36, 4, -113, 36, 116, 0}, LocalTimeConverter.INSTANCE.toBytes(LocalTime.of(11, 0, 2))); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LongConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LongConverterTest.java index ff250d646..30ec68493 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LongConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/LongConverterTest.java @@ -18,29 +18,29 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LongConverterTest { @Test - public void testFromBytes_InIntRange() { + public void fromBytes_InIntRange() { // 256*256* 6 + 256*7 + 16 assertEquals(Long.valueOf(395024L), new LongConverter().fromBytes(new byte[]{0, 6, 7, 16})); } @Test - public void testFromBytes_InLongRange() { + public void fromBytes_InLongRange() { // 6*256*256*256*256 + 7*256*256*256 + 16*256*256 + 17*256 + 99 assertEquals(Long.valueOf(25888297315L), new LongConverter().fromBytes(new byte[]{0, 0, 0, 6, 7, 16, 17, 99})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{127, -1, -1, -1, -1, -1, -1, -2}, new LongConverter().toBytes((long) (Long.MAX_VALUE - 1L))); assertArrayEquals(new byte[]{127, -1, -1, -2}, new LongConverter().toBytes((long) (Integer.MAX_VALUE - 1))); assertArrayEquals(new byte[]{127, -2}, new LongConverter().toBytes(Short.MAX_VALUE - 1L)); diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/PeriodConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/PeriodConverterTest.java index 06371abae..0d2f91c51 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/PeriodConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/PeriodConverterTest.java @@ -21,10 +21,10 @@ package org.apache.cayenne.crypto.transformer.value; import java.time.Period; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @since 4.2 @@ -32,13 +32,13 @@ import static org.junit.Assert.assertEquals; public class PeriodConverterTest { @Test - public void testFromBytes() { + public void fromBytes() { assertEquals(Period.of(10, 5, 20), PeriodConverter.INSTANCE.fromBytes(new byte[]{80, 49, 48, 89, 53, 77, 50, 48, 68})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{80, 49, 48, 89, 53, 77, 50, 48, 68}, PeriodConverter.INSTANCE.toBytes(Period.of(10, 5, 20))); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ShortConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ShortConverterTest.java index 6b456362b..c337e4370 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ShortConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/ShortConverterTest.java @@ -18,30 +18,31 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ShortConverterTest { @Test - public void testFromBytes_InByteRange() { + public void fromBytes_InByteRange() { assertEquals(Short.valueOf((short) 6), ShortConverter.INSTANCE.fromBytes(new byte[]{6})); } @Test - public void testFromBytes_InShortRange() { + public void fromBytes_InShortRange() { assertEquals(Short.valueOf((short) 1287), ShortConverter.INSTANCE.fromBytes(new byte[]{5, 7})); } - @Test(expected = IllegalArgumentException.class) - public void testFromBytes_TooLong() { - ShortConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4}); + @Test + public void fromBytes_TooLong() { + assertThrows(IllegalArgumentException.class, () -> ShortConverter.INSTANCE.fromBytes(new byte[]{6, 5, 4})); } @Test - public void testToBytes() { + public void toBytes() { assertArrayEquals(new byte[]{127, -2}, ShortConverter.INSTANCE.toBytes((short) (Short.MAX_VALUE - 1))); assertArrayEquals(new byte[]{-7}, ShortConverter.INSTANCE.toBytes((short) -7)); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/UtilDateConverterTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/UtilDateConverterTest.java index e9be51029..dfd366f37 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/UtilDateConverterTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/transformer/value/UtilDateConverterTest.java @@ -18,15 +18,15 @@ ****************************************************************/ package org.apache.cayenne.crypto.transformer.value; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class UtilDateConverterTest { @@ -37,12 +37,12 @@ public class UtilDateConverterTest { } @Test - public void testFromBytes() throws ParseException { + public void fromBytes() throws ParseException { assertEquals(date("2015-01-07 11:00:02"), UtilDateConverter.INSTANCE.fromBytes(new byte[]{0, 0, 1, 74, -60, 13, 31, 80})); } @Test - public void testToBytes() throws ParseException { + public void toBytes() throws ParseException { assertArrayEquals(new byte[]{0, 0, 1, 74, -60, 13, 31, 80}, UtilDateConverter.INSTANCE.toBytes(date("2015-01-07 11:00:02"))); } diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/CryptoUnitUtilsTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/CryptoUnitUtilsTest.java index 704ea7824..f30997291 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/CryptoUnitUtilsTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/CryptoUnitUtilsTest.java @@ -18,14 +18,14 @@ ****************************************************************/ package org.apache.cayenne.crypto.unit; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CryptoUnitUtilsTest { @Test - public void testHexToBytes() { + public void hexToBytes() { String hexString = "0506AB"; byte[] hexByte = { 5, 6, (byte) 0xAB }; diff --git a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/SwapBytesTransformerTest.java b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/SwapBytesTransformerTest.java index 275f0e9e1..4714ed615 100644 --- a/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/SwapBytesTransformerTest.java +++ b/cayenne-crypto/src/test/java/org/apache/cayenne/crypto/unit/SwapBytesTransformerTest.java @@ -18,15 +18,15 @@ ****************************************************************/ package org.apache.cayenne.crypto.unit; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import org.apache.cayenne.crypto.transformer.bytes.BytesEncryptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SwapBytesTransformerTest { @Test - public void testEncrypt_Odd() { + public void encrypt_Odd() { BytesEncryptor instance = SwapBytesTransformer.encryptor(); @@ -36,7 +36,7 @@ public class SwapBytesTransformerTest { } @Test - public void testEncrypt_Even() { + public void encrypt_Even() { BytesEncryptor instance = SwapBytesTransformer.encryptor();
