Skip to content

Commit 704688e

Browse files
authored
Merge pull request #318 from pan3793/317
(#317) Compatible with Jackson 2.9.x
2 parents 1abc99b + 2c01183 commit 704688e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/main/java/com/networknt/schema/ContainsValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
4747
return Collections.emptySet();
4848
}
4949

50-
if (node.isEmpty()) {
50+
// to support jackson < 2.10
51+
if (node.size() == 0) {
5152
// Array was empty
5253
return buildErrorMessageSet(at);
5354
} else if (node.isArray()) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Before;
2424
import org.junit.Test;
2525

26+
import java.io.IOException;
2627
import java.util.*;
2728

2829
public class CollectorContextTest {
@@ -96,7 +97,7 @@ public void testCollectorContextWithMultiplThreads() throws Exception {
9697

9798
@SuppressWarnings("unchecked")
9899
@Test
99-
public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException {
100+
public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException, IOException {
100101
ObjectMapper objectMapper = new ObjectMapper();
101102
ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper
102103
.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }"));
@@ -108,7 +109,7 @@ public void testCollectorWithFormat() throws JsonMappingException, JsonProcessin
108109

109110
@SuppressWarnings("unchecked")
110111
@Test
111-
public void testCollectorGetAll() throws JsonMappingException, JsonProcessingException {
112+
public void testCollectorGetAll() throws JsonMappingException, JsonProcessingException, IOException {
112113
ObjectMapper objectMapper = new ObjectMapper();
113114
ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper
114115
.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }"));

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

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

3-
import com.fasterxml.jackson.core.JsonProcessingException;
43
import com.fasterxml.jackson.databind.JsonNode;
54
import com.fasterxml.jackson.databind.ObjectMapper;
65
import org.junit.Assert;
76
import org.junit.Test;
87

8+
import java.io.IOException;
99
import java.util.Set;
1010

1111
public class UnknownMetaSchemaTest {
@@ -17,7 +17,7 @@ public class UnknownMetaSchemaTest {
1717
private String json = "{\"data\":1}";
1818

1919
@Test
20-
public void testSchema1() throws JsonProcessingException {
20+
public void testSchema1() throws IOException {
2121
ObjectMapper mapper = new ObjectMapper();
2222
JsonNode jsonNode = mapper.readTree(this.json);
2323

@@ -31,7 +31,7 @@ public void testSchema1() throws JsonProcessingException {
3131
}
3232

3333
@Test
34-
public void testSchema2() throws JsonProcessingException {
34+
public void testSchema2() throws IOException {
3535
ObjectMapper mapper = new ObjectMapper();
3636
JsonNode jsonNode = mapper.readTree(this.json);
3737

@@ -44,7 +44,7 @@ public void testSchema2() throws JsonProcessingException {
4444
}
4545
}
4646
@Test
47-
public void testSchema3() throws JsonProcessingException {
47+
public void testSchema3() throws IOException {
4848
ObjectMapper mapper = new ObjectMapper();
4949
JsonNode jsonNode = mapper.readTree(this.json);
5050

0 commit comments

Comments
 (0)