Skip to content

Commit 5c4f654

Browse files
vyshakputhusseridavidmoten
authored andcommitted
chore: upgrade junit4 to junit5
Import statement was changed. Also the way of handling exception was also updated
1 parent 11c8fb2 commit 5c4f654

File tree

12 files changed

+63
-69
lines changed

12 files changed

+63
-69
lines changed

geo-mem/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
</dependency>
2727
<!-- Test Dependencies -->
2828
<dependency>
29-
<groupId>junit</groupId>
30-
<artifactId>junit</artifactId>
31-
<version>4.13.2</version>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter-api</artifactId>
31+
<version>5.11.3</version>
3232
<scope>test</scope>
3333
</dependency>
3434
<dependency>

geo-mem/src/test/java/com/github/davidmoten/geo/mem/GeomemTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package com.github.davidmoten.geo.mem;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertFalse;
5-
import static org.junit.Assert.assertTrue;
6-
73
import java.util.List;
84
import java.util.UUID;
9-
10-
import org.junit.Test;
11-
125
import com.google.common.base.Optional;
136
import com.google.common.base.Predicate;
147
import com.google.common.collect.Lists;
8+
import org.junit.jupiter.api.Test;
9+
10+
import static org.junit.jupiter.api.Assertions.*;
1511

