Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump JUnit version to 5.7.2 #447

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<version.common-lang3>3.7</version.common-lang3>
<version.joni>2.1.31</version.joni>
<version.logback>1.2.3</version.logback>
<version.junit>4.13.1</version.junit>
<version.junit>5.7.2</version.junit>
<version.mockito>2.7.21</version.mockito>
<version.hamcrest>1.3</version.hamcrest>
<version.hamcrest>2.2</version.hamcrest>
<version.undertow>2.2.4.Final</version.undertow>
</properties>
<dependencies>
Expand Down Expand Up @@ -101,8 +101,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
Expand All @@ -114,7 +114,7 @@
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<artifactId>hamcrest</artifactId>
<version>${version.hamcrest}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -269,14 +269,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>
<version>2.22.2</version>
</plugin>
<!-- JACOCO added for code coverage -->
<plugin>
Expand Down
38 changes: 19 additions & 19 deletions src/test/java/com/networknt/schema/CollectorContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.*;
Expand All @@ -38,12 +38,12 @@ public class CollectorContextTest {

private JsonSchema jsonSchemaForCombine;

@Before
@BeforeEach
public void setup() throws Exception {
setupSchema();
}

@After
@AfterEach
public void cleanup() {
if (CollectorContext.getInstance() != null) {
CollectorContext.getInstance().reset();
Expand All @@ -54,12 +54,12 @@ public void cleanup() {
@Test
public void testCollectorContextWithKeyword() throws Exception {
ValidationResult validationResult = validate("{\"test-property1\":\"sample1\",\"test-property2\":\"sample2\"}");
Assert.assertEquals(0, validationResult.getValidationMessages().size());
Assertions.assertEquals(0, validationResult.getValidationMessages().size());
List<String> contextValues = (List<String>) validationResult.getCollectorContext().get(SAMPLE_COLLECTOR);
Assert.assertEquals(0, validationResult.getValidationMessages().size());
Assert.assertEquals(2, contextValues.size());
Assert.assertEquals(contextValues.get(0), "actual_value_added_to_context1");
Assert.assertEquals(contextValues.get(1), "actual_value_added_to_context2");
Assertions.assertEquals(0, validationResult.getValidationMessages().size());
Assertions.assertEquals(2, contextValues.size());
Assertions.assertEquals(contextValues.get(0), "actual_value_added_to_context1");
Assertions.assertEquals(contextValues.get(1), "actual_value_added_to_context2");
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -89,17 +89,17 @@ public void testCollectorContextWithMultipleThreads() throws Exception {
ValidationResult validationResult2 = validationRunnable2.getValidationResult();
ValidationResult validationResult3 = validationRunnable3.getValidationResult();

Assert.assertEquals(0, validationResult1.getValidationMessages().size());
Assert.assertEquals(0, validationResult2.getValidationMessages().size());
Assert.assertEquals(0, validationResult3.getValidationMessages().size());
Assertions.assertEquals(0, validationResult1.getValidationMessages().size());
Assertions.assertEquals(0, validationResult2.getValidationMessages().size());
Assertions.assertEquals(0, validationResult3.getValidationMessages().size());

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

Assert.assertEquals(contextValue1.get(0), "actual_value_added_to_context1");
Assert.assertEquals(contextValue2.get(0), "actual_value_added_to_context2");
Assert.assertEquals(contextValue3.get(0), "actual_value_added_to_context3");
Assertions.assertEquals(contextValue1.get(0), "actual_value_added_to_context1");
Assertions.assertEquals(contextValue2.get(0), "actual_value_added_to_context2");
Assertions.assertEquals(contextValue3.get(0), "actual_value_added_to_context3");
}

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

private JsonMetaSchema getJsonMetaSchema(String uri) throws Exception {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/networknt/schema/CustomMetaSchemaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class CustomMetaSchemaTest {

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/networknt/schema/CyclicDependencyTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.networknt.schema;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.net.URI;
import java.net.URL;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class CyclicDependencyTest {

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/networknt/schema/DateTimeDSTTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.util.Set;
Expand All @@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
Set<ValidationMessage> errors = schema.validate(node);
Assert.assertEquals(0, errors.size());
Assertions.assertEquals(0, errors.size());
}
}
6 changes: 3 additions & 3 deletions src/test/java/com/networknt/schema/Issue255Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.util.Set;
Expand All @@ -44,6 +44,6 @@ public void shouldFailWhenRequiredPropertiesDoNotExistInReferencedSubSchema() th
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
Set<ValidationMessage> errors = schema.validate(node);
Assert.assertEquals(2, errors.size());
Assertions.assertEquals(2, errors.size());
}
}
8 changes: 4 additions & 4 deletions src/test/java/com/networknt/schema/Issue285Test.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.networknt.schema;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Set;

import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class Issue285Test {
private ObjectMapper mapper = new ObjectMapper();
Expand Down Expand Up @@ -92,7 +92,7 @@ public void nestedValidation() throws IOException {
// In this case a nested type declaration isn't valid and should raise an error.
// The result is not as expected and we get no validation error.
@Test
@Ignore
@Disabled
public void nestedTypeValidation() throws IOException, URISyntaxException {
URI uri = new URI("https://json-schema.org/draft/2019-09/schema");
JsonSchema jsonSchema = schemaFactory.getSchema(uri);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/networknt/schema/Issue295Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.util.Set;
Expand All @@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
Set<ValidationMessage> errors = schema.validate(node);
Assert.assertEquals(0, errors.size());
Assertions.assertEquals(0, errors.size());
}
}
12 changes: 6 additions & 6 deletions src/test/java/com/networknt/schema/Issue313Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.util.Set;
Expand All @@ -27,7 +27,7 @@ protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exce
}

@Test
@Ignore
@Disabled
public void shouldFailV201909() throws Exception {
String schemaPath = "/schema/issue313-2019-09.json";
String dataPath = "/data/issue313.json";
Expand All @@ -36,7 +36,7 @@ public void shouldFailV201909() throws Exception {
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
Set<ValidationMessage> errors = schema.validate(node);
Assert.assertEquals(2, errors.size());
Assertions.assertEquals(2, errors.size());
}

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

}
6 changes: 3 additions & 3 deletions src/test/java/com/networknt/schema/Issue314Test.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.networknt.schema;

import java.io.InputStream;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

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

Assert.assertNotNull(schema);
Assertions.assertNotNull(schema);
}
}
6 changes: 3 additions & 3 deletions src/test/java/com/networknt/schema/Issue327Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.util.Set;
Expand All @@ -29,6 +29,6 @@ public void shouldWorkV7() throws Exception {
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
Set<ValidationMessage> errors = schema.validate(node);
Assert.assertEquals(0, errors.size());
Assertions.assertEquals(0, errors.size());
}
}
50 changes: 25 additions & 25 deletions src/test/java/com/networknt/schema/Issue342Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
import java.io.InputStream;
import java.util.Set;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Issue342Test {
protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) {
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
return factory.getSchema(schemaContent);
}
protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) {
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
return factory.getSchema(schemaContent);
}

protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(content);
return node;
}
protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(content);
return node;
}

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