The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_14.java
3 issues
Line: 15
import com.alibaba.fastjson.serializer.SerializeWriter;
public class SerializeWriterTest_14 extends TestCase {
@SuppressWarnings("rawtypes")
public void test_writer_1() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
try {
Reported by PMD.
Line: 32
}
public void test_writer_2() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
try {
JSONSerializer serializer = new JSONSerializer(out);
Reported by PMD.
Line: 47
Assert.assertEquals("{ab:\"a\"}", strOut.toString());
}
public void test_writer_3() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
try {
JSONSerializer serializer = new JSONSerializer(out);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_15.java
3 issues
Line: 16
import com.alibaba.fastjson.serializer.SerializerFeature;
public class SerializeWriterTest_15 extends TestCase {
@SuppressWarnings("rawtypes")
public void test_writer_1() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
out.config(SerializerFeature.UseSingleQuotes, true);
Reported by PMD.
Line: 34
}
public void test_writer_2() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
out.config(SerializerFeature.UseSingleQuotes, true);
try {
Reported by PMD.
Line: 50
Assert.assertEquals("{ab:'a'}", strOut.toString());
}
public void test_writer_3() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 1);
out.config(SerializerFeature.UseSingleQuotes, true);
try {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest3.java
3 issues
Line: 16
public class DenyTest3 extends TestCase {
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
Properties properties = new Properties();
Reported by PMD.
Line: 10
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvtVO.deny.A;
import junit.framework.TestCase;
public class DenyTest3 extends TestCase {
Reported by PMD.
Line: 25
properties.put(ParserConfig.DENY_PROPERTY, "com.alibaba.json.bvtVO.deny,,aa");
config.configFromPropety(properties);
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumUsingToString.java
3 issues
Line: 12
* Created by wenshao on 17/03/2017.
*/
public class EnumUsingToString extends TestCase {
public void test_toString() {
Model model = new Model();
model.gender = Gender.M;
String text = JSON.toJSONString(model);
assertEquals("{\"gender\":\"男\"}", text);
Reported by PMD.
Line: 17
model.gender = Gender.M;
String text = JSON.toJSONString(model);
assertEquals("{\"gender\":\"男\"}", text);
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
public Gender gender;
Reported by PMD.
Line: 22
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
public Gender gender;
}
public static enum Gender {
M("男"),
W("女");
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/CharTest.java
3 issues
Line: 11
public class CharTest extends TestCase {
public void test_file() throws Exception {
char ch = 'a';
String text = JSON.toJSONString(ch);
Assert.assertEquals("\"a\"", text);
Reported by PMD.
Line: 21
Character c1 = JSON.parseObject(text, Character.class);
Character c2 = JSON.parseObject(text, char.class);
Assert.assertEquals(ch, c1.charValue());
Assert.assertEquals(ch, c2.charValue());
}
}
Reported by PMD.
Line: 22
Character c2 = JSON.parseObject(text, char.class);
Assert.assertEquals(ch, c1.charValue());
Assert.assertEquals(ch, c2.charValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReader_obj_3.java
3 issues
Line: 13
public class JSONReader_obj_3 extends TestCase {
public void test_obj() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
reader.startObject();
Assert.assertEquals("id", reader.readString());
Assert.assertEquals(Integer.valueOf(123), reader.readInteger());
Reported by PMD.
Line: 24
reader.close();
}
public void test_obj_2() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"val\":{\"id\":123}}"));
reader.startObject();
Assert.assertEquals("val", reader.readString());
Reported by PMD.
Line: 41
reader.close();
}
public void test_obj_3() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"val\":{\"val\":{\"id\":123}}}"));
reader.startObject();
Assert.assertEquals("val", reader.readString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/BooleanFieldTest.java
3 issues
Line: 11
public class BooleanFieldTest extends TestCase {
public void test_model() throws Exception {
Model model = new Model();
model.value = true;
String text = JSON.toJSONString(model);
Assert.assertEquals("{\"value\":true}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"value\":true}", text);
}
public void test_model_max() throws Exception {
Model model = new Model();
model.value = false;
String text = JSON.toJSONString(model);
Assert.assertEquals("{\"value\":false}", text);
Reported by PMD.
Line: 29
public static class Model {
public boolean value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/list/ArrayListEnumFieldDeserializerTest.java
3 issues
Line: 14
public class ArrayListEnumFieldDeserializerTest extends TestCase {
public void test_enums() throws Exception {
Entity a = JSON.parseObject("{units:['NANOSECONDS', 'SECONDS', 3, null]}", Entity.class);
Assert.assertEquals(TimeUnit.NANOSECONDS, a.getUnits().get(0));
}
public static class Entity {
Reported by PMD.
Line: 16
public void test_enums() throws Exception {
Entity a = JSON.parseObject("{units:['NANOSECONDS', 'SECONDS', 3, null]}", Entity.class);
Assert.assertEquals(TimeUnit.NANOSECONDS, a.getUnits().get(0));
}
public static class Entity {
private List<TimeUnit> units = new ArrayList<TimeUnit>();
Reported by PMD.
Line: 16
public void test_enums() throws Exception {
Entity a = JSON.parseObject("{units:['NANOSECONDS', 'SECONDS', 3, null]}", Entity.class);
Assert.assertEquals(TimeUnit.NANOSECONDS, a.getUnits().get(0));
}
public static class Entity {
private List<TimeUnit> units = new ArrayList<TimeUnit>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReader_array.java
3 issues
Line: 26
Assert.assertNotNull(first);
Assert.assertNotNull(second);
Assert.assertEquals(new Integer(3), reader.readInteger());
Assert.assertNull(reader.readString());
{
Map<String, Object> map = new HashMap<String, Object>();
reader.readObject(map);
Reported by PMD.
Line: 16
public class JSONReader_array extends TestCase {
public void test_array() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[[],[],3,null,{\"name\":\"jobs\"},{\"id\":123},{\"id\":1},{\"id\":2}]"));
reader.startArray();
JSONArray first = (JSONArray) reader.readObject();
JSONArray second = (JSONArray) reader.readObject();
Reported by PMD.
Line: 38
{
VO vo = new VO();
reader.readObject(vo);
Assert.assertEquals(123, vo.getId());
}
while (reader.hasNext()) {
VO vo = reader.readObject(VO.class);
Assert.assertNotNull(vo);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest5.java
3 issues
Line: 12
public class RefTest5 extends TestCase {
public void test_ref() throws Exception {
Object[] array = new Object[1];
array[0] = new Object[] { array };
Assert.assertEquals("[[{\"$ref\":\"..\"}]]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 18
Assert.assertEquals("[[{\"$ref\":\"..\"}]]", JSON.toJSONString(array));
}
public void test_parse() throws Exception {
Object[] array2 = JSON.parseObject("[[{\"$ref\":\"..\"}]]", Object[].class);
JSONArray item = (JSONArray) array2[0];
Assert.assertSame(item, item.get(0));
}
Reported by PMD.
Line: 21
public void test_parse() throws Exception {
Object[] array2 = JSON.parseObject("[[{\"$ref\":\"..\"}]]", Object[].class);
JSONArray item = (JSONArray) array2[0];
Assert.assertSame(item, item.get(0));
}
}
Reported by PMD.