Skip to content

Commit dad9f18

Browse files
committed
Move to Junit5
1 parent f541b1a commit dad9f18

15 files changed

+218
-125
lines changed

pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737

3838
<dependencies>
3939
<dependency>
40-
<groupId>junit</groupId>
41-
<artifactId>junit</artifactId>
42-
<version>4.13.2</version>
40+
<groupId>org.junit.jupiter</groupId>
41+
<artifactId>junit-jupiter</artifactId>
4342
<scope>test</scope>
4443
</dependency>
4544
</dependencies>

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,29 @@
1616
* limitations under the License.
1717
*/
1818

19-
import static org.junit.Assert.*;
19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
import static org.junit.jupiter.api.Assertions.assertNull;
2022

2123
import java.io.IOException;
2224
import java.util.HashMap;
2325
import java.util.Map;
2426

2527
import org.codehaus.plexus.interpolation.os.OperatingSystemUtils;
26-
import org.junit.Before;
27-
import org.junit.Test;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.Test;
2830

2931
public class EnvarBasedValueSourceTest
3032
{
3133

32-
@Before
34+
@BeforeEach
3335
public void setUp()
3436
{
3537
EnvarBasedValueSource.resetStatics();
3638
}
3739

3840
@Test
39-
public void testNoArgConstructorIsCaseSensitive()
41+
void testNoArgConstructorIsCaseSensitive()
4042
throws IOException
4143
{
4244
OperatingSystemUtils.setEnvVarSource( new OperatingSystemUtils.EnvVarSource()
@@ -58,7 +60,7 @@ public Map<String, String> getEnvMap()
5860
}
5961

6062
@Test
61-
public void testCaseInsensitive()
63+
void testCaseInsensitive()
6264
throws IOException
6365
{
6466
OperatingSystemUtils.setEnvVarSource( new OperatingSystemUtils.EnvVarSource()
@@ -80,7 +82,7 @@ public Map<String, String> getEnvMap()
8082
}
8183

8284
@Test
83-
public void testGetRealEnvironmentVariable()
85+
void testGetRealEnvironmentVariable()
8486
throws IOException
8587
{
8688
OperatingSystemUtils.setEnvVarSource( new OperatingSystemUtils.DefaultEnvVarSource() );
@@ -90,7 +92,7 @@ public void testGetRealEnvironmentVariable()
9092
String realEnvVar = "JAVA_HOME";
9193

9294
String realValue = System.getenv().get( realEnvVar );
93-
assertNotNull( "Can't run this test until " + realEnvVar + " env variable is set", realValue );
95+
assertNotNull( realValue , "Can't run this test until " + realEnvVar + " env variable is set");
9496

9597
assertEquals( realValue, source.getValue( realEnvVar ) );
9698
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
* SOFTWARE.
2525
*/
2626

27+
import static org.junit.jupiter.api.Assertions.assertEquals;
28+
2729
import java.io.StringReader;
2830
import java.util.ArrayList;
2931
import java.util.HashMap;
3032
import java.util.List;
3133
import java.util.Map;
3234

33-
import junit.framework.TestCase;
35+
import org.junit.jupiter.api.Test;
3436

3537
/**
3638
* InterpolatorFilterReaderTest, heavily based on InterpolationFilterReaderTest. Heh, even the test strings remained the
@@ -40,12 +42,12 @@
4042
*
4143
*/
4244
public class InterpolatorFilterReaderTest
43-
extends TestCase
4445
{
4546
/*
4647
* Added and commented by jdcasey@03-Feb-2005 because it is a bug in the InterpolationFilterReader.
4748
* kenneyw@15-04-2005 fixed the bug.
4849
*/
50+
@Test
4951
public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken()
5052
throws Exception
5153
{
@@ -60,6 +62,7 @@ public void testShouldNotInterpolateExpressionAtEndOfDataWithInvalidEndToken()
6062
/*
6163
* kenneyw@14-04-2005 Added test to check above fix.
6264
*/
65+
@Test
6366
public void testShouldNotInterpolateExpressionWithMissingEndToken()
6467
throws Exception
6568
{
@@ -71,6 +74,7 @@ public void testShouldNotInterpolateExpressionWithMissingEndToken()
7174
assertEquals( "This is a ${test, really", interpolate( testStr, m ) );
7275
}
7376

77+
@Test
7478
public void testShouldNotInterpolateWithMalformedStartToken()
7579
throws Exception
7680
{
@@ -82,6 +86,7 @@ public void testShouldNotInterpolateWithMalformedStartToken()
8286
assertEquals( "This is a $!test} again", interpolate( foo, m ) );
8387
}
8488

89+
@Test
8590
public void testShouldNotInterpolateWithMalformedEndToken()
8691
throws Exception
8792
{
@@ -93,6 +98,7 @@ public void testShouldNotInterpolateWithMalformedEndToken()
9398
assertEquals( "This is a ${test!} again", interpolate( foo, m ) );
9499
}
95100

101+
@Test
96102
public void testDefaultInterpolationWithNonInterpolatedValueAtEnd()
97103
throws Exception
98104
{
@@ -105,6 +111,7 @@ public void testDefaultInterpolationWithNonInterpolatedValueAtEnd()
105111
assertEquals( "jason is an asshole. ${not.interpolated}", interpolate( foo, m ) );
106112
}
107113

114+
@Test
108115
public void testDefaultInterpolationWithInterpolatedValueAtEnd()
109116
throws Exception
110117
{
@@ -117,6 +124,7 @@ public void testDefaultInterpolationWithInterpolatedValueAtEnd()
117124
assertEquals( "jason is an asshole", interpolate( foo, m ) );
118125
}
119126

127+
@Test
120128
public void testInterpolationWithInterpolatedValueAtEndWithCustomToken()
121129
throws Exception
122130
{
@@ -129,6 +137,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomToken()
129137
assertEquals( "jason is an asshole", interpolate( foo, m, "@{", "}" ) );
130138
}
131139

140+
@Test
132141
public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomString()
133142
throws Exception
134143
{
@@ -141,6 +150,7 @@ public void testInterpolationWithInterpolatedValueAtEndWithCustomTokenAndCustomS
141150
assertEquals( "jason is an asshole", interpolate( foo, m, "@", "@" ) );
142151
}
143152

153+
@Test
144154
public void testEscape()
145155
throws Exception
146156
{
@@ -153,6 +163,7 @@ public void testEscape()
153163
assertEquals( "jason is an ${noun}", interpolate( foo, m, "\\" ) );
154164
}
155165

166+
@Test
156167
public void testEscapeAtStart()
157168
throws Exception
158169
{
@@ -165,6 +176,7 @@ public void testEscapeAtStart()
165176
assertEquals( "${name} is an ${noun}", interpolate( foo, m, "\\" ) );
166177
}
167178

179+
@Test
168180
public void testEscapeOnlyAtStart()
169181
throws Exception
170182
{
@@ -178,6 +190,7 @@ public void testEscapeOnlyAtStart()
178190
assertEquals( "@name@ is an asshole", result );
179191
}
180192

193+
@Test
181194
public void testEscapeOnlyAtStartDefaultToken()
182195
throws Exception
183196
{
@@ -191,6 +204,7 @@ public void testEscapeOnlyAtStartDefaultToken()
191204
assertEquals( "${name} is an asshole", result );
192205
}
193206

207+
@Test
194208
public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes()
195209
throws Exception
196210
{
@@ -224,6 +238,7 @@ public void testShouldDetectRecursiveExpressionPassingThroughTwoPrefixes()
224238
assertEquals( input, buf.toString() );
225239
}
226240

241+
@Test
227242
public void testShouldDetectRecursiveExpressionWithPrefixAndWithout()
228243
throws Exception
229244
{

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
* limitations under the License.
1717
*/
1818

19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
1923
import java.util.Arrays;
2024
import java.util.Collections;
2125

22-
import junit.framework.TestCase;
26+
import org.junit.jupiter.api.Test;
2327

2428
public class PrefixAwareRecursionInterceptorTest
25-
extends TestCase
2629
{
2730

31+
@Test
2832
public void testFindExpression()
2933
{
3034
PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(
@@ -42,6 +46,7 @@ public void testFindExpression()
4246
assertFalse( receptor.hasRecursiveExpression( expr ) );
4347
}
4448

49+
@Test
4550
public void testFindExpressionWithDifferentPrefix()
4651
{
4752
PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(
@@ -61,6 +66,7 @@ public void testFindExpressionWithDifferentPrefix()
6166
assertFalse( receptor.hasRecursiveExpression( expr ) );
6267
}
6368

69+
@Test
6470
public void testFindExpressionWithoutPrefix()
6571
{
6672
PrefixAwareRecursionInterceptor receptor = new PrefixAwareRecursionInterceptor(

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
* limitations under the License.
1717
*/
1818

19+
import static org.junit.jupiter.api.Assertions.assertNull;
20+
1921
import java.util.ArrayList;
2022
import java.util.List;
2123

22-
import junit.framework.TestCase;
24+
import org.junit.jupiter.api.Test;
2325

2426
public class PrefixedObjectValueSourceTest
25-
extends TestCase
2627
{
27-
28+
29+
@Test
2830
public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed()
2931
{
3032
String target = "Target object";
@@ -39,6 +41,7 @@ public void testEmptyExpressionResultsInNullReturn_NoPrefixUsed()
3941
assertNull( result );
4042
}
4143

44+
@Test
4245
public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot()
4346
{
4447
String target = "Target object";
@@ -53,6 +56,7 @@ public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithDot()
5356
assertNull( result );
5457
}
5558

59+
@Test
5660
public void testEmptyExpressionResultsInNullReturn_PrefixUsedWithoutDot()
5761
{
5862
String target = "Target object";

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
* limitations under the License.
1717
*/
1818

19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertNull;
21+
1922
import java.util.Properties;
2023

21-
import junit.framework.TestCase;
24+
import org.junit.jupiter.api.Test;
2225

2326
public class PrefixedValueSourceWrapperTest
24-
extends TestCase
2527
{
2628

29+
@Test
2730
public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix()
2831
{
2932
String prefix = "prefix.";
@@ -38,6 +41,7 @@ public void testShouldReturnValueForPropertyVSWRappedWithSinglePrefix()
3841
assertEquals( value, wrapper.getValue( prefix + key ) );
3942
}
4043

44+
@Test
4145
public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSinglePrefix()
4246
{
4347
String prefix = "prefix.";
@@ -53,6 +57,7 @@ public void testShouldReturnNullForIncorrectPrefixUsingPropertyVSWRappedWithSing
5357
assertNull( wrapper.getValue( otherPrefix + key ) );
5458
}
5559

60+
@Test
5661
public void testShouldNullForMissingValueInPropertyVSWRappedWithSinglePrefix()
5762
{
5863
String prefix = "prefix.";

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
* limitations under the License.
1717
*/
1818

19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
import static org.junit.jupiter.api.Assertions.assertNull;
21+
1922
import java.util.Properties;
2023

21-
import junit.framework.TestCase;
24+
import org.junit.jupiter.api.Test;
2225

2326
public class PropertiesBasedValueSourceTest
24-
extends TestCase
2527
{
2628

29+
@Test
2730
public void testPropertyShouldReturnValueFromProperties()
2831
{
2932
Properties props = new Properties();
@@ -38,6 +41,7 @@ public void testPropertyShouldReturnValueFromProperties()
3841
assertNotNull( vs.getValue( key ) );
3942
}
4043

44+
@Test
4145
public void testPropertyShouldReturnNullWhenPropertyMissing()
4246
{
4347
Properties props = new Properties();

0 commit comments

Comments
 (0)