Skip to content

Commit f0db9f7

Browse files
JUnit Jupiter best practices
Co-authored-by: Moderne <[email protected]>
1 parent a414fed commit f0db9f7

15 files changed

+161
-252
lines changed

src/test/java/org/codehaus/plexus/interpolation/EnvarBasedValueSourceTest.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
package org.codehaus.plexus.interpolation;
22

3-
/*
4-
* Copyright 2007 The Codehaus Foundation.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
18-
19-
import java.io.IOException;
203
import java.util.HashMap;
214
import java.util.Map;
225

@@ -28,15 +11,15 @@
2811
import static org.junit.jupiter.api.Assertions.assertNotNull;
2912
import static org.junit.jupiter.api.Assertions.assertNull;
3013

31-
public class EnvarBasedValueSourceTest {
14+
class EnvarBasedValueSourceTest {
3215

3316
@BeforeEach
34-
public void setUp() {
17+
void setUp() {
3518
EnvarBasedValueSource.resetStatics();
3619
}
3720

3821
@Test
39-
void testNoArgConstructorIsCaseSensitive() throws IOException {
22+
void noArgConstructorIsCaseSensitive() throws Exception {
4023
OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() {
4124
public Map<String, String> getEnvMap() {
4225
HashMap<String, String> map = new HashMap<String, String>();
@@ -54,7 +37,7 @@ public Map<String, String> getEnvMap() {
5437
}
5538

5639
@Test
57-
void testCaseInsensitive() throws IOException {
40+
void caseInsensitive() throws Exception {
5841
OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.EnvVarSource() {
5942
public Map<String, String> getEnvMap() {
6043
HashMap<String, String> map = new HashMap<String, String>();
@@ -72,7 +55,7 @@ public Map<String, String> getEnvMap() {
7255
}
7356

7457
@Test
75-
void testGetRealEnvironmentVariable() throws IOException {
58+
void getRealEnvironmentVariable() throws Exception {
7659
OperatingSystemUtils.setEnvVarSource(new OperatingSystemUtils.DefaultEnvVarSource());
7760

7861
EnvarBasedValueSource source = new EnvarBasedValueSource();

src/test/java/org/codehaus/plexus/interpolation/FeedbackingValueSourceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
import static org.junit.jupiter.api.Assertions.assertNull;
2424
import static org.junit.jupiter.api.Assertions.assertTrue;
2525

26-
public class FeedbackingValueSourceTest {
26+
class FeedbackingValueSourceTest {
2727

2828
@Test
29-
public void testStandalone() {
29+
void standalone() {
3030
ValueSource valueSource = new FeedbackingValueSource();
3131
assertNull(valueSource.getValue("test"));
3232
assertEquals(1, valueSource.getFeedback().size());
3333
assertEquals("'test' not resolved", valueSource.getFeedback().iterator().next());
3434
}
3535

3636
@Test
37-
public void testAfterResolvedExpression() throws InterpolationException {
37+
void afterResolvedExpression() throws Exception {
3838
StringSearchInterpolator interpolator = new StringSearchInterpolator();
3939
interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val")));
4040
interpolator.addValueSource(new FeedbackingValueSource());
@@ -43,7 +43,7 @@ public void testAfterResolvedExpression() throws InterpolationException {
4343
}
4444

4545
@Test
46-
public void testBeforeResolvedExpression() throws InterpolationException {
46+
void beforeResolvedExpression() throws Exception {
4747
StringSearchInterpolator interpolator = new StringSearchInterpolator();
4848
interpolator.addValueSource(new FeedbackingValueSource("Resolving ${expression}"));
4949
interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val")));
@@ -53,7 +53,7 @@ public void testBeforeResolvedExpression() throws InterpolationException {
5353
}
5454

5555
@Test
56-
public void testAfterNotResolvedExpression() throws InterpolationException {
56+
void afterNotResolvedExpression() throws Exception {
5757
StringSearchInterpolator interpolator = new StringSearchInterpolator();
5858
interpolator.addValueSource(new MapBasedValueSource(singletonMap("key", "val")));
5959
interpolator.addValueSource(new FeedbackingValueSource());

src/test/java/org/codehaus/plexus/interpolation/InterpolatorFilterReaderTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
* @author cstamas
4242
*
4343
*/
44-
public class InterpolatorFilterReaderTest {
44+
class InterpolatorFilterReaderTest {
4545
/*
4646
* Added and commented by jdcasey@03-Feb-2005 because it is a bug in the InterpolationFilterReader.
4747
* kenneyw@15-04-2005 fixed the bug.
4848
*/
4949
@Test
50-
public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception {
50+
void shouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() throws Exception {
5151
Map m = new HashMap();
5252
m.put("test", "TestValue");
5353

@@ -60,7 +60,7 @@ public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken() t
6060
* kenneyw@14-04-2005 Added test to check above fix.
6161
*/
6262
@Test
63-
public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Exception {
63+
void shouldNotInterpolateExpressionWithMissingEndToken() throws Exception {
6464
Map m = new HashMap();
6565
m.put("test", "TestValue");
6666

@@ -70,7 +70,7 @@ public void testShouldNotInterpolateExpressionWithMissingEndToken() throws Excep
7070
}
7171

7272
@Test
73-
public void testShouldNotInterpolateWithMalformedStartToken() throws Exception {
73+
void shouldNotInterpolateWithMalformedStartToken() throws Exception {
7474
Map m = new HashMap();
7575
m.put("test", "testValue");
7676

@@ -80,7 +80,7 @@ public void testShouldNotInterpolateWithMalformedStartToken() throws Exception {
8080
}
8181

8282
@Test
83-
public void testShouldNotInterpolateWithMalformedEndToken() throws Exception {
83+
void shouldNotInterpolateWithMalformedEndToken() throws Exception {
8484
Map m = new HashMap();
8585
m.put("test", "testValue");
8686

@@ -90,7 +90,7 @@ public void testShouldNotInterpolateWithMalformedEndToken() throws Exception {
9090
}
9191

9292
@Test
93-
public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception {
93+
void defaultInterpolationWithNonInterpolatedValueAtEnd() throws Exception {
9494
Map m = new HashMap();
9595
m.put("name", "jason");
9696
m.put("noun", "asshole");
@@ -101,7 +101,7 @@ public void testDefaultInterpolationWithNonInterpolatedValueAtEnd() throws Excep
101101
}
102102

103103
@Test
104-
public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exception {
104+
void defaultInterpolationWithInterpolatedValueAtEnd() throws Exception {
105105
Map m = new HashMap();
106106
m.put("name", "jason");
107107
m.put("noun", "asshole");
@@ -112,7 +112,7 @@ public void testDefaultInterpolationWithInterpolatedValueAtEnd() throws Exceptio
112112
}
113113

114114
@Test
115-
public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception {
115+
void interpolationWithInterpolatedValueAtEndWithCustomToken() throws Exception {
116116
Map m = new HashMap();
117117
m.put("name", "jason");
118118
m.put("noun", "asshole");
@@ -123,7 +123,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomToken() throws
123123
}
124124

125125
@Test
126-
public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception {
126+
void interpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString() throws Exception {
127127
Map m = new HashMap();
128128
m.put("name", "jason");
129129
m.put("noun", "asshole");
@@ -134,7 +134,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomS
134134
}
135135

136136
@Test
137-
public void testEscape() throws Exception {
137+
void escape() throws Exception {
138138
Map m = new HashMap();
139139
m.put("name", "jason");
140140
m.put("noun", "asshole");
@@ -145,7 +145,7 @@ public void testEscape() throws Exception {
145145
}
146146

147147
@Test
148-
public void testEscapeAtStart() throws Exception {
148+
void escapeAtStart() throws Exception {
149149
Map m = new HashMap();
150150
m.put("name", "jason");
151151
m.put("noun", "asshole");
@@ -156,7 +156,7 @@ public void testEscapeAtStart() throws Exception {
156156
}
157157

158158
@Test
159-
public void testEscapeOnlyAtStart() throws Exception {
159+
void escapeOnlyAtStart() throws Exception {
160160
Map m = new HashMap();
161161
m.put("name", "jason");
162162
m.put("noun", "asshole");
@@ -168,7 +168,7 @@ public void testEscapeOnlyAtStart() throws Exception {
168168
}
169169

170170
@Test
171-
public void testEscapeOnlyAtStartDefaultToken() throws Exception {
171+
void escapeOnlyAtStartDefaultToken() throws Exception {
172172
Map m = new HashMap();
173173
m.put("name", "jason");
174174
m.put("noun", "asshole");
@@ -180,7 +180,7 @@ public void testEscapeOnlyAtStartDefaultToken() throws Exception {
180180
}
181181

182182
@Test
183-
public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception {
183+
void shouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throws Exception {
184184
List prefixes = new ArrayList();
185185

186186
prefixes.add("prefix1");
@@ -211,7 +211,7 @@ public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes() throw
211211
}
212212

213213
@Test
214-
public void testShouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception {
214+
void shouldDetectRecursiveExpressionWithPrefixAndWithout() throws Exception {
215215
List prefixes = new ArrayList();
216216

217217
prefixes.add("prefix1");

src/test/java/org/codehaus/plexus/interpolation/PrefixAwareRecursionInterceptorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import static org.junit.jupiter.api.Assertions.assertFalse;
2626
import static org.junit.jupiter.api.Assertions.assertTrue;
2727

28-
public class PrefixAwareRecursionInterceptorTest {
28+
class PrefixAwareRecursionInterceptorTest {
2929

3030
@Test
31-
public void testFindExpression() {
31+
void findExpression() {
3232
PrefixAwareRecursionInterceptor receptor =
3333
new PrefixAwareRecursionInterceptor(Collections.singleton("prefix."));
3434

@@ -45,7 +45,7 @@ public void testFindExpression() {
4545
}
4646

4747
@Test
48-
public void testFindExpressionWithDifferentPrefix() {
48+
void findExpressionWithDifferentPrefix() {
4949
PrefixAwareRecursionInterceptor receptor =
5050
new PrefixAwareRecursionInterceptor(Arrays.asList(new String[] {"prefix.", "other."}));
5151

@@ -61,7 +61,7 @@ public void testFindExpressionWithDifferentPrefix() {
6161
}
6262

6363
@Test
64-
public void testFindExpressionWithoutPrefix() {
64+
void findExpressionWithoutPrefix() {
6565
PrefixAwareRecursionInterceptor receptor =
6666
new PrefixAwareRecursionInterceptor(Arrays.asList(new String[] {"prefix.", "other."}));
6767

src/test/java/org/codehaus/plexus/interpolation/PrefixedObjectValueSourceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
import static org.junit.jupiter.api.Assertions.assertNull;
2525

26-
public class PrefixedObjectValueSourceTest {
26+
class PrefixedObjectValueSourceTest {
2727

2828
@Test
29-
public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed() {
29+
void emptyExpressionResultsInNullReturnNoPrefixUsed() {
3030
String target = "Target object";
3131

3232
List prefixes = new ArrayList();
@@ -40,7 +40,7 @@ public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed() {
4040
}
4141

4242
@Test
43-
public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot() {
43+
void emptyExpressionResultsInNullReturnPrefixUsedWithDot() {
4444
String target = "Target object";
4545

4646
List prefixes = new ArrayList();
@@ -54,7 +54,7 @@ public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot() {
5454
}
5555

5656
@Test
57-
public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithoutDot() {
57+
void emptyExpressionResultsInNullReturnPrefixUsedWithoutDot() {
5858
String target = "Target object";
5959

6060
List prefixes = new ArrayList();

src/test/java/org/codehaus/plexus/interpolation/PrefixedValueSourceWrapperTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import static org.junit.jupiter.api.Assertions.assertEquals;
2424
import static org.junit.jupiter.api.Assertions.assertNull;
2525

26-
public class PrefixedValueSourceWrapperTest {
26+
class PrefixedValueSourceWrapperTest {
2727

2828
@Test
29-
public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix() {
29+
void shouldReturnValueForPropertyVSWRappedWithSinglePrefix() {
3030
String prefix = "prefix.";
3131
String key = "key";
3232
String value = "value";
@@ -41,7 +41,7 @@ public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix() {
4141
}
4242

4343
@Test
44-
public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSinglePrefix() {
44+
void shouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSinglePrefix() {
4545
String prefix = "prefix.";
4646
String otherPrefix = "other.";
4747
String key = "key";
@@ -57,7 +57,7 @@ public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSing
5757
}
5858

5959
@Test
60-
public void testShouldNullForMissingValueInPropertyVSWRappedWithSinglePrefix() {
60+
void shouldNullForMissingValueInPropertyVSWRappedWithSinglePrefix() {
6161
String prefix = "prefix.";
6262
String key = "key";
6363

src/test/java/org/codehaus/plexus/interpolation/PropertiesBasedValueSourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import static org.junit.jupiter.api.Assertions.assertNotNull;
2424
import static org.junit.jupiter.api.Assertions.assertNull;
2525

26-
public class PropertiesBasedValueSourceTest {
26+
class PropertiesBasedValueSourceTest {
2727

2828
@Test
29-
public void testPropertyShouldReturnValueFromProperties() {
29+
void propertyShouldReturnValueFromProperties() {
3030
Properties props = new Properties();
3131

3232
String key = "key";
@@ -40,7 +40,7 @@ public void testPropertyShouldReturnValueFromProperties() {
4040
}
4141

4242
@Test
43-
public void testPropertyShouldReturnNullWhenPropertyMissing() {
43+
void propertyShouldReturnNullWhenPropertyMissing() {
4444
Properties props = new Properties();
4545

4646
String key = "key";

0 commit comments

Comments
 (0)