Skip to content

Commit ccb9696

Browse files
authored
Bump JUnit version to 5.7.2 (networknt#447)
1 parent 8b26d19 commit ccb9696

Some content is hidden

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

44 files changed

+396
-383
lines changed

pom.xml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
<version.common-lang3>3.7</version.common-lang3>
6868
<version.joni>2.1.31</version.joni>
6969
<version.logback>1.2.3</version.logback>
70-
<version.junit>4.13.1</version.junit>
70+
<version.junit>5.7.2</version.junit>
7171
<version.mockito>2.7.21</version.mockito>
72-
<version.hamcrest>1.3</version.hamcrest>
72+
<version.hamcrest>2.2</version.hamcrest>
7373
<version.undertow>2.2.4.Final</version.undertow>
7474
</properties>
7575
<dependencies>
@@ -101,8 +101,8 @@
101101
<scope>test</scope>
102102
</dependency>
103103
<dependency>
104-
<groupId>junit</groupId>
105-
<artifactId>junit</artifactId>
104+
<groupId>org.junit.jupiter</groupId>
105+
<artifactId>junit-jupiter-engine</artifactId>
106106
<version>${version.junit}</version>
107107
<scope>test</scope>
108108
</dependency>
@@ -114,7 +114,7 @@
114114
</dependency>
115115
<dependency>
116116
<groupId>org.hamcrest</groupId>
117-
<artifactId>hamcrest-all</artifactId>
117+
<artifactId>hamcrest</artifactId>
118118
<version>${version.hamcrest}</version>
119119
<scope>test</scope>
120120
</dependency>
@@ -269,14 +269,7 @@
269269
<plugin>
270270
<groupId>org.apache.maven.plugins</groupId>
271271
<artifactId>maven-surefire-plugin</artifactId>
272-
<version>2.19.1</version>
273-
<dependencies>
274-
<dependency>
275-
<groupId>org.apache.maven.surefire</groupId>
276-
<artifactId>surefire-junit47</artifactId>
277-
<version>2.19.1</version>
278-
</dependency>
279-
</dependencies>
272+
<version>2.22.2</version>
280273
</plugin>
281274
<!-- JACOCO added for code coverage -->
282275
<plugin>

src/test/java/com/networknt/schema/CollectorContextTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222

23-
import org.junit.After;
24-
import org.junit.Assert;
25-
import org.junit.Before;
26-
import org.junit.Test;
23+
import org.junit.jupiter.api.AfterEach;
24+
import org.junit.jupiter.api.Assertions;
25+
import org.junit.jupiter.api.BeforeEach;
26+
import org.junit.jupiter.api.Test;
2727

2828
import java.io.IOException;
2929
import java.util.*;
@@ -38,12 +38,12 @@ public class CollectorContextTest {
3838

3939
private JsonSchema jsonSchemaForCombine;
4040

41-
@Before
41+
@BeforeEach
4242
public void setup() throws Exception {
4343
setupSchema();
4444
}
4545

46-
@After
46+
@AfterEach
4747
public void cleanup() {
4848
if (CollectorContext.getInstance() != null) {
4949
CollectorContext.getInstance().reset();
@@ -54,12 +54,12 @@ public void cleanup() {
5454
@Test
5555
public void testCollectorContextWithKeyword() throws Exception {
5656
ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}");
57-
Assert.assertEquals(0, validationResult.getValidationMessages().size());
57+
Assertions.assertEquals(0, validationResult.getValidationMessages().size());
5858
List<String> contextValues = (List<String>) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR);
59-
Assert.assertEquals(0, validationResult.getValidationMessages().size());
60-
Assert.assertEquals(2, contextValues.size());
61-
Assert.assertEquals(contextValues.get(0), "actual_value_added_to_context1");
62-
Assert.assertEquals(contextValues.get(1), "actual_value_added_to_context2");
59+
Assertions.assertEquals(0, validationResult.getValidationMessages().size());
60+
Assertions.assertEquals(2, contextValues.size());
61+
Assertions.assertEquals(contextValues.get(0), "actual_value_added_to_context1");
62+
Assertions.assertEquals(contextValues.get(1), "actual_value_added_to_context2");
6363
}
6464

6565
@SuppressWarnings("unchecked")
@@ -89,17 +89,17 @@ public void testCollectorContextWithMultipleThreads() throws Exception {
8989
ValidationResult validationResult2 = validationRunnable2.getValidationResult();
9090
ValidationResult validationResult3 = validationRunnable3.getValidationResult();
9191

92-
Assert.assertEquals(0, validationResult1.getValidationMessages().size());
93-
Assert.assertEquals(0, validationResult2.getValidationMessages().size());
94-
Assert.assertEquals(0, validationResult3.getValidationMessages().size());
92+
Assertions.assertEquals(0, validationResult1.getValidationMessages().size());
93+
Assertions.assertEquals(0, validationResult2.getValidationMessages().size());
94+
Assertions.assertEquals(0, validationResult3.getValidationMessages().size());
9595

9696
List<String> contextValue1 = (List<String>) validationResult1.getCollectorContext().get(SAMPLE_COLLECTOR);
9797
List<String> contextValue2 = (List<String>) validationResult2.getCollectorContext().get(SAMPLE_COLLECTOR);
9898
List<String> contextValue3 = (List<String>) validationResult3.getCollectorContext().get(SAMPLE_COLLECTOR);
9999

100-
Assert.assertEquals(contextValue1.get(0), "actual_value_added_to_context1");
101-
Assert.assertEquals(contextValue2.get(0), "actual_value_added_to_context2");
102-
Assert.assertEquals(contextValue3.get(0), "actual_value_added_to_context3");
100+
Assertions.assertEquals(contextValue1.get(0), "actual_value_added_to_context1");
101+
Assertions.assertEquals(contextValue2.get(0), "actual_value_added_to_context2");
102+
Assertions.assertEquals(contextValue3.get(0), "actual_value_added_to_context3");
103103
}
104104

105105
@SuppressWarnings("unchecked")
@@ -109,8 +109,8 @@ public void testCollectorGetAll() throws JsonMappingException, JsonProcessingExc
109109
ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper
110110
.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }"));
111111
CollectorContext collectorContext = validationResult.getCollectorContext();
112-
Assert.assertEquals(((List<String>) collectorContext.get(SAMPLE_COLLECTOR)).size(), 1);
113-
Assert.assertEquals(((List<String>) collectorContext.get(SAMPLE_COLLECTOR_OTHER)).size(), 3);
112+
Assertions.assertEquals(((List<String>) collectorContext.get(SAMPLE_COLLECTOR)).size(), 1);
113+
Assertions.assertEquals(((List<String>) collectorContext.get(SAMPLE_COLLECTOR_OTHER)).size(), 3);
114114
}
115115

116116
private JsonMetaSchema getJsonMetaSchema(String uri) throws Exception {

src/test/java/com/networknt/schema/CustomMetaSchemaTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
import com.fasterxml.jackson.core.JsonProcessingException;
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323

2424
import java.io.IOException;
2525
import java.text.MessageFormat;
2626
import java.util.ArrayList;
2727
import java.util.List;
2828
import java.util.Set;
2929

30-
import static org.junit.Assert.assertEquals;
30+
import static org.junit.jupiter.api.Assertions.assertEquals;
3131

3232
public class CustomMetaSchemaTest {
3333

src/test/java/com/networknt/schema/CyclicDependencyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.networknt.schema;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
55

66
import java.net.URI;
77
import java.net.URL;
88

9-
import static org.junit.Assert.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
1010

1111
public class CyclicDependencyTest {
1212

src/test/java/com/networknt/schema/DateTimeDSTTest.java

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

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import org.junit.Assert;
6-
import org.junit.Test;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
77

88
import java.io.InputStream;
99
import java.util.Set;
@@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
2929
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
3030
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
3131
Set<ValidationMessage> errors = schema.validate(node);
32-
Assert.assertEquals(0, errors.size());
32+
Assertions.assertEquals(0, errors.size());
3333
}
3434
}

src/test/java/com/networknt/schema/Issue255Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import com.fasterxml.jackson.databind.JsonNode;
1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.junit.Assert;
21-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
2222

2323
import java.io.InputStream;
2424
import java.util.Set;
@@ -44,6 +44,6 @@ public void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() th
4444
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
4545
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
4646
Set<ValidationMessage> errors = schema.validate(node);
47-
Assert.assertEquals(2, errors.size());
47+
Assertions.assertEquals(2, errors.size());
4848
}
4949
}

