From 12d92f611153d019c7b42421db95463c18d274d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=93=81?= Date: Sat, 27 Jun 2020 10:16:59 +0800 Subject: [PATCH] refactor validate testcase --- .../fastjson/validate/JSONValidateTest_0.java | 18 ------------ .../json/bvt/validate/JSONValidatorTest.java | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/alibaba/fastjson/validate/JSONValidateTest_0.java b/src/test/java/com/alibaba/fastjson/validate/JSONValidateTest_0.java index 3cf56099e9..cf3c40762e 100644 --- a/src/test/java/com/alibaba/fastjson/validate/JSONValidateTest_0.java +++ b/src/test/java/com/alibaba/fastjson/validate/JSONValidateTest_0.java @@ -8,12 +8,6 @@ import java.io.ByteArrayInputStream; public class JSONValidateTest_0 extends TestCase { - public void test_validate() throws Exception { - String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent()); - JSONValidator validator = JSONValidator.from(json); - assertTrue(validator.validate()); - } - public void test_validate_benchmark() throws Exception { String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent()); @@ -27,20 +21,8 @@ public void test_validate_benchmark() throws Exception { } } - public void test_validate_utf8() throws Exception { - byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()); - - JSONValidator validator = JSONValidator.fromUtf8(json); - assertTrue(validator.validate()); - } - public void test_validate_utf8_stream() throws Exception { - byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()); - JSONValidator validator = JSONValidator.fromUtf8(new ByteArrayInputStream(json)); - assertTrue(validator.validate()); - validator.close(); - } public void test_validate_utf8_benchmark() throws Exception { byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()); diff --git a/src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java b/src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java index da4237416c..494c1c43d7 100644 --- a/src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java +++ b/src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java @@ -1,8 +1,12 @@ package com.alibaba.json.bvt.validate; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONValidator; +import com.alibaba.json.test.benchmark.decode.EishayDecodeBytes; import org.junit.Test; +import java.io.ByteArrayInputStream; + import static org.junit.Assert.*; public class JSONValidatorTest { @@ -72,4 +76,28 @@ public void validate_test_tfn() throws Throwable { boolean isValidate = JSONValidator.from("trua").validate(); assertFalse(isValidate); } + + @Test + public void test_validate_utf8() throws Exception { + byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()); + + JSONValidator validator = JSONValidator.fromUtf8(json); + assertTrue(validator.validate()); + } + + @Test + public void test_validate_utf8_stream() throws Exception { + byte[] json = JSON.toJSONBytes(EishayDecodeBytes.instance.getContent()); + + JSONValidator validator = JSONValidator.fromUtf8(new ByteArrayInputStream(json)); + assertTrue(validator.validate()); + validator.close(); + } + + @Test + public void test_validate() throws Exception { + String json = JSON.toJSONString(EishayDecodeBytes.instance.getContent()); + JSONValidator validator = JSONValidator.from(json); + assertTrue(validator.validate()); + } } \ No newline at end of file