use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class EnumFieldTest method test_error.
public void test_error() throws Exception {
Exception error = null;
try {
JSONReader read = new JSONReader(new StringReader("{\"value\":\"a\\b\"}"));
read.readObject(Model.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class EnumFieldTest method test_1.
public void test_1() throws Exception {
JSONReader read = new JSONReader(new StringReader("{\"value\":\"A\",\"value1\":\"B\"}"));
Model model = read.readObject(Model.class);
Assert.assertEquals(Type.A, model.value);
Assert.assertEquals(Type.B, model.value1);
read.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class EnumFieldTest2 method test_error_nul.
public void test_error_nul() throws Exception {
Exception error = null;
try {
JSONReader read = new JSONReader(new StringReader("[nul"));
read.config(Feature.SupportArrayToBean, true);
Model model = read.readObject(Model.class);
read.readObject(Model.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class EnumFieldTest2 method test_2.
public void test_2() throws Exception {
JSONReader read = new JSONReader(new StringReader("[null,null]"));
read.config(Feature.SupportArrayToBean, true);
Model model = read.readObject(Model.class);
Assert.assertEquals(null, model.value);
Assert.assertEquals(null, model.value1);
read.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class EnumFieldTest2 method test_error_nu.
public void test_error_nu() throws Exception {
Exception error = null;
try {
JSONReader read = new JSONReader(new StringReader("[nu"));
read.config(Feature.SupportArrayToBean, true);
Model model = read.readObject(Model.class);
read.readObject(Model.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Aggregations