Skip to content

Commit 4636ff3

Browse files
committed
Use JUnit 5 convention for test method visibility
1 parent 488663e commit 4636ff3

21 files changed

Lines changed: 73 additions & 73 deletions

src/test/java/org/apache/commons/crypto/CryptoTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class CryptoTest {
3131
* This test may fail unless the code was built by Maven, as it relies on the VERSION file being set up correctly
3232
*/
3333
@Test
34-
public void testGetComponentName() {
34+
void testGetComponentName() {
3535
final String version = Crypto.getComponentName();
3636
assertNotNull("Should not be null", version);
3737
assertTrue(version.matches("^Apache Commons Crypto.*"), version);
@@ -41,14 +41,14 @@ public void testGetComponentName() {
4141
* This test may fail unless the code was built by Maven, as it relies on the VERSION file being set up correctly.
4242
*/
4343
@Test
44-
public void testGetComponentVersion() {
44+
void testGetComponentVersion() {
4545
final String version = Crypto.getComponentVersion();
4646
assertNotNull("Should not be null", version);
4747
assertTrue(version.matches("^\\d+\\.\\d+.*"), version);
4848
}
4949

5050
@Test
51-
public void testLoadingError() throws Throwable {
51+
void testLoadingError() throws Throwable {
5252
final Throwable loadingError = Crypto.getLoadingError();
5353
if (loadingError != null) {
5454
throw loadingError;
@@ -57,7 +57,7 @@ public void testLoadingError() throws Throwable {
5757
}
5858

5959
@Test
60-
public void testMain() throws Throwable {
60+
void testMain() throws Throwable {
6161
// Check that Crypto.main will actually run tests
6262
assertTrue(Crypto.isNativeCodeLoaded(), "Native code loaded OK");
6363
Crypto.main(new String[] { }); // show the JNI library details

src/test/java/org/apache/commons/crypto/NativeCodeLoaderTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class NativeCodeLoaderTest {
3434

3535
@Test
36-
public void test() {
36+
void test() {
3737
assertTrue(NativeCodeLoader.isNativeCodeLoaded(), "Native (JNI) code loaded successfully");
3838
}
3939

@@ -48,20 +48,20 @@ public void test() {
4848
// Note that this appears during a subsequent test, and does not
4949
// happen every time.
5050
// At this point it is not known where the native stream is written.
51-
public void testCanLoadIfPresent() {
51+
void testCanLoadIfPresent() {
5252
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
5353
// This will try to reload the library, so should work
5454
assertNull(NativeCodeLoader.loadLibrary());
5555
}
5656

5757
@Test
58-
public void testNativeNotPresent() {
58+
void testNativeNotPresent() {
5959
assumeTrue(!NativeCodeLoader.isNativeCodeLoaded());
6060
assertNotNull(NativeCodeLoader.getLoadingError());
6161
}
6262

6363
@Test
64-
public void testNativePresent() {
64+
void testNativePresent() {
6565
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
6666
assertNull(NativeCodeLoader.getLoadingError());
6767
}
@@ -71,7 +71,7 @@ public void testNativePresent() {
7171
// It causes problems because the system properties are temporarily changed.
7272
// However, properties are only fetched once, thus the test either corrupts the settings
7373
// or does not work, depending on the order of tests.
74-
public void testUnSuccessfulLoad() throws Exception {
74+
void testUnSuccessfulLoad() throws Exception {
7575
final String nameKey = System.getProperty(Crypto.LIB_NAME_KEY);
7676
final String pathKey = System.getProperty(Crypto.LIB_PATH_KEY);
7777
// An empty file should cause UnsatisfiedLinkError

src/test/java/org/apache/commons/crypto/OsInfoTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class OsInfoTest {
2525

2626
private static final String EXPECTED_PATH_PROPERTY = "OsInfoTest.expectedPath";
2727
@Test
28-
public void testMain() {
28+
void testMain() {
2929
OsInfo.main(new String[0]);
3030
OsInfo.main(new String[] { "--os" });
3131
OsInfo.main(new String[] { "--arch" });

src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void setup() {
208208
}
209209

210210
@Test
211-
public void testCloseTestAfterInit() throws Exception {
211+
void testCloseTestAfterInit() throws Exception {
212212
// This test deliberately does not use try with resources in order to control
213213
// the sequence of operations exactly
214214
try (final CryptoCipher enc = getCipher(transformations[0])) {
@@ -217,7 +217,7 @@ public void testCloseTestAfterInit() throws Exception {
217217
}
218218

219219
@Test
220-
public void testCloseTestNoInit() throws Exception {
220+
void testCloseTestNoInit() throws Exception {
221221
// This test deliberately does not use try with resources in order to control
222222
// the sequence of operations exactly
223223
try (final CryptoCipher enc = getCipher(transformations[0])) {
@@ -226,7 +226,7 @@ public void testCloseTestNoInit() throws Exception {
226226
}
227227

228228
@Test
229-
public void testCloseTestRepeat() throws Exception {
229+
void testCloseTestRepeat() throws Exception {
230230
// This test deliberately does not use try with resources in order to control
231231
// the sequence of operations exactly
232232
try (final CryptoCipher enc = getCipher(transformations[0])) {
@@ -236,7 +236,7 @@ public void testCloseTestRepeat() throws Exception {
236236
}
237237

238238
@Test
239-
public void testCryptoTest() throws Exception {
239+
void testCryptoTest() throws Exception {
240240
for (final String tran : transformations) {
241241
/** Uses the small data set in {@link TestData} */
242242
cipherTests = TestData.getTestData(tran);
@@ -265,7 +265,7 @@ public void testCryptoTest() throws Exception {
265265
}
266266

267267
@Test
268-
public void testInvalidIV() throws Exception {
268+
void testInvalidIV() throws Exception {
269269
for (final String transform : transformations) {
270270
try (final CryptoCipher cipher = getCipher(transform)) {
271271
assertNotNull(cipher);
@@ -277,7 +277,7 @@ public void testInvalidIV() throws Exception {
277277
}
278278

279279
@Test
280-
public void testInvalidIVClass() throws Exception {
280+
void testInvalidIVClass() throws Exception {
281281
for (final String transform : transformations) {
282282
try (final CryptoCipher cipher = getCipher(transform)) {
283283
assertNotNull(cipher);
@@ -287,7 +287,7 @@ public void testInvalidIVClass() throws Exception {
287287
}
288288

289289
@Test
290-
public void testInvalidKey() throws Exception {
290+
void testInvalidKey() throws Exception {
291291
for (final String transform : transformations) {
292292
try (final CryptoCipher cipher = getCipher(transform)) {
293293
assertNotNull(cipher);
@@ -300,19 +300,19 @@ public void testInvalidKey() throws Exception {
300300
}
301301

302302
@Test
303-
public void testInvalidTransform() {
303+
void testInvalidTransform() {
304304
assertThrows(IllegalArgumentException.class,
305305
() -> getCipher("AES/CBR/NoPadding/garbage/garbage").close());
306306
}
307307

308308
@Test
309-
public void testNullTransform() {
309+
void testNullTransform() {
310310
assertThrows(IllegalArgumentException.class,
311311
() -> getCipher(null).close());
312312
}
313313

314314
@Test
315-
public void testReInitAfterClose() throws Exception {
315+
void testReInitAfterClose() throws Exception {
316316
// This test deliberately does not use try with resources in order to control
317317
// the sequence of operations exactly
318318
try (final CryptoCipher enc = getCipher(transformations[0])) {
@@ -323,7 +323,7 @@ public void testReInitAfterClose() throws Exception {
323323
}
324324

325325
@Test
326-
public void testReInitTest() throws Exception {
326+
void testReInitTest() throws Exception {
327327
// This test deliberately does not use try with resources in order to control
328328
// the sequence of operations exactly
329329
try (final CryptoCipher enc = getCipher(transformations[0])) {

src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class CryptoCipherFactoryTest {
3131

3232
@Test
33-
public void testDefaultCipher() throws GeneralSecurityException, IOException {
33+
void testDefaultCipher() throws GeneralSecurityException, IOException {
3434
try (CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(AES.CTR_NO_PADDING)) {
3535
final String name = defaultCipher.getClass().getName();
3636
if (OpenSsl.getLoadingFailureReason() == null) {
@@ -42,7 +42,7 @@ public void testDefaultCipher() throws GeneralSecurityException, IOException {
4242
}
4343

4444
@Test
45-
public void testEmptyCipher() throws GeneralSecurityException, IOException {
45+
void testEmptyCipher() throws GeneralSecurityException, IOException {
4646
final Properties properties = new Properties();
4747
properties.setProperty(CryptoCipherFactory.CLASSES_KEY, ""); // TODO should this really mean use the default?
4848
try (CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher(AES.CBC_NO_PADDING, properties)) {
@@ -56,22 +56,22 @@ public void testEmptyCipher() throws GeneralSecurityException, IOException {
5656
}
5757

5858
@Test
59-
public void testInvalidCipher() {
59+
void testInvalidCipher() {
6060
final Properties properties = new Properties();
6161
properties.setProperty(CryptoCipherFactory.CLASSES_KEY, "InvalidCipherName");
6262
assertThrows(GeneralSecurityException.class, () -> CryptoCipherFactory.getCryptoCipher(AES.CBC_NO_PADDING, properties));
6363

6464
}
6565

6666
@Test
67-
public void testInvalidTransformation() {
67+
void testInvalidTransformation() {
6868
final Properties properties = new Properties();
6969
assertThrows(GeneralSecurityException.class, () -> CryptoCipherFactory.getCryptoCipher("AES/Invalid/NoPadding", properties));
7070

7171
}
7272

7373
@Test
74-
public void testNoCipher() {
74+
void testNoCipher() {
7575
final Properties properties = new Properties();
7676
// An empty string currently means use the default
7777
// However the splitter drops empty fields

src/test/java/org/apache/commons/crypto/cipher/CryptoCipherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
public class CryptoCipherTest {
3131

3232
@Test
33-
public void testUpdateAADByteArray() {
33+
void testUpdateAADByteArray() {
3434
assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((byte[]) null));
3535
}
3636

3737
@Test
38-
public void testUpdateAADByteBuffer() {
38+
void testUpdateAADByteBuffer() {
3939
assertThrows(UnsupportedOperationException.class, () -> new DefaultCryptoCipher().updateAAD((ByteBuffer) null));
4040
}
4141
}

src/test/java/org/apache/commons/crypto/cipher/GcmCipherTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private void testGcmEncryption(final String kHex, final String pHex, final Strin
320320
* @throws Exception Test failure
321321
*/
322322
@Test
323-
public void testGcmNistCase2() throws Exception {
323+
void testGcmNistCase2() throws Exception {
324324
// key length: 16 bytes
325325
// plain text length: 16 bytes
326326
// iv length: 12 bytes
@@ -342,7 +342,7 @@ public void testGcmNistCase2() throws Exception {
342342
}
343343

344344
@Test
345-
public void testGcmNistCase4() throws Exception {
345+
void testGcmNistCase4() throws Exception {
346346
// key length: 16 bytes
347347
// plain text length: 60 bytes
348348
// iv length: 12 bytes
@@ -371,7 +371,7 @@ public void testGcmNistCase4() throws Exception {
371371
}
372372

373373
@Test
374-
public void testGcmNistCase5() throws Exception {
374+
void testGcmNistCase5() throws Exception {
375375
// key length: 16 bytes
376376
// plain text length: 60 bytes
377377
// iv length: 8 bytes
@@ -404,7 +404,7 @@ public void testGcmNistCase5() throws Exception {
404404
}
405405

406406
@Test
407-
public void testGcmNistCase6() throws Exception {
407+
void testGcmNistCase6() throws Exception {
408408
// key length: 16 bytes
409409
// plain text length: 60 bytes
410410
// iv length: 60 bytes
@@ -440,7 +440,7 @@ public void testGcmNistCase6() throws Exception {
440440
}
441441

442442
@Test
443-
public void testGcmNistCases() throws Exception {
443+
void testGcmNistCases() throws Exception {
444444
for(int i = 0; i < kHex.length; i++) {
445445
testGcmEncryption(kHex[i], pHex[i], ivHex[i], aadHex[i], cHex[i], tHex[i]);
446446
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
482482
}
483483

484484
@Test
485-
public void testGcmTamperedData() throws Exception {
485+
void testGcmTamperedData() throws Exception {
486486

487487
final Random r = new Random();
488488
final int textLength = r.nextInt(1024*1024);
@@ -529,7 +529,7 @@ public void testGcmTamperedData() throws Exception {
529529
}
530530

531531
@Test
532-
public void testGMac() throws Exception {
532+
void testGMac() throws Exception {
533533
// for GMAC, aad is the input data,
534534
// tag is the digest message
535535

@@ -582,7 +582,7 @@ public void testGMac() throws Exception {
582582

583583
@Test
584584
//(expected = AEADBadTagException.class)
585-
public void testGMacTamperedData() throws Exception {
585+
void testGMacTamperedData() throws Exception {
586586
final Random r = new Random();
587587
final byte[] keyBytes = new byte[32];
588588
final byte[] input = {};

src/test/java/org/apache/commons/crypto/cipher/OpenSslCipherTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void init() {
5252
}
5353

5454
@Test
55-
public void testCipherLifecycle() throws Exception {
55+
void testCipherLifecycle() throws Exception {
5656
try (OpenSslCipher cipher = new OpenSslCipher(new Properties(), AES.CTR_NO_PADDING)) {
5757

5858
assertThrows(IllegalStateException.class, () -> cipher.update(dummyBuffer(), dummyBuffer()));
@@ -76,7 +76,7 @@ public void testCipherLifecycle() throws Exception {
7676

7777
@Test
7878
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
79-
public void testDoFinalArguments() throws Exception {
79+
void testDoFinalArguments() throws Exception {
8080
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
8181
final OpenSsl cipher = OpenSsl
8282
.getInstance(AES.CTR_NO_PADDING);
@@ -95,7 +95,7 @@ public void testDoFinalArguments() throws Exception {
9595
@Override
9696
@Test
9797
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
98-
public void testInvalidIV() throws Exception {
98+
void testInvalidIV() throws Exception {
9999
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
100100
final OpenSsl cipher = OpenSsl
101101
.getInstance(AES.CTR_NO_PADDING);
@@ -111,7 +111,7 @@ public void testInvalidIV() throws Exception {
111111
@Override
112112
@Test
113113
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
114-
public void testInvalidIVClass() throws Exception {
114+
void testInvalidIVClass() throws Exception {
115115
final OpenSsl cipher = OpenSsl.getInstance(AES.CTR_NO_PADDING);
116116
assertNotNull(cipher);
117117

@@ -122,7 +122,7 @@ public void testInvalidIVClass() throws Exception {
122122
@Override
123123
@Test
124124
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
125-
public void testInvalidKey() throws Exception {
125+
void testInvalidKey() throws Exception {
126126
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
127127
final OpenSsl cipher = OpenSsl
128128
.getInstance(AES.CTR_NO_PADDING);
@@ -137,23 +137,23 @@ public void testInvalidKey() throws Exception {
137137

138138
@Test
139139
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
140-
public void testInvalidMode() {
140+
void testInvalidMode() {
141141
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
142142
assertThrows(NoSuchAlgorithmException.class,
143143
() -> OpenSsl.getInstance("AES/CTR2/NoPadding"));
144144
}
145145

146146
@Test
147147
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
148-
public void testInvalidPadding() {
148+
void testInvalidPadding() {
149149
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
150150
assertThrows(NoSuchPaddingException.class,
151151
() -> OpenSsl.getInstance("AES/CTR/NoPadding2"));
152152
}
153153

154154
@Test
155155
@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
156-
public void testUpdateArguments() throws Exception {
156+
void testUpdateArguments() throws Exception {
157157
assumeTrue(OpenSsl.getLoadingFailureReason() == null);
158158
final OpenSsl cipher = OpenSsl
159159
.getInstance(AES.CTR_NO_PADDING);

src/test/java/org/apache/commons/crypto/cipher/OpenSslCommonModeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class OpenSslCommonModeTest {
2626

2727
@Test
28-
public void testUpdateAAD() {
28+
void testUpdateAAD() {
2929
assertThrows(UnsupportedOperationException.class, () -> new OpenSslCommonMode(0, 0, 0).updateAAD(null));
3030
}
3131
}

0 commit comments

Comments
 (0)