src/test/java/com/networknt/schema/Issue285Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.networknt.schema;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import org.junit.Ignore;
5-
import org.junit.Test;
4+
import org.junit.jupiter.api.Disabled;
5+
import org.junit.jupiter.api.Test;
66

77
import java.io.IOException;
88
import java.net.URI;
99
import java.net.URISyntaxException;
1010
import java.util.Arrays;
1111
import java.util.Set;
1212

13-
import static org.junit.Assert.assertFalse;
13+
import static org.junit.jupiter.api.Assertions.assertFalse;
1414

1515
public class Issue285Test {
1616
private ObjectMapper mapper = new ObjectMapper();
@@ -92,7 +92,7 @@ public void nestedValidation() throws IOException {
9292
// In this case a nested type declaration isn't valid and should raise an error.
9393
// The result is not as expected and we get no validation error.
9494
@Test
95-
@Ignore
95+
@Disabled
9696
public void nestedTypeValidation() throws IOException, URISyntaxException {
9797
URI uri = new URI("https://json-schema.org/draft/2019-09/schema");
9898
JsonSchema jsonSchema = schemaFactory.getSchema(uri);

src/test/java/com/networknt/schema/Issue295Test.java

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

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import org.junit.Assert;
6-
import org.junit.Test;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
77

88
import java.io.InputStream;
99
import java.util.Set;
@@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
2929
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
3030
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
3131
Set<ValidationMessage> errors = schema.validate(node);
32-
Assert.assertEquals(0, errors.size());
32+
Assertions.assertEquals(0, errors.size());
3333
}
3434
}

src/test/java/com/networknt/schema/Issue313Test.java

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

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import org.junit.Assert;
6-
import org.junit.Ignore;
7-
import org.junit.Test;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Disabled;
7+
import org.junit.jupiter.api.Test;
88

99
import java.io.InputStream;
1010
import java.util.Set;
@@ -27,7 +27,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce
2727
}
2828

