Skip to content

Commit 220f329

Browse files
committed
Upgrade to junit-jupiter
1 parent 0ed52b4 commit 220f329

File tree

77 files changed

+1094
-1173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1094
-1173
lines changed

build.gradle

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ buildscript {
1313

1414
ext {
1515
libs = [
16-
jsonSmart: 'net.minidev:json-smart:2.5.0',
17-
slf4jApi: 'org.slf4j:slf4j-api:2.0.11',
18-
gson: 'com.google.code.gson:gson:2.10.1',
19-
hamcrest: 'org.hamcrest:hamcrest:2.2',
16+
jsonSmart : 'net.minidev:json-smart:2.5.0',
17+
slf4jApi : 'org.slf4j:slf4j-api:2.0.11',
18+
gson : 'com.google.code.gson:gson:2.10.1',
19+
hamcrest : 'org.hamcrest:hamcrest:2.2',
2020
jacksonDatabind: 'com.fasterxml.jackson.core:jackson-databind:2.16.1',
21-
jettison: 'org.codehaus.jettison:jettison:1.5.4',
22-
jsonOrg: 'org.json:json:20231013',
23-
tapestryJson: 'org.apache.tapestry:tapestry-json:5.8.3',
24-
jakartaJsonP: 'jakarta.json:jakarta.json-api:2.0.2',
25-
jakartaJsonB: 'jakarta.json.bind:jakarta.json.bind-api:2.0.0',
21+
jettison : 'org.codehaus.jettison:jettison:1.5.4',
22+
jsonOrg : 'org.json:json:20231013',
23+
tapestryJson : 'org.apache.tapestry:tapestry-json:5.8.3',
24+
jakartaJsonP : 'jakarta.json:jakarta.json-api:2.0.2',
25+
jakartaJsonB : 'jakarta.json.bind:jakarta.json.bind-api:2.0.0',
2626

27-
test: [
27+
test : [
2828
'commons-io:commons-io:2.15.0',
29-
'junit:junit:4.13.+',
30-
'org.junit.vintage:junit-vintage-engine:5.10.+',
29+
'org.junit.jupiter:junit-jupiter:5.10.1',
3130
'org.assertj:assertj-core:3.25.1',
3231
'org.hamcrest:hamcrest:2.2',
3332
'org.glassfish:jakarta.json:2.0.1',
@@ -80,9 +79,6 @@ subprojects {
8079

8180
test {
8281
useJUnitPlatform()
83-
84-
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
85-
8682
testLogging {
8783
events "passed", "skipped", "failed"
8884
}
@@ -98,7 +94,7 @@ subprojects {
9894
options.addStringOption('Xdoclint:none', '-quiet')
9995
}
10096

101-
if(JavaVersion.current().isJava9Compatible()) {
97+
if (JavaVersion.current().isJava9Compatible()) {
10298
options.addBooleanOption('html5', true)
10399
}
104100
}

json-path-assert/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
description = "Assertions on Json using JsonPath"
32

43
jar {
54
baseName 'json-path-assert'
6-
bnd (
7-
'Implementation-Title': 'json-path-assert', 'Implementation-Version': archiveVersion
5+
bnd(
6+
'Implementation-Title': 'json-path-assert', 'Implementation-Version': archiveVersion
87
)
98
}
109

@@ -15,5 +14,4 @@ dependencies {
1514

1615
testImplementation libs.jsonSmart
1716
testImplementation libs.test
18-
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
1917
}

json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.jayway.jsonassert;
22

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

55
import java.io.InputStream;
66

77
import static com.jayway.jsonassert.JsonAssert.*;
88
import static org.hamcrest.Matchers.*;
9+
import static org.junit.jupiter.api.Assertions.assertThrows;
910

1011
public class JsonAssertTest {
1112

@@ -52,10 +53,10 @@ public void invalid_path() throws Exception {
5253
}
5354

5455

55-
@Test(expected = AssertionError.class)
56+
@Test
5657
public void has_path() throws Exception {
5758

58-
with(JSON).assertNotDefined("$.store.bicycle[?(@.color == 'red' )]");
59+
assertThrows(AssertionError.class, () -> with(JSON).assertNotDefined("$.store.bicycle[?(@.color == 'red' )]"));
5960
}
6061

6162
@Test
@@ -66,10 +67,10 @@ public void assert_gears() throws Exception {
6667
with(JSON).assertThat("$.store.bicycle[?(@.escape == 'Esc\\b\\f\\n\\r\\t\\u002A')]", is(collectionWithSize(equalTo(1))));
6768
}
6869

69-
@Test(expected = AssertionError.class)
70+
@Test
7071
public void failed_error_message() throws Exception {
7172

72-
with(JSON).assertThat("$.store.book[0].category", endsWith("foobar"));
73+
assertThrows(AssertionError.class, () -> with(JSON).assertThat("$.store.book[0].category", endsWith("foobar")));
7374
}
7475

7576
@Test
@@ -168,25 +169,26 @@ public void testNotDefined() throws Exception {
168169
}
169170

170171

171-
@Test(expected = AssertionError.class)
172+
@Test
172173
public void assert_that_invalid_path_is_thrown() {
173174

174175
JsonAsserter asserter = JsonAssert.with("{\"foo\":\"bar\"}");
175-
asserter.assertEquals("$foo", "bar");
176+
assertThrows(AssertionError.class, () -> asserter.assertEquals("$foo", "bar"));
176177
}
178+
177179
@Test
178180
public void testAssertEqualsInteger() throws Exception {
179181
with(getResourceAsStream("lotto.json")).assertEquals("lotto.winners[0].winnerId", 23);
180182
}
181183

182-
@Test(expected = AssertionError.class)
184+
@Test
183185
public void testAssertEqualsIntegerInvalidExpected() throws Exception {
184-
with(getResourceAsStream("lotto.json")).assertEquals("lotto.winners[0].winnerId", 24);
186+
assertThrows(AssertionError.class, () -> with(getResourceAsStream("lotto.json")).assertEquals("lotto.winners[0].winnerId", 24));
185187
}
186188

187-
@Test(expected = AssertionError.class)
189+
@Test
188190
public void testAssertEqualsIntegerInvalidField() throws Exception {
189-
with(getResourceAsStream("lotto.json")).assertEquals("lotto.winners[0].winnerId1", 24);
191+
assertThrows(AssertionError.class, () -> with(getResourceAsStream("lotto.json")).assertEquals("lotto.winners[0].winnerId1", 24));
190192
}
191193

192194
private InputStream getResourceAsStream(String resourceName) {

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/DemoTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package com.jayway.jsonpath.matchers;
22

3-
import org.junit.Ignore;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.Disabled;
4+
import org.junit.jupiter.api.Test;
55

66
import java.io.File;
77

88
import static com.jayway.jsonpath.matchers.JsonPathMatchers.*;
99
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
1010
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile;
11+
import static org.hamcrest.MatcherAssert.assertThat;
1112
import static org.hamcrest.Matchers.equalTo;
12-
import static org.junit.Assert.assertThat;
1313

14-
@Ignore
14+
@Disabled
1515
public class DemoTest {
1616
@Test
1717
public void shouldFailOnJsonString() {

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/HasNoJsonPathTest.java

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

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

55
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasNoJsonPath;
6+
import static org.hamcrest.MatcherAssert.assertThat;
67
import static org.hamcrest.Matchers.*;
7-
import static org.junit.Assert.assertThat;
88

99
public class HasNoJsonPathTest {
1010
private static final String JSON_STRING = "{" +

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/IsJsonFileTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
import org.hamcrest.Description;
66
import org.hamcrest.Matcher;
77
import org.hamcrest.StringDescription;
8-
import org.junit.AfterClass;
9-
import org.junit.BeforeClass;
10-
import org.junit.Test;
8+
import org.junit.jupiter.api.AfterAll;
9+
import org.junit.jupiter.api.BeforeAll;
10+
import org.junit.jupiter.api.Test;
1111

1212
import java.io.File;
1313

1414
import static com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonFile;
1515
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile;
1616
import static com.jayway.jsonpath.matchers.helpers.TestingMatchers.*;
17+
import static org.hamcrest.MatcherAssert.assertThat;
1718
import static org.hamcrest.Matchers.*;
18-
import static org.junit.Assert.assertThat;
1919

2020
public class IsJsonFileTest {
2121
private static final File BOOKS_JSON = resourceAsFile("books.json");
2222
private static final File INVALID_JSON = resourceAsFile("invalid.json");
2323

24-
@BeforeClass
24+
@BeforeAll
2525
public static void setupStrictJsonParsing() {
2626
Configuration.setDefaults(new StrictParsingConfiguration());
2727
}
2828

29-
@AfterClass
29+
@AfterAll
3030
public static void setupDefaultJsonParsing() {
3131
Configuration.setDefaults(null);
3232
}

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/IsJsonStringTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
import org.hamcrest.Description;
66
import org.hamcrest.Matcher;
77
import org.hamcrest.StringDescription;
8-
import org.junit.AfterClass;
9-
import org.junit.BeforeClass;
10-
import org.junit.Test;
8+
import org.junit.jupiter.api.AfterAll;
9+
import org.junit.jupiter.api.BeforeAll;
10+
import org.junit.jupiter.api.Test;
1111

1212
import static com.jayway.jsonpath.matchers.JsonPathMatchers.isJsonString;
1313
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
1414
import static com.jayway.jsonpath.matchers.helpers.TestingMatchers.*;
15+
import static org.hamcrest.MatcherAssert.assertThat;
1516
import static org.hamcrest.Matchers.*;
16-
import static org.junit.Assert.assertThat;
1717

1818
public class IsJsonStringTest {
1919
private static final String BOOKS_JSON = resource("books.json");
2020

21-
@BeforeClass
21+
@BeforeAll
2222
public static void setupStrictJsonParsing() {
2323
Configuration.setDefaults(new StrictParsingConfiguration());
2424
}
2525

26-
@AfterClass
26+
@AfterAll
2727
public static void setupDefaultJsonParsing() {
2828
Configuration.setDefaults(null);
2929
}

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/IsJsonTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
import org.hamcrest.Description;
77
import org.hamcrest.Matcher;
88
import org.hamcrest.StringDescription;
9-
import org.junit.AfterClass;
10-
import org.junit.BeforeClass;
11-
import org.junit.Test;
9+
import org.junit.jupiter.api.AfterAll;
10+
import org.junit.jupiter.api.BeforeAll;
11+
import org.junit.jupiter.api.Test;
1212

1313
import java.io.File;
1414

1515
import static com.jayway.jsonpath.matchers.JsonPathMatchers.isJson;
1616
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
1717
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile;
1818
import static com.jayway.jsonpath.matchers.helpers.TestingMatchers.withPathEvaluatedTo;
19+
import static org.hamcrest.MatcherAssert.assertThat;
1920
import static org.hamcrest.Matchers.*;
20-
import static org.junit.Assert.assertThat;
2121

2222
public class IsJsonTest {
2323
private static final String VALID_JSON = resource("example.json");
@@ -26,12 +26,12 @@ public class IsJsonTest {
2626
private static final File BOOKS_JSON_FILE = resourceAsFile("books.json");
2727
private static final Object BOOKS_JSON_PARSED = parseJson(BOOKS_JSON_STRING);
2828

29-
@BeforeClass
29+
@BeforeAll
3030
public static void setupStrictJsonParsing() {
3131
Configuration.setDefaults(new StrictParsingConfiguration());
3232
}
3333

34-
@AfterClass
34+
@AfterAll
3535
public static void setupDefaultJsonParsing() {
3636
Configuration.setDefaults(null);
3737
}

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/JsonPathMatchersTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import com.jayway.jsonpath.JsonPath;
55
import com.jayway.jsonpath.ReadContext;
66
import com.jayway.jsonpath.matchers.helpers.StrictParsingConfiguration;
7-
import org.junit.AfterClass;
8-
import org.junit.BeforeClass;
9-
import org.junit.Test;
7+
import org.junit.jupiter.api.AfterAll;
8+
import org.junit.jupiter.api.BeforeAll;
9+
import org.junit.jupiter.api.Test;
1010

1111
import java.io.File;
1212
import java.util.List;
@@ -15,21 +15,21 @@
1515
import static com.jayway.jsonpath.matchers.JsonPathMatchers.*;
1616
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
1717
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile;
18+
import static org.hamcrest.MatcherAssert.assertThat;
1819
import static org.hamcrest.Matchers.*;
19-
import static org.junit.Assert.assertThat;
2020

2121
public class JsonPathMatchersTest {
2222
private static final String BOOKS_JSON = resource("books.json");
2323
private static final String INVALID_JSON = "{ invalid-json }";
2424
private static final File BOOKS_JSON_FILE = resourceAsFile("books.json");
2525

26-
@BeforeClass
26+
@BeforeAll
2727
public static void setupStrictJsonParsing() {
2828
// NOTE: Evaluation depends on the default configuration of JsonPath
2929
Configuration.setDefaults(new StrictParsingConfiguration());
3030
}
3131

32-
@AfterClass
32+
@AfterAll
3333
public static void setupDefaultJsonParsing() {
3434
Configuration.setDefaults(null);
3535
}

json-path-assert/src/test/java/com/jayway/jsonpath/matchers/WithJsonPathTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
import org.hamcrest.Description;
77
import org.hamcrest.Matcher;
88
import org.hamcrest.StringDescription;
9-
import org.junit.Test;
9+
import org.junit.jupiter.api.Test;
1010

1111
import java.util.Collection;
1212
import java.util.List;
1313

1414
import static com.jayway.jsonpath.JsonPath.compile;
1515
import static com.jayway.jsonpath.matchers.JsonPathMatchers.withJsonPath;
1616
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource;
17+
import static org.hamcrest.MatcherAssert.assertThat;
1718
import static org.hamcrest.Matchers.*;
18-
import static org.junit.Assert.assertThat;
19+
import static org.junit.jupiter.api.Assertions.assertThrows;
1920

2021
public class WithJsonPathTest {
2122
private static final ReadContext BOOKS_JSON = JsonPath.parse(resource("books.json"));
@@ -82,9 +83,9 @@ public void shouldMatchJsonPathEvaluatedToCollectionValue() {
8283
assertThat(BOOKS_JSON, withJsonPath("$..book[2].title", hasItem("Moby Dick")));
8384
}
8485

85-
@Test(expected = InvalidPathException.class)
86+
@Test
8687
public void shouldFailOnInvalidJsonPath() {
87-
withJsonPath("$[}");
88+
assertThrows(InvalidPathException.class, () -> withJsonPath("$[}"));
8889
}
8990

9091
@Test

0 commit comments

Comments
 (0)