use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JSONSerializerTest method test_2_s.
public void test_2_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.EMPTY_MAP);
Assert.assertEquals("{}", serializer.getWriter().toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JSONSerializerTest method test_12.
public void test_12() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new Object[0]);
Assert.assertEquals("[]", serializer.getWriter().toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JSONSerializerTest method test_17.
public void test_17() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new Object[] { null, null, null, null });
Assert.assertEquals("[null,null,null,null]", serializer.getWriter().toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JSONSerializerTest method test_0.
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Assert.assertEquals("[]", serializer.getWriter().toString());
}
use of com.alibaba.fastjson.serializer.JSONSerializer in project fastjson by alibaba.
the class JSONSerializerTest method test_error.
public void test_error() throws Exception {
JSONException error = null;
try {
StringWriter out = new StringWriter();
JSONSerializer serializer = new JSONSerializer();
serializer.write(new JSONStreamAware() {
public void writeJSONString(Appendable out) throws IOException {
throw new IOException();
}
});
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
Aggregations