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

Commit

Permalink
refactor validate testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jun 27, 2020
1 parent 50532a4 commit 12d92f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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());
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/com/alibaba/json/bvt/validate/JSONValidatorTest.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 12d92f6

Please sign in to comment.