Skip to content

Commit 69928bc

Browse files
committed
Use JUnit 5 conventions on method visibility
1 parent 275d733 commit 69928bc

13 files changed

Lines changed: 35 additions & 34 deletions

src/test/java/org/apache/commons/codec/binary/Base16Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Base16Test {
4646
/**
4747
* @return the random.
4848
*/
49-
public Random getRandom() {
49+
Random getRandom() {
5050
return this.random;
5151
}
5252

src/test/java/org/apache/commons/codec/binary/Base64Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static Stream<Object> testIsBase64Url() {
173173
/**
174174
* @return the random.
175175
*/
176-
public Random getRandom() {
176+
Random getRandom() {
177177
return this.random;
178178
}
179179

src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ static long getPresumableFreeMemory() {
113113
}
114114

115115
BaseNCodec codec;
116-
@BeforeEach
117116

118-
public void setUp() {
117+
@BeforeEach
118+
void setUp() {
119119
codec = new BaseNCodec(0, 0, 0, 0) {
120120
@Override
121121
void decode(final byte[] array, final int i, final int length, final Context context) {

src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ void assertDecodeObject(final byte[] bits, final String encodeMe) throws Decoder
9292
}
9393

9494
@BeforeEach
95-
public void setUp() throws Exception {
95+
void setUp() throws Exception {
9696
this.instance = new BinaryCodec();
9797
}
9898

9999
@AfterEach
100-
public void tearDown() throws Exception {
100+
void tearDown() throws Exception {
101101
this.instance = null;
102102
}
103103

src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Blake3TestVectorsTest {
4242
private static final byte[] CTX =
4343
"BLAKE3 2019-12-27 16:29:52 test vectors context".getBytes(StandardCharsets.UTF_8);
4444

45-
public static Stream<Arguments> data() {
45+
static Stream<Arguments> data() {
4646
return Stream.of(
4747
Arguments.of(
4848
0,
@@ -268,15 +268,15 @@ public static Stream<Arguments> data() {
268268

269269
@ParameterizedTest
270270
@MethodSource("data")
271-
public void hashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
271+
void hashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
272272
initData(inputLength, hash, keyedHash, deriveKey);
273273
final byte[] actual = hasher.update(inputByteArray).doFinalize(hashByteArray.length);
274274
assertArrayEquals(hashByteArray, actual);
275275
}
276276

277277
@ParameterizedTest
278278
@MethodSource("data")
279-
public void hashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
279+
void hashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
280280
initData(inputLength, hash, keyedHash, deriveKey);
281281
final byte[] actual = Blake3.hash(inputByteArray);
282282
assertArrayEquals(Arrays.copyOf(this.hashByteArray, 32), actual);
@@ -295,7 +295,7 @@ private void initData(final int inputLength, final String hash, final String key
295295

296296
@ParameterizedTest
297297
@MethodSource("data")
298-
public void keyDerivation(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
298+
void keyDerivation(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
299299
initData(inputLength, hash, keyedHash, deriveKey);
300300
final byte[] actual = kdfHasher.update(inputByteArray).doFinalize(deriveKeyByteArray.length);
301301
assertArrayEquals(deriveKeyByteArray, actual);
@@ -306,15 +306,15 @@ public void keyDerivation(final int inputLength, final String hash, final String
306306

307307
@ParameterizedTest
308308
@MethodSource("data")
309-
public void keyedHashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
309+
void keyedHashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
310310
initData(inputLength, hash, keyedHash, deriveKey);
311311
final byte[] actual = keyedHasher.update(inputByteArray).doFinalize(keyedHashByteArray.length);
312312
assertArrayEquals(keyedHashByteArray, actual);
313313
}
314314

315315
@ParameterizedTest
316316
@MethodSource("data")
317-
public void keyedHashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
317+
void keyedHashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
318318
initData(inputLength, hash, keyedHash, deriveKey);
319319
final byte[] actual = Blake3.keyedHash(KEY, inputByteArray);
320320
assertArrayEquals(Arrays.copyOf(keyedHashByteArray, 32), actual);

src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class HmacAlgorithmsTest {
9898
static Path TempFile;
9999

100100
// TODO HMAC_SHA_224
101-
public static Stream<Arguments> data() {
101+
static Stream<Arguments> data() {
102102
List<Arguments> list = Arrays.asList(
103103
// @formatter:off
104104
Arguments.of(HmacAlgorithms.HMAC_MD5, STANDARD_MD5_RESULT_BYTES, STANDARD_MD5_RESULT_STRING),
@@ -115,20 +115,21 @@ public static Stream<Arguments> data() {
115115
}
116116

117117
@BeforeAll
118-
public static void init() throws IOException {
118+
static void init() throws IOException {
119119
TempFile = Files.createFile(TempDir.resolve(HmacAlgorithmsTest.class.getSimpleName()));
120120
Files.write(TempFile, STANDARD_PHRASE_BYTES, StandardOpenOption.CREATE);
121121
}
122122

123123
private DigestUtilsTest digestUtilsTest;
124+
124125
@BeforeEach
125-
public void setUp() throws Exception {
126+
void setUp() throws Exception {
126127
digestUtilsTest = new DigestUtilsTest();
127128
digestUtilsTest.setUp();
128129
}
129130

130131
@AfterEach
131-
public void tearDown() throws Exception {
132+
void tearDown() throws Exception {
132133
digestUtilsTest.tearDown();
133134
digestUtilsTest = null;
134135
}

src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
class MessageDigestAlgorithmsTest {
4949

5050
@BeforeAll
51-
public static void checkValues() throws Exception {
51+
static void checkValues() throws Exception {
5252
final Field[] fields = MessageDigestAlgorithms.class.getDeclaredFields();
5353
boolean ok = true;
5454
int psf = 0;
@@ -89,7 +89,7 @@ private static boolean contains(final String key) {
8989
return false;
9090
}
9191

92-
public static String[] data() {
92+
static String[] data() {
9393
return MessageDigestAlgorithms.values();
9494
}
9595

@@ -116,13 +116,13 @@ private RandomAccessFile getTestRandomAccessFile() {
116116
}
117117

118118
@BeforeEach
119-
public void setUp() throws Exception {
119+
void setUp() throws Exception {
120120
digestUtilsTest = new DigestUtilsTest();
121121
digestUtilsTest.setUp();
122122
}
123123

124124
@AfterEach
125-
public void tearDown() throws Exception {
125+
void tearDown() throws Exception {
126126
digestUtilsTest.tearDown();
127127
digestUtilsTest = null;
128128
}

src/test/java/org/apache/commons/codec/digest/XXHash32Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static long copy(final InputStream input, final OutputStream output, fin
4040
return IOUtils.copyLarge(input, output, new byte[bufferSize]);
4141
}
4242

43-
public static Stream<Arguments> data() {
43+
static Stream<Arguments> data() {
4444
// @formatter:off
4545
return Stream.of(
4646
// reference checksums created with xxh32sum
@@ -62,7 +62,7 @@ private static byte[] toByteArray(final InputStream input) throws IOException {
6262

6363
private String expectedChecksum;
6464

65-
public void initData(final String path, final String c) throws Exception {
65+
private void initData(final String path, final String c) throws Exception {
6666
final URL url = XXHash32Test.class.getClassLoader().getResource(path);
6767
if (url == null) {
6868
throw new FileNotFoundException("couldn't find " + path);
@@ -73,7 +73,7 @@ public void initData(final String path, final String c) throws Exception {
7373

7474
@ParameterizedTest
7575
@MethodSource("data")
76-
public void verifyChecksum(final String path, final String c) throws Exception {
76+
void verifyChecksum(final String path, final String c) throws Exception {
7777
initData(path, c);
7878
final XXHash32 hasher = new XXHash32();
7979
try (InputStream in = Files.newInputStream(file)) {
@@ -85,7 +85,7 @@ public void verifyChecksum(final String path, final String c) throws Exception {
8585

8686
@ParameterizedTest
8787
@MethodSource("data")
88-
public void verifyIncrementalChecksum(final String path, final String c) throws Exception {
88+
void verifyIncrementalChecksum(final String path, final String c) throws Exception {
8989
initData(path, c);
9090
final XXHash32 hasher = new XXHash32();
9191
try (InputStream in = Files.newInputStream(file)) {

src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ColognePhoneticTest extends AbstractStringEncoderTest<ColognePhonetic> {
7474

7575
@AfterAll
7676
// Check that all possible input sequence conditions are represented
77-
public static void finishTests() {
77+
static void finishTests() {
7878
int errors = 0;
7979
for (final String m : MATCHES) {
8080
if (!hasTestCase(m)) {

src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ private void assertDoubleMetaphone(final String expected, final String source) {
10211021
/**
10221022
* Tests encoding APIs in one place.
10231023
*/
1024-
public void assertDoubleMetaphoneAlt(final String expected, final String source) {
1024+
private void assertDoubleMetaphoneAlt(final String expected, final String source) {
10251025
assertEquals(expected, getStringEncoder().doubleMetaphone(source, true));
10261026
}
10271027

@@ -1030,7 +1030,7 @@ protected DoubleMetaphone createStringEncoder() {
10301030
return new DoubleMetaphone();
10311031
}
10321032

1033-
public void doubleMetaphoneEqualTest(final String[][] pairs, final boolean useAlternate) {
1033+
private void doubleMetaphoneEqualTest(final String[][] pairs, final boolean useAlternate) {
10341034
validateFixture(pairs);
10351035
for (final String[] pair : pairs) {
10361036
final String name0 = pair[0];
@@ -1045,7 +1045,7 @@ public void doubleMetaphoneEqualTest(final String[][] pairs, final boolean useAl
10451045
}
10461046
}
10471047

1048-
public void doubleMetaphoneNotEqualTest(final boolean alternate) {
1048+
private void doubleMetaphoneNotEqualTest(final boolean alternate) {
10491049
assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Brain", "Band", alternate));
10501050
assertFalse(getStringEncoder().isDoubleMetaphoneEqual("Band", "Brain", alternate));
10511051

@@ -1243,7 +1243,7 @@ void testSetMaxCodeLength() {
12431243
assertEquals("AMP", doubleMetaphone.doubleMetaphone(value, true), "Max=3 Alternate");
12441244
}
12451245

1246-
public void validateFixture(final String[][] pairs) {
1246+
private void validateFixture(final String[][] pairs) {
12471247
if (pairs.length == 0) {
12481248
fail("Test fixture is empty");
12491249
}

0 commit comments

Comments
 (0)