Skip to content

Commit 3bd95cf

Browse files
committed
Upgrade to JUnit 5.
1 parent c0ebe6c commit 3bd95cf

File tree

10 files changed

+65
-65
lines changed

10 files changed

+65
-65
lines changed

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

httprpc/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ repositories {
2828
dependencies {
2929
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
3030

31-
testCompile 'junit:junit:4.12'
31+
testCompile("org.junit.jupiter:junit-jupiter-api:5.4.2")
32+
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.4.2")
33+
}
34+
35+
test {
36+
useJUnitPlatform()
3237
}
3338

3439
jar {

httprpc/src/test/java/org/httprpc/beans/BeanAdapterTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
package org.httprpc.beans;
1616

1717
import org.httprpc.AbstractTest;
18-
import org.junit.Assert;
19-
import org.junit.Test;
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.Test;
2020

2121
import java.math.BigInteger;
2222
import java.net.MalformedURLException;
@@ -71,8 +71,8 @@ public void testBeanAdapter() throws MalformedURLException {
7171

7272
Map<String, Object> actual = new BeanAdapter(new TestBean());
7373

74-
Assert.assertEquals(expected, actual);
75-
Assert.assertNull(actual.get("ignored"));
74+
Assertions.assertEquals(expected, actual);
75+
Assertions.assertNull(actual.get("ignored"));
7676
}
7777

7878
@Test
@@ -85,7 +85,7 @@ public void testValueAt() {
8585
))
8686
);
8787

88-
Assert.assertEquals(Integer.valueOf(123), BeanAdapter.valueAt(map, "a.b.c"));
88+
Assertions.assertEquals(Integer.valueOf(123), BeanAdapter.valueAt(map, "a.b.c"));
8989
}
9090