1612
public class GeomemTest {
1713

@@ -118,7 +114,7 @@ public void testGeomemFindWhenOneEntryOutsideRegion() {
118114
/**
119115
* Indicates 4.5MB per 1000 records. Thus one million entries needs 4500
120116
* entries.
121-
*
117+
*
122118
* @throws InterruptedException
123119
*/
124120
@Test

geo/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
<scope>test</scope>
2828
</dependency>
2929
<dependency>
30-
<groupId>junit</groupId>
31-
<artifactId>junit</artifactId>
32-
<version>4.13.2</version>
30+
<groupId>org.junit.jupiter</groupId>
31+
<artifactId>junit-jupiter-api</artifactId>
32+
<version>5.11.3</version>
3333
<scope>test</scope>
3434
</dependency>
3535
<dependency>

geo/src/test/java/com/github/davidmoten/geo/Base32Test.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import static com.github.davidmoten.geo.Base32.decodeBase32;
44
import static com.github.davidmoten.geo.Base32.encodeBase32;
5-
import static org.junit.Assert.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
import static org.junit.jupiter.api.Assertions.assertThrows;
67

7-
import org.junit.Test;
88

9+
import org.junit.jupiter.api.Test;
910
/**
1011
* Unit tests for {@link Base32}.
1112
*
@@ -66,9 +67,9 @@ public void testEncodePadsToLength12() {
6667
assertEquals("00000000003v", encodeBase32(123));
6768
}
6869

69-
@Test(expected = IllegalArgumentException.class)
70+
@Test
7071
public void testGetCharIndexThrowsExceptionWhenNonBase32CharacterGiven() {
71-
Base32.getCharIndex('?');
72+
assertThrows(IllegalArgumentException.class, () -> Base32.getCharIndex('?'));
7273
}
7374

7475
@Test

geo/src/test/java/com/github/davidmoten/geo/CoverageLongsTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.github.davidmoten.geo;
22

3-
import static org.junit.Assert.assertEquals;
4-
5-
import org.junit.Test;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import org.junit.jupiter.api.Test;
65

76
/**
87
* Unit tests for {@link CoverageLongs}.

geo/src/test/java/com/github/davidmoten/geo/CoverageTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.github.davidmoten.geo;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
5-
6-
import org.junit.Test;
7-
83
import com.google.common.collect.Sets;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
98

109
/**
1110
* Unit tests for {@link Coverage}.

geo/src/test/java/com/github/davidmoten/geo/DirectionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.davidmoten.geo;
22

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

5-
import org.junit.Test;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77
/**
88
* Unit tests for {@link Direction}.

geo/src/test/java/com/github/davidmoten/geo/GeoHashTest.java

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,16 @@
1414
import static com.github.davidmoten.geo.GeoHash.right;
1515
import static com.github.davidmoten.geo.GeoHash.top;
1616
import static com.github.davidmoten.geo.GeoHash.widthDegrees;
17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertNull;
20-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.*;
2118

2219
import java.util.Arrays;
2320
import java.util.Collections;
2421
import java.util.List;
2522
import java.util.Set;
2623
import java.util.TreeSet;
2724

28-
import org.junit.Test;
29-
3025
import com.google.common.collect.Sets;
26+
import org.junit.jupiter.api.Test;
3127

3228
/**
3329
* Unit tests for {@link GeoHash}.
@@ -62,14 +58,14 @@ public void encodeHashToLong() {
6258
assertEquals(0x65c0000000000002L, GeoHash.encodeHashToLong(41.842967, -72.727175, 2));
6359
}
6460

65-
@Test(expected = IllegalArgumentException.class)
61+
@Test
6662
public void fromLongToStringInvalid() {
67-
GeoHash.fromLongToString(0xff);
63+
assertThrows(IllegalArgumentException.class, () -> GeoHash.fromLongToString(0xff));
6864
}
6965

70-
@Test(expected = IllegalArgumentException.class)
66+
@Test
7167
public void fromLongToStringZero() {
72-
GeoHash.fromLongToString(0);
68+
assertThrows(IllegalArgumentException.class, () -> GeoHash.fromLongToString(0));
7369
}
7470

7571
@Test
@@ -100,50 +96,50 @@ public void testFromGeoHashDotOrg() {
10096
public void testHashOfNonDefaultLength() {
10197
assertEquals("6gkzwg", encodeHash(-25.382708, -49.265506, 6));
10298
}
103-
99+
104100
@Test
105101
public void testHashOfLength12() {
106102
assertEquals("6gkzwgjzn820", encodeHash(-25.382708, -49.265506, 12));
107103
}
108104

109-
@Test(expected = IllegalArgumentException.class)
105+
@Test
110106
public void testHashOfLength13() {
111-
encodeHash(-25.382708, -49.265506, 13);
107+
assertThrows(IllegalArgumentException.class, () -> encodeHash(-25.382708, -49.265506, 13));
112108
}
113109

114-
@Test(expected = IllegalArgumentException.class)
110+
@Test
115111
public void testHashOfLength20() {
116-
encodeHash(-25.382708, -49.265506, 20);
112+
assertThrows(IllegalArgumentException.class, () -> encodeHash(-25.382708, -49.265506, 20));
117113
}
118114

119-
@Test(expected = IllegalArgumentException.class)
115+
@Test
120116
public void testHashEncodeGivenNonPositiveLength() {
121-
encodeHash(-25.382708, -49.265506, 0);
117+
assertThrows(IllegalArgumentException.class, () -> encodeHash(-25.382708, -49.265506, 0));
122118
}
123119

124120
@Test
125121
public void testAnother() {
126122
assertEquals("sew1c2vs2q5r", encodeHash(20, 31));
127123
}
128124

129-
@Test(expected = IllegalArgumentException.class)
125+
@Test
130126
public void testEncodeHashWithLatTooBig() {
131-
encodeHash(1000, 100, 4);
127+
assertThrows(IllegalArgumentException.class, () -> encodeHash(1000, 100, 4));
132128
}
133129

134-
@Test(expected = IllegalArgumentException.class)
130+
@Test
135131
public void testEncodeHashWithLatTooSmall() {
136-
encodeHash(-1000, 100, 4);
132+
assertThrows(IllegalArgumentException.class, () -> encodeHash(-1000, 100, 4));
137133
}
138134

139-
@Test(expected = IllegalArgumentException.class)
135+
@Test
140136
public void testAdjacentHashThrowsExceptionGivenNullHash() {
141-
GeoHash.adjacentHash(null, Direction.RIGHT);
137+
assertThrows(IllegalArgumentException.class, () -> GeoHash.adjacentHash(null, Direction.RIGHT));
142138
}
143139

144-
@Test(expected = IllegalArgumentException.class)
140+
@Test
145141
public void testAdjacentHashThrowsExceptionGivenBlankHash() {
146-
GeoHash.adjacentHash("", Direction.RIGHT);
142+
assertThrows(IllegalArgumentException.class, () -> GeoHash.adjacentHash("", Direction.RIGHT));
147143
}
148144

149145
@Test
@@ -404,10 +400,12 @@ public void testCoverBoundingBoxWithHashLength3AroundBoston() {
404400
assertEquals(Sets.newHashSet("dr7", "dre", "drk", "drs"), hashes);
405401
}
406402

407-
@Test(expected = IllegalArgumentException.class)
403+
@Test
408404
public void testCoverBoundingBoxWithZeroLengthThrowsException() {
409-
coverBoundingBox(SCHENECTADY_LAT, SCHENECTADY_LON, HARTFORD_LAT,
410-
HARTFORD_LON, 0);
405+
assertThrows(IllegalArgumentException.class, () ->
406+
coverBoundingBox(SCHENECTADY_LAT, SCHENECTADY_LON, HARTFORD_LAT,
407+
HARTFORD_LON, 0)
408+
);
411409
}
412410

413411
@Test
@@ -612,10 +610,10 @@ public void testNeighboursAtLongitudeMinus180() {
612610
assertEquals("2pbpbpbpbpbr", neighbors.get(I_RIGHT_BOT));
613611
}
614612

615-
616-
@Test(expected=IllegalArgumentException.class)
613+
614+
@Test
617615
public void testCoverBoundingBoxPreconditionLat() {
618-
GeoHash.coverBoundingBox(0, 100, 10, 120);
616+
assertThrows(IllegalArgumentException.class, () -> GeoHash.coverBoundingBox(0, 100, 10, 120));
619617
}
620618

621619
}

geo/src/test/java/com/github/davidmoten/geo/LatLongTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.davidmoten.geo;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77
/**
88
* Unit tests for {@link LatLong}.

geo/src/test/java/com/github/davidmoten/geo/TestingUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.github.davidmoten.geo;
22

3-
import static org.junit.Assert.assertTrue;
43

54
import java.lang.reflect.Constructor;
65
import java.lang.reflect.InvocationTargetException;
76
import java.lang.reflect.Modifier;
87

8+
import static org.junit.jupiter.api.Assertions.assertTrue;
9+
910
/**
1011
* Utility methods for unit tests.
1112
*
@@ -17,7 +18,7 @@ public class TestingUtil {
1718
/**
1819
* Checks that a class has a no-argument private constructor and calls that
1920
* constructor to instantiate the class.
20-
*
21+
*
2122
* @param cls
2223
*/
2324
public static <T> void callConstructorAndCheckIsPrivate(Class<T> cls) {
@@ -43,5 +44,4 @@ public static <T> void callConstructorAndCheckIsPrivate(Class<T> cls) {
4344
throw new RuntimeException(e);
4445
}
4546
}
46-
4747
}

0 commit comments

Comments
 (0)