Skip to content

Commit 9b20755

Browse files
committed
Switch to JUint 5
1 parent 0d64ce3 commit 9b20755

File tree

6 files changed

+74
-49
lines changed

6 files changed

+74
-49
lines changed

pom.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@
3737
</developers>
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>
42+
<version>5.10.1</version>
43+
<scope>test</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.hamcrest</groupId>
47+
<artifactId>java-hamcrest</artifactId>
48+
<version>2.0.0.0</version>
4349
<scope>test</scope>
4450
</dependency>
4551
</dependencies>
@@ -121,6 +127,11 @@
121127
<target>11</target>
122128
</configuration>
123129
</plugin>
130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-surefire-plugin</artifactId>
133+
<version>3.2.2</version>
134+
</plugin>
124135
<plugin>
125136
<groupId>org.eluder.coveralls</groupId>
126137
<artifactId>coveralls-maven-plugin</artifactId>

src/test/java/com/maxmind/db/DecoderTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import static org.hamcrest.CoreMatchers.containsString;
44
import static org.hamcrest.MatcherAssert.assertThat;
5-
import static org.junit.Assert.assertArrayEquals;
6-
import static org.junit.Assert.assertEquals;
7-
import static org.junit.Assert.assertThrows;
5+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertThrows;
88

99
import java.io.File;
1010
import java.io.IOException;
@@ -20,7 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222
import java.util.UUID;
23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
@SuppressWarnings({"boxing", "static-method"})
2626
public class DecoderTest {
@@ -434,42 +434,42 @@ private static <T> void testTypeDecoding(Type type, Map<T, byte[]> tests)
434434

435435
// XXX - this could be streamlined
436436
if (type.equals(Type.BYTES)) {
437-
assertArrayEquals(desc, (byte[]) expect, decoder.decode(0, byte[].class));
437+
assertArrayEquals((byte[]) expect, decoder.decode(0, byte[].class), desc);
438438
} else if (type.equals(Type.ARRAY)) {
439-
assertEquals(desc, expect, decoder.decode(0, List.class));
439+
assertEquals(expect, decoder.decode(0, List.class), desc);
440440
} else if (type.equals(Type.UINT16)
441441
|| type.equals(Type.INT32)) {
442-
assertEquals(desc, expect, decoder.decode(0, Integer.class));
442+
assertEquals(expect, decoder.decode(0, Integer.class), desc);
443443
} else if (type.equals(Type.UINT32)
444444
|| type.equals(Type.POINTER)) {
445-
assertEquals(desc, expect, decoder.decode(0, Long.class));
445+
assertEquals(expect, decoder.decode(0, Long.class), desc);
446446
} else if (type.equals(Type.UINT64)
447447
|| type.equals(Type.UINT128)) {
448-
assertEquals(desc, expect, decoder.decode(0, BigInteger.class));
448+
assertEquals(expect, decoder.decode(0, BigInteger.class), desc);
449449
} else if (type.equals(Type.DOUBLE)) {
450-
assertEquals(desc, expect, decoder.decode(0, Double.class));
450+
assertEquals(expect, decoder.decode(0, Double.class), desc);
451451
} else if (type.equals(Type.FLOAT)) {
452-
assertEquals(desc, expect, decoder.decode(0, Float.class));
452+
assertEquals(expect, decoder.decode(0, Float.class), desc);
453453
} else if (type.equals(Type.UTF8_STRING)) {
454-
assertEquals(desc, expect, decoder.decode(0, String.class));
454+
assertEquals(expect, decoder.decode(0, String.class), desc);
455455
} else if (type.equals(Type.BOOLEAN)) {
456-
assertEquals(desc, expect, decoder.decode(0, Boolean.class));
456+
assertEquals(expect, decoder.decode(0, Boolean.class), desc);
457457
} else {
458458
// We hit this for Type.MAP.
459459

460460
Map got = decoder.decode(0, Map.class);
461461
Map expectMap = (Map) expect;
462462

463-
assertEquals(desc, expectMap.size(), got.size());
463+
assertEquals(expectMap.size(), got.size(), desc);
464464

465465
for (Object keyObject : expectMap.keySet()) {
466466
String key = (String) keyObject;
467467
Object value = expectMap.get(key);
468468

469469
if (value instanceof Object[]) {
470-
assertArrayEquals(desc, (Object[]) value, (Object[]) got.get(key));
470+
assertArrayEquals((Object[]) value, (Object[]) got.get(key), desc);
471471
} else {
472-
assertEquals(desc, value, got.get(key));
472+
assertEquals(value, got.get(key), desc);
473473
}
474474
}
475475
}

src/test/java/com/maxmind/db/MultiThreadedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.maxmind.db;
22

3-
import static org.junit.Assert.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import java.io.IOException;
66
import java.net.InetAddress;
@@ -12,7 +12,7 @@
1212
import java.util.concurrent.ExecutorService;
1313
import java.util.concurrent.Executors;
1414
import java.util.concurrent.Future;
15-
import org.junit.Test;
15+
import org.junit.jupiter.api.Test;
1616

1717
public class MultiThreadedTest {
1818

src/test/java/com/maxmind/db/NetworkTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.maxmind.db;
22

3-
import static junit.framework.TestCase.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import java.net.InetAddress;
66
import java.net.UnknownHostException;
7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88

99
public class NetworkTest {
1010
@Test

src/test/java/com/maxmind/db/PointerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.maxmind.db;
22

3-
import static org.junit.Assert.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import com.maxmind.db.Reader.FileMode;
66
import java.io.File;
77
import java.io.IOException;
88
import java.util.HashMap;
99
import java.util.Map;
10-
import org.junit.Test;
10+
import org.junit.jupiter.api.Test;
1111

1212
public class PointerTest {
1313
@SuppressWarnings("static-method")

src/test/java/com/maxmind/db/ReaderTest.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import static org.hamcrest.CoreMatchers.containsString;
44
import static org.hamcrest.CoreMatchers.equalTo;
55
import static org.hamcrest.MatcherAssert.assertThat;
6-
import static org.junit.Assert.assertArrayEquals;
7-
import static org.junit.Assert.assertEquals;
8-
import static org.junit.Assert.assertFalse;
9-
import static org.junit.Assert.assertNotEquals;
10-
import static org.junit.Assert.assertNotNull;
11-
import static org.junit.Assert.assertNull;
12-
import static org.junit.Assert.assertThrows;
13-
import static org.junit.Assert.assertTrue;
6+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertFalse;
9+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
10+
import static org.junit.jupiter.api.Assertions.assertNotNull;
11+
import static org.junit.jupiter.api.Assertions.assertNull;
12+
import static org.junit.jupiter.api.Assertions.assertThrows;
13+
import static org.junit.jupiter.api.Assertions.assertTrue;
1414

1515
import java.io.File;
1616
import java.io.IOException;
@@ -27,19 +27,19 @@
2727
import java.util.Map;
2828
import java.util.Vector;
2929
import java.util.concurrent.ConcurrentHashMap;
30-
import org.junit.After;
31-
import org.junit.Before;
32-
import org.junit.Test;
30+
import org.junit.jupiter.api.AfterEach;
31+
import org.junit.jupiter.api.BeforeEach;
32+
import org.junit.jupiter.api.Test;
3333

3434
public class ReaderTest {
3535
private Reader testReader;
3636

37-
@Before
37+
@BeforeEach
3838
public void setupReader() {
3939
this.testReader = null;
4040
}
4141

42-
@After
42+
@AfterEach
4343
public void teardownReader() throws IOException {
4444
if (this.testReader != null) {
4545
this.testReader.close();
@@ -93,9 +93,11 @@ public void testNetworks() throws IOException, InvalidDatabaseException, Invalid
9393

9494
InetAddress actualIPInData = InetAddress.getByName(data.get("ip"));
9595

96-
assertEquals("expected ip address",
96+
assertEquals(
9797
iteration.getNetwork().getNetworkAddress(),
98-
actualIPInData);
98+
actualIPInData,
99+
"expected ip address"
100+
);
99101
}
100102

101103
reader.close();
@@ -1208,7 +1210,7 @@ private void testMetadata(Reader reader, int ipVersion, long recordSize) {
12081210

12091211
Metadata metadata = reader.getMetadata();
12101212

1211-
assertEquals("major version", 2, metadata.getBinaryFormatMajorVersion());
1213+
assertEquals(2, metadata.getBinaryFormatMajorVersion(), "major version");
12121214
assertEquals(0, metadata.getBinaryFormatMinorVersion());
12131215
assertEquals(ipVersion, metadata.getIpVersion());
12141216
assertEquals("Test", metadata.getDatabaseType());
@@ -1237,8 +1239,11 @@ private void testIpV4(Reader reader, File file) throws IOException {
12371239
Map<String, String> data = new HashMap<>();
12381240
data.put("ip", address);
12391241

1240-
assertEquals("found expected data record for " + address + " in "
1241-
+ file, data, reader.get(InetAddress.getByName(address), Map.class));
1242+
assertEquals(
1243+
data,
1244+
reader.get(InetAddress.getByName(address), Map.class),
1245+
"found expected data record for " + address + " in " + file
1246+
);
12421247
}
12431248

12441249
Map<String, String> pairs = new HashMap<>();
@@ -1253,8 +1258,11 @@ private void testIpV4(Reader reader, File file) throws IOException {
12531258
Map<String, String> data = new HashMap<>();
12541259
data.put("ip", pairs.get(address));
12551260

1256-
assertEquals("found expected data record for " + address + " in "
1257-
+ file, data, reader.get(InetAddress.getByName(address), Map.class));
1261+
assertEquals(
1262+
data,
1263+
reader.get(InetAddress.getByName(address), Map.class),
1264+
"found expected data record for " + address + " in " + file
1265+
);
12581266
}
12591267

12601268
for (String ip : new String[] {"1.1.1.33", "255.254.253.123"}) {
@@ -1271,8 +1279,11 @@ private void testIpV6(Reader reader, File file) throws IOException {
12711279
Map<String, String> data = new HashMap<>();
12721280
data.put("ip", address);
12731281

1274-
assertEquals("found expected data record for " + address + " in "
1275-
+ file, data, reader.get(InetAddress.getByName(address), Map.class));
1282+
assertEquals(
1283+
data,
1284+
reader.get(InetAddress.getByName(address), Map.class),
1285+
"found expected data record for " + address + " in " + file
1286+
);
12761287
}
12771288

12781289
Map<String, String> pairs = new HashMap<>();
@@ -1289,8 +1300,11 @@ private void testIpV6(Reader reader, File file) throws IOException {
12891300
Map<String, String> data = new HashMap<>();
12901301
data.put("ip", pairs.get(address));
12911302

1292-
assertEquals("found expected data record for " + address + " in "
1293-
+ file, data, reader.get(InetAddress.getByName(address), Map.class));
1303+
assertEquals(
1304+
data,
1305+
reader.get(InetAddress.getByName(address), Map.class),
1306+
"found expected data record for " + address + " in " + file
1307+
);
12941308
}
12951309

12961310
for (String ip : new String[] {"1.1.1.33", "255.254.253.123", "89fa::"}) {

0 commit comments

Comments
 (0)