9191
@Test
@@ -94,7 +94,7 @@ public void testDescribe() {
9494

9595
BeanAdapter.describe(TestBean.class, structures);
9696

97-
Assert.assertEquals(
97+
Assertions.assertEquals(
9898
"{\n" +
9999
" URL: url,\n" +
100100
" bigInteger: number,\n" +
@@ -118,7 +118,7 @@ public void testDescribe() {
118118
structures.get(TestBean.class)
119119
);
120120

121-
Assert.assertEquals(
121+
Assertions.assertEquals(
122122
"{\n" +
123123
" flag: boolean\n" +
124124
"}",

httprpc/src/test/java/org/httprpc/io/CSVDecoderTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
import java.util.stream.StreamSupport;
2323

2424
import org.httprpc.AbstractTest;
25-
import org.httprpc.io.CSVDecoder;
26-
import org.junit.Assert;
27-
import org.junit.Test;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.Test;
2827

2928
public class CSVDecoderTest extends AbstractTest {
3029
@Test
@@ -55,6 +54,6 @@ public void testRead() throws IOException {
5554
Iterable<Map<String, String>> cursor = csvDecoder.read(reader);
5655
List<Map<String, String>> actual = StreamSupport.stream(cursor.spliterator(), false).collect(Collectors.toList());
5756

58-
Assert.assertEquals(expected, actual);
57+
Assertions.assertEquals(expected, actual);
5958
}
6059
}

httprpc/src/test/java/org/httprpc/io/CSVEncoderTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
import java.util.Map;
2323

2424
import org.httprpc.AbstractTest;
25-
import org.httprpc.io.CSVEncoder;
26-
import org.junit.Assert;
27-
import org.junit.Test;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.Test;
2827

2928
public class CSVEncoderTest extends AbstractTest {
3029
@Test
@@ -57,6 +56,6 @@ public void testWrite() throws IOException {
5756

5857
csvEncoder.write(values, writer);
5958

60-
Assert.assertEquals(expected, writer.toString());
59+
Assertions.assertEquals(expected, writer.toString());
6160
}
6261
}

httprpc/src/test/java/org/httprpc/io/JSONDecoderTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,30 @@
2020
import java.util.Map;
2121

2222
import org.httprpc.AbstractTest;
23-
import org.httprpc.io.JSONDecoder;
24-
import org.junit.Assert;
25-
import org.junit.Test;
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
2625

2726
public class JSONDecoderTest extends AbstractTest {
2827
@Test
2928
public void testString() throws IOException {
30-
Assert.assertEquals("abcdéfg", decode("\"abcdéfg\""));
31-
Assert.assertEquals("\b\f\r\n\t", decode("\"\\b\\f\\r\\n\\t\""));
32-
Assert.assertEquals("é", decode("\"\\u00E9\""));
29+
Assertions.assertEquals("abcdéfg", decode("\"abcdéfg\""));
30+
Assertions.assertEquals("\b\f\r\n\t", decode("\"\\b\\f\\r\\n\\t\""));
31+
Assertions.assertEquals("é", decode("\"\\u00E9\""));
3332
}
3433

3534
@Test
3635
public void testNumber() throws IOException {
37-
Assert.assertEquals(42L, (long)decode("42"));
38-
Assert.assertEquals(42.5, (double)decode("42.5"), 0);
36+
Assertions.assertEquals(42L, (long)decode("42"));
37+
Assertions.assertEquals(42.5, decode("42.5"), 0);
3938

40-
Assert.assertEquals(-789L, (long)decode("-789"));
41-
Assert.assertEquals(-789.10, (double)decode("-789.10"), 0);
39+
Assertions.assertEquals(-789L, (long)decode("-789"));
40+
Assertions.assertEquals(-789.10, decode("-789.10"), 0);
4241
}
4342

4443
@Test
4544
public void testBoolean() throws IOException {
46-
Assert.assertEquals(true, decode("true"));
47-
Assert.assertEquals(false, decode("false"));
45+
Assertions.assertEquals(true, decode("true"));
46+
Assertions.assertEquals(false, decode("false"));
4847
}
4948

5049
@Test
@@ -59,7 +58,7 @@ public void testArray() throws IOException {
5958

6059
List<?> list = decode("[\"abc\",\t123,,, true,\n[1, 2.0, 3.0],\n{\"x\": 1, \"y\": 2.0, \"z\": 3.0}]");
6160

62-
Assert.assertEquals(expected, list);
61+
Assertions.assertEquals(expected, list);
6362
}
6463

6564
@Test
@@ -74,7 +73,7 @@ public void testObject() throws IOException {
7473

7574
Map<String, ?> map = decode("{\"a\": \"abc\", \"b\":\t123,,, \"c\": true,\n\"d\": [1, 2.0, 3.0],\n\"e\": {\"x\": 1, \"y\": 2.0, \"z\": 3.0}}");
7675

77-
Assert.assertEquals(expected, map);
76+
Assertions.assertEquals(expected, map);
7877
}
7978

8079
@Test
@@ -107,9 +106,9 @@ public void testMissingObjectClosingBracket() throws IOException {
107106
decode("{\"a\":1, \"b\":2, \"c\":3 ");
108107
}
109108

110-
@Test(expected=IOException.class)
111-
public void testInvalidCharacters() throws IOException {
112-
decode("xyz");
109+
@Test
110+
public void testInvalidCharacters() {
111+
Assertions.assertThrows(IOException.class, () -> decode("xyz"));
113112
}
114113

115114
private static <T> T decode(String text) throws IOException {

httprpc/src/test/java/org/httprpc/io/JSONEncoderTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,44 @@
2323
import java.util.Map;
2424

2525
import org.httprpc.AbstractTest;
26-
import org.httprpc.io.JSONEncoder;
27-
import org.junit.Assert;
28-
import org.junit.Test;
26+
import org.junit.jupiter.api.Assertions;
27+
import org.junit.jupiter.api.Test;
2928

3029
public class JSONEncoderTest extends AbstractTest {
3130
@Test
3231
public void testString() throws IOException {
33-
Assert.assertEquals("\"abcdéfg\"", encode("abcdéfg"));
34-
Assert.assertEquals("\"\\b\\f\\r\\n\\t\"", encode("\b\f\r\n\t"));
32+
Assertions.assertEquals("\"abcdéfg\"", encode("abcdéfg"));
33+
Assertions.assertEquals("\"\\b\\f\\r\\n\\t\"", encode("\b\f\r\n\t"));
3534
}
3635

3736
@Test
3837
public void testNumber() throws IOException {
39-
Assert.assertEquals("42", encode(42L));
40-
Assert.assertEquals("42.5", encode(42.5));
38+
Assertions.assertEquals("42", encode(42L));
39+
Assertions.assertEquals("42.5", encode(42.5));
4140

42-
Assert.assertEquals("-789", encode(-789));
43-
Assert.assertEquals("-789.1", encode(-789.10));
41+
Assertions.assertEquals("-789", encode(-789));
42+
Assertions.assertEquals("-789.1", encode(-789.10));
4443
}
4544

4645
@Test
4746
public void testBoolean() throws IOException {
48-
Assert.assertEquals("true", encode(true));
49-
Assert.assertEquals("false", encode(false));
47+
Assertions.assertEquals("true", encode(true));
48+
Assertions.assertEquals("false", encode(false));
5049
}
5150

5251
@Test
5352
public void testDate() throws IOException {
54-
Assert.assertEquals("0", encode(new Date(0)));
53+
Assertions.assertEquals("0", encode(new Date(0)));
5554
}
5655

5756
@Test
5857
public void testURL() throws IOException {
59-
Assert.assertEquals("\"http://localhost:8080\"", encode(new URL("http://localhost:8080")));
58+
Assertions.assertEquals("\"http://localhost:8080\"", encode(new URL("http://localhost:8080")));
6059
}
6160

6261
@Test
6362
public void testEnum() throws IOException {
64-
Assert.assertEquals("3", encode(DayOfWeek.THURSDAY));
63+
Assertions.assertEquals("3", encode(DayOfWeek.THURSDAY));
6564
}
6665

6766
@Test
@@ -90,7 +89,7 @@ public void testArray() throws IOException {
9089
mapOf(entry("x", 1L), entry("y", 2.0), entry("z", 3.0))
9190
);
9291

93-
Assert.assertEquals(expected, encode(list));
92+
Assertions.assertEquals(expected, encode(list));
9493
}
9594

9695
@Test
@@ -119,7 +118,7 @@ public void testObject() throws IOException {
119118
entry("e", mapOf(entry("x", 1L), entry("y", 2.0), entry("z", 3.0)))
120119
);
121120

122-
Assert.assertEquals(expected, encode(map));
121+
Assertions.assertEquals(expected, encode(map));
123122
}
124123

125124
@Test
@@ -132,7 +131,7 @@ public void testCompact() throws IOException {
132131
entry("c", 3)
133132
);
134133

135-
Assert.assertEquals(expected, encode(map, true));
134+
Assertions.assertEquals(expected, encode(map, true));
136135
}
137136

138137
private static String encode(Object value) throws IOException {

httprpc/src/test/java/org/httprpc/io/XMLEncoderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import javax.xml.transform.stream.StreamSource;
3232

3333
import org.httprpc.AbstractTest;
34-
import org.junit.Assert;
35-
import org.junit.Test;
34+
import org.junit.jupiter.api.Assertions;
35+
import org.junit.jupiter.api.Test;
3636

3737
public class XMLEncoderTest extends AbstractTest {
3838
@Test
@@ -76,7 +76,7 @@ public void testWrite() throws IOException {
7676

7777
xmlEncoder.write(values, writer);
7878

79-
Assert.assertEquals(expected, writer.toString());
79+
Assertions.assertEquals(expected, writer.toString());
8080
}
8181

8282
@Test
@@ -131,6 +131,6 @@ public void testTransform() throws IOException {
131131
throw new IOException(exception);
132132
}
133133

134-
Assert.assertEquals(expected, writer.toString());
134+
Assertions.assertEquals(expected, writer.toString());
135135
}
136136
}

httprpc/src/test/java/org/httprpc/sql/ParametersTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,28 @@
1414

1515
package org.httprpc.sql;
1616

17-
import org.httprpc.sql.Parameters;
18-
import org.junit.Assert;
19-
import org.junit.Test;
17+
import org.junit.jupiter.api.Assertions;
18+
import org.junit.jupiter.api.Test;
2019

2120
public class ParametersTest {
2221
@Test
2322
public void testParameters() {
2423
Parameters parameters = Parameters.parse("insert into xyz (foo, bar) values :foo, :bar");
2524

26-
Assert.assertEquals("insert into xyz (foo, bar) values ?, ?", parameters.getSQL());
25+
Assertions.assertEquals("insert into xyz (foo, bar) values ?, ?", parameters.getSQL());
2726
}
2827

2928
@Test
3029
public void testColon() {
3130
Parameters parameters = Parameters.parse("select * from xyz where foo = 'a:b:c'");
3231

33-
Assert.assertEquals("select * from xyz where foo = 'a:b:c'", parameters.getSQL());
32+
Assertions.assertEquals("select * from xyz where foo = 'a:b:c'", parameters.getSQL());
3433
}
3534

3635
@Test
3736
public void testDoubleColon() {
3837
Parameters parameters = Parameters.parse("select 'ab:c'::varchar(16) as abc");
3938

40-
Assert.assertEquals("select 'ab:c'::varchar(16) as abc", parameters.getSQL());
39+
Assertions.assertEquals("select 'ab:c'::varchar(16) as abc", parameters.getSQL());
4140
}
4241
}

httprpc/src/test/java/org/httprpc/sql/ResultSetAdapterTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
package org.httprpc.sql;
1616

1717
import java.sql.Date;
18-
import java.sql.SQLException;
1918
import java.util.List;
2019
import java.util.Map;
2120
import java.util.stream.Collectors;
2221
import java.util.stream.StreamSupport;
2322

2423
import org.httprpc.AbstractTest;
25-
import org.junit.Assert;
26-
import org.junit.Test;
24+
import org.junit.jupiter.api.Assertions;
25+
import org.junit.jupiter.api.Test;
2726

2827
public class ResultSetAdapterTest extends AbstractTest {
2928
private List<?> expected = listOf(
@@ -68,6 +67,6 @@ public void testResultSetAdapter() {
6867
actual = StreamSupport.stream(adapter.spliterator(), false).collect(Collectors.toList());
6968
}
7069

71-
Assert.assertEquals(expected, actual);
70+
Assertions.assertEquals(expected, actual);
7271
}
7372
}

0 commit comments

Comments
 (0)