This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-crypto.git
The following commit(s) were added to refs/heads/master by this push: new 4636ff34 Use JUnit 5 convention for test method visibility 4636ff34 is described below commit 4636ff3442d1b72c2024400d42d31fece059227a Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 7 14:38:19 2025 -0400 Use JUnit 5 convention for test method visibility --- .../java/org/apache/commons/crypto/CryptoTest.java | 8 +++---- .../commons/crypto/NativeCodeLoaderTest.java | 10 ++++----- .../java/org/apache/commons/crypto/OsInfoTest.java | 2 +- .../commons/crypto/cipher/AbstractCipherTest.java | 22 +++++++++--------- .../crypto/cipher/CryptoCipherFactoryTest.java | 10 ++++----- .../commons/crypto/cipher/CryptoCipherTest.java | 4 ++-- .../commons/crypto/cipher/GcmCipherTest.java | 16 ++++++------- .../commons/crypto/cipher/OpenSslCipherTest.java | 16 ++++++------- .../crypto/cipher/OpenSslCommonModeTest.java | 2 +- .../apache/commons/crypto/jna/OpenSslJnaTest.java | 2 +- .../commons/crypto/jna/OpenSslNativeJnaTest.java | 2 +- .../jna/PositionedCryptoInputStreamJnaTest.java | 2 +- .../commons/crypto/random/AbstractRandomTest.java | 4 ++-- .../crypto/random/CryptoRandomFactoryTest.java | 26 +++++++++++----------- .../commons/crypto/random/OsCryptoRandomTest.java | 2 +- .../commons/crypto/stream/CtrCryptoStreamTest.java | 2 +- .../stream/PositionedCryptoInputStreamTest.java | 2 +- .../crypto/stream/input/ChannelInputTest.java | 2 +- .../crypto/stream/output/StreamOutputTest.java | 2 +- .../org/apache/commons/crypto/utils/EnumTest.java | 4 ++-- .../org/apache/commons/crypto/utils/UtilsTest.java | 6 ++--- 21 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/test/java/org/apache/commons/crypto/CryptoTest.java b/src/test/java/org/apache/commons/crypto/CryptoTest.java index 92fda87e..812b6dab 100644 --- a/src/test/java/org/apache/commons/crypto/CryptoTest.java +++ b/src/test/java/org/apache/commons/crypto/CryptoTest.java @@ -31,7 +31,7 @@ public class CryptoTest { * This test may fail unless the code was built by Maven, as it relies on the VERSION file being set up correctly */ @Test - public void testGetComponentName() { + void testGetComponentName() { final String version = Crypto.getComponentName(); assertNotNull("Should not be null", version); assertTrue(version.matches("^Apache Commons Crypto.*"), version); @@ -41,14 +41,14 @@ public void testGetComponentName() { * This test may fail unless the code was built by Maven, as it relies on the VERSION file being set up correctly. */ @Test - public void testGetComponentVersion() { + void testGetComponentVersion() { final String version = Crypto.getComponentVersion(); assertNotNull("Should not be null", version); assertTrue(version.matches("^\\d+\\.\\d+.*"), version); } @Test - public void testLoadingError() throws Throwable { + void testLoadingError() throws Throwable { final Throwable loadingError = Crypto.getLoadingError(); if (loadingError != null) { throw loadingError; @@ -57,7 +57,7 @@ public void testLoadingError() throws Throwable { } @Test - public void testMain() throws Throwable { + void testMain() throws Throwable { // Check that Crypto.main will actually run tests assertTrue(Crypto.isNativeCodeLoaded(), "Native code loaded OK"); Crypto.main(new String[] { }); // show the JNI library details diff --git a/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java b/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java index 17cb27de..ff2abca2 100644 --- a/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java +++ b/src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java @@ -33,7 +33,7 @@ public class NativeCodeLoaderTest { @Test - public void test() { + void test() { assertTrue(NativeCodeLoader.isNativeCodeLoaded(), "Native (JNI) code loaded successfully"); } @@ -48,20 +48,20 @@ public void test() { // Note that this appears during a subsequent test, and does not // happen every time. // At this point it is not known where the native stream is written. - public void testCanLoadIfPresent() { + void testCanLoadIfPresent() { assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); // This will try to reload the library, so should work assertNull(NativeCodeLoader.loadLibrary()); } @Test - public void testNativeNotPresent() { + void testNativeNotPresent() { assumeTrue(!NativeCodeLoader.isNativeCodeLoaded()); assertNotNull(NativeCodeLoader.getLoadingError()); } @Test - public void testNativePresent() { + void testNativePresent() { assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); assertNull(NativeCodeLoader.getLoadingError()); } @@ -71,7 +71,7 @@ public void testNativePresent() { // It causes problems because the system properties are temporarily changed. // However, properties are only fetched once, thus the test either corrupts the settings // or does not work, depending on the order of tests. - public void testUnSuccessfulLoad() throws Exception { + void testUnSuccessfulLoad() throws Exception { final String nameKey = System.getProperty(Crypto.LIB_NAME_KEY); final String pathKey = System.getProperty(Crypto.LIB_PATH_KEY); // An empty file should cause UnsatisfiedLinkError diff --git a/src/test/java/org/apache/commons/crypto/OsInfoTest.java b/src/test/java/org/apache/commons/crypto/OsInfoTest.java index 23b71359..4a5da730 100644 --- a/src/test/java/org/apache/commons/crypto/OsInfoTest.java +++ b/src/test/java/org/apache/commons/crypto/OsInfoTest.java @@ -25,7 +25,7 @@ public class OsInfoTest { private static final String EXPECTED_PATH_PROPERTY = "OsInfoTest.expectedPath"; @Test - public void testMain() { + void testMain() { OsInfo.main(new String[0]); OsInfo.main(new String[] { "--os" }); OsInfo.main(new String[] { "--arch" }); diff --git a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java index a45bda9a..0f84ebb8 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java @@ -208,7 +208,7 @@ public void setup() { } @Test - public void testCloseTestAfterInit() throws Exception { + void testCloseTestAfterInit() throws Exception { // This test deliberately does not use try with resources in order to control // the sequence of operations exactly try (final CryptoCipher enc = getCipher(transformations[0])) { @@ -217,7 +217,7 @@ public void testCloseTestAfterInit() throws Exception { } @Test - public void testCloseTestNoInit() throws Exception { + void testCloseTestNoInit() throws Exception { // This test deliberately does not use try with resources in order to control // the sequence of operations exactly try (final CryptoCipher enc = getCipher(transformations[0])) { @@ -226,7 +226,7 @@ public void testCloseTestNoInit() throws Exception { } @Test - public void testCloseTestRepeat() throws Exception { + void testCloseTestRepeat() throws Exception { // This test deliberately does not use try with resources in order to control // the sequence of operations exactly try (final CryptoCipher enc = getCipher(transformations[0])) { @@ -236,7 +236,7 @@ public void testCloseTestRepeat() throws Exception { } @Test - public void testCryptoTest() throws Exception { + void testCryptoTest() throws Exception { for (final String tran : transformations) { /** Uses the small data set in {@link TestData} */ cipherTests = TestData.getTestData(tran); @@ -265,7 +265,7 @@ public void testCryptoTest() throws Exception { } @Test - public void testInvalidIV() throws Exception { + void testInvalidIV() throws Exception { for (final String transform : transformations) { try (final CryptoCipher cipher = getCipher(transform)) { assertNotNull(cipher); @@ -277,7 +277,7 @@ public void testInvalidIV() throws Exception { } @Test - public void testInvalidIVClass() throws Exception { + void testInvalidIVClass() throws Exception { for (final String transform : transformations) { try (final CryptoCipher cipher = getCipher(transform)) { assertNotNull(cipher); @@ -287,7 +287,7 @@ public void testInvalidIVClass() throws Exception { } @Test - public void testInvalidKey() throws Exception { + void testInvalidKey() throws Exception { for (final String transform : transformations) { try (final CryptoCipher cipher = getCipher(transform)) { assertNotNull(cipher); @@ -300,19 +300,19 @@ public void testInvalidKey() throws Exception { } @Test - public void testInvalidTransform() { + void testInvalidTransform() { assertThrows(IllegalArgumentException.class, () -> getCipher("AES/CBR/NoPadding/garbage/garbage").close()); } @Test - public void testNullTransform() { + void testNullTransform() { assertThrows(IllegalArgumentException.class, () -> getCipher(null).close()); } @Test - public void testReInitAfterClose() throws Exception { + void testReInitAfterClose() throws Exception { // This test deliberately does not use try with resources in order to control // the sequence of operations exactly try (final CryptoCipher enc = getCipher(transformations[0])) { @@ -323,7 +323,7 @@ public void testReInitAfterClose() throws Exception { } @Test - public void testReInitTest() throws Exception { + void testReInitTest() throws Exception { // This test deliberately does not use try with resources in order to control // the sequence of operations exactly try (final CryptoCipher enc = getCipher(transformations[0])) { diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java index 31cf76fc..2a232489 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java @@ -30,7 +30,7 @@ public class CryptoCipherFactoryTest { @Test - public void testDefaultCipher() throws GeneralSecurityException, IOException { + void testDefaultCipher() throws GeneralSecurityException, IOException { try (CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(AES.CTR_NO_PADDING)) { final String name = defaultCipher.getClass().getName(); if (OpenSsl.getLoadingFailureReason() == null) { @@ -42,7 +42,7 @@ public void testDefaultCipher() throws GeneralSecurityException, IOException { } @Test - public void testEmptyCipher() throws GeneralSecurityException, IOException { + void testEmptyCipher() throws GeneralSecurityException, IOException { final Properties properties = new Properties(); properties.setProperty(CryptoCipherFactory.CLASSES_KEY, ""); // TODO should this really mean use the default? try (CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(AES.CBC_NO_PADDING, properties)) { @@ -56,7 +56,7 @@ public void testEmptyCipher() throws GeneralSecurityException, IOException { } @Test - public void testInvalidCipher() { + void testInvalidCipher() { final Properties properties = new Properties(); properties.setProperty(CryptoCipherFactory.CLASSES_KEY, "InvalidCipherName"); assertThrows(GeneralSecurityException.class, () -> CryptoCipherFactory.getCryptoCipher(AES.CBC_NO_PADDING, properties)); @@ -64,14 +64,14 @@ public void testInvalidCipher() { } @Test - public void testInvalidTransformation() { + void testInvalidTransformation() { final Properties properties = new Properties(); assertThrows(GeneralSecurityException.class, () -> CryptoCipherFactory.getCryptoCipher("AES/Invalid/NoPadding", properties)); } @Test - public void testNoCipher() { + void testNoCipher() { final Properties properties = new Properties(); // An empty string currently means use the default // However the splitter drops empty fields diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java index 20b641ba..8d53f8ed 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java @@ -30,12 +30,12 @@ public class CryptoCipherTest { @Test - public void testUpdateAADByteArray() { + void testUpdateAADByteArray() { assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((byte[]) null)); } @Test - public void testUpdateAADByteBuffer() { + void testUpdateAADByteBuffer() { assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((ByteBuffer) null)); } } diff --git a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java index 3c28f5f3..1ad0f03d 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java @@ -320,7 +320,7 @@ private void testGcmEncryption(final String kHex, final String pHex, final Strin * @throws Exception Test failure */ @Test - public void testGcmNistCase2() throws Exception { + void testGcmNistCase2() throws Exception { // key length: 16 bytes // plain text length: 16 bytes // iv length: 12 bytes @@ -342,7 +342,7 @@ public void testGcmNistCase2() throws Exception { } @Test - public void testGcmNistCase4() throws Exception { + void testGcmNistCase4() throws Exception { // key length: 16 bytes // plain text length: 60 bytes // iv length: 12 bytes @@ -371,7 +371,7 @@ public void testGcmNistCase4() throws Exception { } @Test - public void testGcmNistCase5() throws Exception { + void testGcmNistCase5() throws Exception { // key length: 16 bytes // plain text length: 60 bytes // iv length: 8 bytes @@ -404,7 +404,7 @@ public void testGcmNistCase5() throws Exception { } @Test - public void testGcmNistCase6() throws Exception { + void testGcmNistCase6() throws Exception { // key length: 16 bytes // plain text length: 60 bytes // iv length: 60 bytes @@ -440,7 +440,7 @@ public void testGcmNistCase6() throws Exception { } @Test - public void testGcmNistCases() throws Exception { + void testGcmNistCases() throws Exception { for(int i = 0; i < kHex.length; i++) { testGcmEncryption(kHex[i], pHex[i], ivHex[i], aadHex[i], cHex[i], tHex[i]); testGcmDecryption(kHex[i], pHex[i], ivHex[i], aadHex[i], cHex[i], tHex[i]); @@ -482,7 +482,7 @@ private void testGcmReturnDataAfterTagVerified(final String kHex, final String p } @Test - public void testGcmTamperedData() throws Exception { + void testGcmTamperedData() throws Exception { final Random r = new Random(); final int textLength = r.nextInt(1024*1024); @@ -529,7 +529,7 @@ public void testGcmTamperedData() throws Exception { } @Test - public void testGMac() throws Exception { + void testGMac() throws Exception { // for GMAC, aad is the input data, // tag is the digest message @@ -582,7 +582,7 @@ public void testGMac() throws Exception { @Test //(expected = AEADBadTagException.class) - public void testGMacTamperedData() throws Exception { + void testGMacTamperedData() throws Exception { final Random r = new Random(); final byte[] keyBytes = new byte[32]; final byte[] input = {}; diff --git a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java index 07a12ad4..fb5f416d 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java @@ -52,7 +52,7 @@ public void init() { } @Test - public void testCipherLifecycle() throws Exception { + void testCipherLifecycle() throws Exception { try (OpenSslCipher cipher = new OpenSslCipher(new Properties(), AES.CTR_NO_PADDING)) { assertThrows(IllegalStateException.class, () -> cipher.update(dummyBuffer(), dummyBuffer())); @@ -76,7 +76,7 @@ public void testCipherLifecycle() throws Exception { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testDoFinalArguments() throws Exception { + void testDoFinalArguments() throws Exception { assumeTrue(OpenSsl.getLoadingFailureReason() == null); final OpenSsl cipher = OpenSsl .getInstance(AES.CTR_NO_PADDING); @@ -95,7 +95,7 @@ public void testDoFinalArguments() throws Exception { @Override @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testInvalidIV() throws Exception { + void testInvalidIV() throws Exception { assumeTrue(OpenSsl.getLoadingFailureReason() == null); final OpenSsl cipher = OpenSsl .getInstance(AES.CTR_NO_PADDING); @@ -111,7 +111,7 @@ public void testInvalidIV() throws Exception { @Override @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testInvalidIVClass() throws Exception { + void testInvalidIVClass() throws Exception { final OpenSsl cipher = OpenSsl.getInstance(AES.CTR_NO_PADDING); assertNotNull(cipher); @@ -122,7 +122,7 @@ public void testInvalidIVClass() throws Exception { @Override @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testInvalidKey() throws Exception { + void testInvalidKey() throws Exception { assumeTrue(OpenSsl.getLoadingFailureReason() == null); final OpenSsl cipher = OpenSsl .getInstance(AES.CTR_NO_PADDING); @@ -137,7 +137,7 @@ public void testInvalidKey() throws Exception { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testInvalidMode() { + void testInvalidMode() { assumeTrue(OpenSsl.getLoadingFailureReason() == null); assertThrows(NoSuchAlgorithmException.class, () -> OpenSsl.getInstance("AES/CTR2/NoPadding")); @@ -145,7 +145,7 @@ public void testInvalidMode() { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testInvalidPadding() { + void testInvalidPadding() { assumeTrue(OpenSsl.getLoadingFailureReason() == null); assertThrows(NoSuchPaddingException.class, () -> OpenSsl.getInstance("AES/CTR/NoPadding2")); @@ -153,7 +153,7 @@ public void testInvalidPadding() { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testUpdateArguments() throws Exception { + void testUpdateArguments() throws Exception { assumeTrue(OpenSsl.getLoadingFailureReason() == null); final OpenSsl cipher = OpenSsl .getInstance(AES.CTR_NO_PADDING); diff --git a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java index 585ce5e9..7d943b1c 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java @@ -25,7 +25,7 @@ public class OpenSslCommonModeTest { @Test - public void testUpdateAAD() { + void testUpdateAAD() { assertThrows(UnsupportedOperationException.class, () -> new OpenSslCommonMode(0, 0, 0).updateAAD(null)); } } diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java index 42f24abc..46ba7398 100644 --- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java +++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java @@ -27,7 +27,7 @@ public class OpenSslJnaTest { private static final String EXPECTED_VERSION_PROPERTY = "OpenSslJnaTest.expectedVersion"; @Test - public void testMain() throws Throwable { + void testMain() throws Throwable { OpenSslJna.main(new String[0]); final String expectedVersion = System.getProperty(EXPECTED_VERSION_PROPERTY, ""); if (expectedVersion.isEmpty()) { diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslNativeJnaTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslNativeJnaTest.java index 60bcea15..c6dc0286 100644 --- a/src/test/java/org/apache/commons/crypto/jna/OpenSslNativeJnaTest.java +++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslNativeJnaTest.java @@ -26,7 +26,7 @@ public class OpenSslNativeJnaTest { @Test - public void test(final TestReporter reporter) { + void test(final TestReporter reporter) { if (OpenSslJna.isEnabled()) { reporter.publishEntry(String.format("JNA loaded OK for lib version 0x%x: ", OpenSslNativeJna.VERSION)); } else { diff --git a/src/test/java/org/apache/commons/crypto/jna/PositionedCryptoInputStreamJnaTest.java b/src/test/java/org/apache/commons/crypto/jna/PositionedCryptoInputStreamJnaTest.java index ab47dd43..66c4f84e 100644 --- a/src/test/java/org/apache/commons/crypto/jna/PositionedCryptoInputStreamJnaTest.java +++ b/src/test/java/org/apache/commons/crypto/jna/PositionedCryptoInputStreamJnaTest.java @@ -37,7 +37,7 @@ public void testJNI() throws Exception { } @Test - public void testCipher() throws Exception { + void testCipher() throws Exception { testCipher(OpenSslJnaCipher.class.getName()); } diff --git a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java index dca853a6..cdce7edd 100644 --- a/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/random/AbstractRandomTest.java @@ -47,7 +47,7 @@ private void checkRandomBytes(final CryptoRandom random, final int len) { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testRandomBytes() throws Exception { + void testRandomBytes() throws Exception { try (CryptoRandom random = getCryptoRandom()) { // len = 16 checkRandomBytes(random, 16); @@ -62,7 +62,7 @@ public void testRandomBytes() throws Exception { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testRandomBytesMultiThreaded() throws Exception { + void testRandomBytesMultiThreaded() throws Exception { final int threadCount = 100; try (final CryptoRandom random = getCryptoRandom()) { final List<Thread> threads = new ArrayList<>(threadCount); diff --git a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java index bef46890..e09159c8 100644 --- a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java +++ b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java @@ -33,7 +33,7 @@ public class CryptoRandomFactoryTest { @Test - public void testAbstractRandom() { + void testAbstractRandom() { final Properties properties = new Properties(); properties.setProperty(CryptoRandomFactory.CLASSES_KEY, AbstractRandom.class.getName()); final Exception ex = assertThrows(GeneralSecurityException.class, () -> CryptoRandomFactory.getCryptoRandom(properties)); @@ -42,7 +42,7 @@ public void testAbstractRandom() { } @Test - public void testDefaultRandom() throws GeneralSecurityException, IOException { + void testDefaultRandom() throws GeneralSecurityException, IOException { final Properties properties = new Properties(); try (final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(properties)) { final String name = random.getClass().getName(); @@ -55,14 +55,14 @@ public void testDefaultRandom() throws GeneralSecurityException, IOException { } @Test - public void testDefaultRandomClass() throws GeneralSecurityException, IOException { + void testDefaultRandomClass() throws GeneralSecurityException, IOException { try (final CryptoRandom random = CryptoRandomFactory.getCryptoRandom()) { assertEquals(OpenSslCryptoRandom.class.getName(), random.getClass().getName()); } } @Test - public void testMissingPropertyCtrRandomRandom() { + void testMissingPropertyCtrRandomRandom() { final Properties properties = new Properties(); properties.setProperty(CryptoRandomFactory.CLASSES_KEY, MissingPropertyCtrRandom.class.getName()); final Exception ex = assertThrows(GeneralSecurityException.class, () -> CryptoRandomFactory.getCryptoRandom(properties)); @@ -71,14 +71,14 @@ public void testMissingPropertyCtrRandomRandom() { } @Test - public void testEmpty() throws Exception { + void testEmpty() throws Exception { final Properties properties = new Properties(); properties.setProperty(CryptoRandomFactory.CLASSES_KEY, ""); CryptoRandomFactory.getCryptoRandom(properties).close(); } @Test - public void testExceptionInInitializerErrorRandom() throws GeneralSecurityException, IOException { + void testExceptionInInitializerErrorRandom() throws GeneralSecurityException, IOException { final Properties properties = new Properties(); final String classes = ExceptionInInitializerErrorRandom.class.getName().concat(",") .concat(CryptoRandomFactory.RandomProvider.JAVA.getClassName()); @@ -92,7 +92,7 @@ public void testExceptionInInitializerErrorRandom() throws GeneralSecurityExcept } @Test - public void testFailingRandom() { + void testFailingRandom() { final Properties properties = new Properties(); properties.setProperty(CryptoRandomFactory.CLASSES_KEY, FailingRandom.class.getName()); final Exception ex = assertThrows(GeneralSecurityException.class, () -> CryptoRandomFactory.getCryptoRandom(properties)); @@ -106,7 +106,7 @@ public void testFailingRandom() { } @Test - public void testFullClassName() throws GeneralSecurityException, IOException { + void testFullClassName() throws GeneralSecurityException, IOException { final Properties props = new Properties(); props.setProperty(CryptoRandomFactory.CLASSES_KEY, JavaCryptoRandom.class.getName()); try (final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props)) { @@ -115,7 +115,7 @@ public void testFullClassName() throws GeneralSecurityException, IOException { } @Test - public void testGetOSRandom() throws GeneralSecurityException, IOException { + void testGetOSRandom() throws GeneralSecurityException, IOException { // Windows does not have a /dev/random device assumeTrue(!SystemProperties.getOsName().contains("Windows")); final Properties properties = new Properties(); @@ -126,7 +126,7 @@ public void testGetOSRandom() throws GeneralSecurityException, IOException { } @Test - public void testInvalidRandom() { + void testInvalidRandom() { final Properties properties = new Properties(); properties.setProperty(CryptoRandomFactory.CLASSES_KEY, "InvalidCipherName"); @@ -134,7 +134,7 @@ public void testInvalidRandom() { } @Test - public void testInvalidRandomClass() throws GeneralSecurityException, IOException { + void testInvalidRandomClass() throws GeneralSecurityException, IOException { final Properties properties = new Properties(); properties.setProperty("org.apache.commons.crypto.cipher", "OpenSsl"); try (final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(properties)) { @@ -143,7 +143,7 @@ public void testInvalidRandomClass() throws GeneralSecurityException, IOExceptio } @Test - public void testNoClasses() { + void testNoClasses() { final Properties properties = new Properties(); // An empty string currently means use the default // However the splitter drops empty fields @@ -152,7 +152,7 @@ public void testNoClasses() { } @Test - public void testNull() { + void testNull() { assertThrows(NullPointerException.class, () -> CryptoRandomFactory.getCryptoRandom(null)); } } diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java index 9a7c4ac6..d6a09f3d 100644 --- a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java @@ -44,7 +44,7 @@ public CryptoRandom getCryptoRandom() throws GeneralSecurityException { } @Test - public void testInvalidRandom() { + void testInvalidRandom() { final Properties props = new Properties(); props.setProperty(CryptoRandomFactory.CLASSES_KEY, OsCryptoRandom.class.getName()); // Invalid device diff --git a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java index e5f4e24d..83409c9c 100644 --- a/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java +++ b/src/test/java/org/apache/commons/crypto/stream/CtrCryptoStreamTest.java @@ -162,7 +162,7 @@ public void setUp() { @Test @Timeout(value = 120000, unit = TimeUnit.MILLISECONDS) - public void testDecrypt() throws Exception { + void testDecrypt() throws Exception { doDecryptTest(AbstractCipherTest.JCE_CIPHER_CLASSNAME, false); doDecryptTest(AbstractCipherTest.OPENSSL_CIPHER_CLASSNAME, false); diff --git a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java index 637d1d3c..00daa784 100644 --- a/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java +++ b/src/test/java/org/apache/commons/crypto/stream/PositionedCryptoInputStreamTest.java @@ -326,7 +326,7 @@ protected void testCipher(final String cipherClass) throws Exception { } @Test - public void testJCE() throws Exception { + void testJCE() throws Exception { testCipher(AbstractCipherTest.JCE_CIPHER_CLASSNAME); } diff --git a/src/test/java/org/apache/commons/crypto/stream/input/ChannelInputTest.java b/src/test/java/org/apache/commons/crypto/stream/input/ChannelInputTest.java index cd2686a9..ebdd25a9 100644 --- a/src/test/java/org/apache/commons/crypto/stream/input/ChannelInputTest.java +++ b/src/test/java/org/apache/commons/crypto/stream/input/ChannelInputTest.java @@ -32,7 +32,7 @@ public class ChannelInputTest { @Test - public void testSkipWithSkipBuffer() throws IOException { + void testSkipWithSkipBuffer() throws IOException { try (final ChannelInput channelInput = new ChannelInput( Channels.newChannel(new ByteArrayInputStream(new byte[10])))) { assertEquals(0, channelInput.skip(0)); diff --git a/src/test/java/org/apache/commons/crypto/stream/output/StreamOutputTest.java b/src/test/java/org/apache/commons/crypto/stream/output/StreamOutputTest.java index 3275f3b5..9973b1b3 100644 --- a/src/test/java/org/apache/commons/crypto/stream/output/StreamOutputTest.java +++ b/src/test/java/org/apache/commons/crypto/stream/output/StreamOutputTest.java @@ -31,7 +31,7 @@ public class StreamOutputTest { @Test - public void testGetOut() throws IOException { + void testGetOut() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (StreamOutput streamOutput = new StreamOutput(baos, 1024)) { assertEquals(baos, streamOutput.getOut()); diff --git a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java index 194de85f..bc6d58a9 100644 --- a/src/test/java/org/apache/commons/crypto/utils/EnumTest.java +++ b/src/test/java/org/apache/commons/crypto/utils/EnumTest.java @@ -46,7 +46,7 @@ private void checkImplClass(final RandomProvider value) { } @Test - public void testCipher() throws Exception { + void testCipher() throws Exception { for (final CipherProvider value : CryptoCipherFactory.CipherProvider.values()) { ReflectionUtils.getClassByName(value.getClassName()); checkImplClass(value); @@ -54,7 +54,7 @@ public void testCipher() throws Exception { } @Test - public void testRandom() throws Exception { + void testRandom() throws Exception { for (final RandomProvider value : CryptoRandomFactory.RandomProvider.values()) { ReflectionUtils.getClassByName(value.getClassName()); checkImplClass(value); diff --git a/src/test/java/org/apache/commons/crypto/utils/UtilsTest.java b/src/test/java/org/apache/commons/crypto/utils/UtilsTest.java index 09ecaeac..0ec7f912 100644 --- a/src/test/java/org/apache/commons/crypto/utils/UtilsTest.java +++ b/src/test/java/org/apache/commons/crypto/utils/UtilsTest.java @@ -28,7 +28,7 @@ public class UtilsTest { @Test - public void testGetProperties() { + void testGetProperties() { final Properties props = new Properties(); props.setProperty( "garbage.in", @@ -38,12 +38,12 @@ public void testGetProperties() { } @Test - public void testSplitNull() { + void testSplitNull() { assertEquals(Collections.<String> emptyList(), Utils.splitClassNames(null, ",")); } @Test - public void testSplitOmitEmptyLine() { + void testSplitOmitEmptyLine() { List<String> clazzNames = Utils.splitClassNames("", ","); assertEquals(Collections.<String> emptyList(), clazzNames);