2929
@Test
30-
@Ignore
30+
@Disabled
3131
public void shouldFailV201909() throws Exception {
3232
String schemaPath = "/schema/issue313-2019-09.json";
3333
String dataPath = "/data/issue313.json";
@@ -36,7 +36,7 @@ public void shouldFailV201909() throws Exception {
3636
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
3737
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
3838
Set<ValidationMessage> errors = schema.validate(node);
39-
Assert.assertEquals(2, errors.size());
39+
Assertions.assertEquals(2, errors.size());
4040
}
4141

4242
@Test
@@ -48,7 +48,7 @@ public void shouldFailV7() throws Exception {
4848
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
4949
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
5050
Set<ValidationMessage> errors = schema.validate(node);
51-
Assert.assertEquals(2, errors.size());
51+
Assertions.assertEquals(2, errors.size());
5252
}
5353

5454
}

src/test/java/com/networknt/schema/Issue314Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.networknt.schema;
22

33
import java.io.InputStream;
4-
import org.junit.Assert;
5-
import org.junit.Test;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.api.Test;
66

77
public class Issue314Test {
88
private static final JsonSchemaFactory FACTORY =
@@ -21,6 +21,6 @@ public void testNormalizeHttpOnly() {
2121
InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath);
2222
JsonSchema schema = FACTORY.getSchema(schemaInputStream);
2323

24-
Assert.assertNotNull(schema);
24+
Assertions.assertNotNull(schema);
2525
}
2626
}

src/test/java/com/networknt/schema/Issue327Test.java

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

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import org.junit.Assert;
6-
import org.junit.Test;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
77

88
import java.io.InputStream;
99
import java.util.Set;
@@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
2929
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
3030
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
3131
Set<ValidationMessage> errors = schema.validate(node);
32-
Assert.assertEquals(0, errors.size());
32+
Assertions.assertEquals(0, errors.size());
3333
}
3434
}

src/test/java/com/networknt/schema/Issue342Test.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
import java.io.InputStream;
44
import java.util.Set;
55

6-
import org.junit.Assert;
7-
import org.junit.Test;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
88

99
import com.fasterxml.jackson.databind.JsonNode;
1010
import com.fasterxml.jackson.databind.ObjectMapper;
1111

1212
public class Issue342Test {
13-
protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) {
14-
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
15-
return factory.getSchema(schemaContent);
16-
}
13+
protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) {
14+
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
15+
return factory.getSchema(schemaContent);
16+
}
1717

18-
protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception {
19-
ObjectMapper mapper = new ObjectMapper();
20-
JsonNode node = mapper.readTree(content);
21-
return node;
22-
}
18+
protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception {
19+
ObjectMapper mapper = new ObjectMapper();
20+
JsonNode node = mapper.readTree(content);
21+
return node;
22+
}
2323

24-
@Test
25-
public void propertyNameEnumShouldFailV7() throws Exception {
26-
String schemaPath = "/schema/issue342-v7.json";
27-
String dataPath = "/data/issue342.json";
28-
InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath);
29-
JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream);
30-
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
31-
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
32-
Set<ValidationMessage> errors = schema.validate(node);
33-
Assert.assertEquals(1, errors.size());
34-
final ValidationMessage error = errors.iterator().next();
35-
Assert.assertEquals("$.z", error.getPath());
36-
Assert.assertEquals("Property name $.z is not valid for validation: does not have a value in the enumeration [a, b, c]", error.getMessage());
37-
}
24+
@Test
25+
public void propertyNameEnumShouldFailV7() throws Exception {
26+
String schemaPath = "/schema/issue342-v7.json";
27+
String dataPath = "/data/issue342.json";
28+
InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath);
29+
JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream);
30+
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
31+
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
32+
Set<ValidationMessage> errors = schema.validate(node);
33+
Assertions.assertEquals(1, errors.size());
34+
final ValidationMessage error = errors.iterator().next();
35+
Assertions.assertEquals("$.z", error.getPath());
36+
Assertions.assertEquals("Property name $.z is not valid for validation: does not have a value in the enumeration [a, b, c]", error.getMessage());
37+
}
3838
}

0 commit comments

Comments
 (0)