Skip to content

Commit

Permalink
implement Closeable & add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jun 27, 2020
1 parent 12d92f6 commit 36e0322
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/com/alibaba/fastjson/JSONValidator.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.alibaba.fastjson;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

public abstract class JSONValidator implements Cloneable {
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.StringReader;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -100,4 +101,14 @@ public void test_validate() throws Exception {
JSONValidator validator = JSONValidator.from(json);
assertTrue(validator.validate());
}

@Test
public void test_validate_reader() throws Exception {
JSONValidator validator = JSONValidator.from(
new StringReader(
new String(
JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()))));
assertTrue(validator.validate());
validator.close();
}
}

0 comments on commit 36e0322

Please sign in to comment.