Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 36e0322

Browse files
committed
implement Closeable & add testcase
1 parent 12d92f6 commit 36e0322

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/com/alibaba/fastjson/JSONValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.alibaba.fastjson;
22

3+
import java.io.Closeable;
34
import java.io.IOException;
45
import java.io.InputStream;
56
import java.io.Reader;
67

7-
public abstract class JSONValidator implements Cloneable {
8+
public abstract class JSONValidator implements Cloneable, Closeable {
89
public enum Type {
910
Object, Array, Value
1011
}

src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.junit.Test;
77

88
import java.io.ByteArrayInputStream;
9+
import java.io.StringReader;
910

1011
import static org.junit.Assert.*;
1112

@@ -100,4 +101,14 @@ public void test_validate() throws Exception {
100101
JSONValidator validator = JSONValidator.from(json);
101102
assertTrue(validator.validate());
102103
}
104+
105+
@Test
106+
public void test_validate_reader() throws Exception {
107+
JSONValidator validator = JSONValidator.from(
108+
new StringReader(
109+
new String(
110+
JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()))));
111+
assertTrue(validator.validate());
112+
validator.close();
113+
}
103114
}

0 commit comments

Comments
 (0)