The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest2.java
5 issues
Line: 23
public void test_enum() throws Exception {
Date date = new Date(1308841916550L);
Assert.assertEquals("1308841916550", JSON.toJSONString(date)); // 1308841916550
System.out.println(JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat)); // "2011-06-23T23:11:56.550"
SerializerFeature[] features = {SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
System.out.println(JSON.toJSONString(date, features)); // '2011-06-23T23:11:56.550'
}
public void test_enum_noasm() throws Exception {
Reported by PMD.
Line: 25
Assert.assertEquals("1308841916550", JSON.toJSONString(date)); // 1308841916550
System.out.println(JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat)); // "2011-06-23T23:11:56.550"
SerializerFeature[] features = {SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
System.out.println(JSON.toJSONString(date, features)); // '2011-06-23T23:11:56.550'
}
public void test_enum_noasm() throws Exception {
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 15
import com.alibaba.fastjson.serializer.SerializerFeature;
public class EnumTest2 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_enum() throws Exception {
Reported by PMD.
Line: 20
JSON.defaultLocale = Locale.CHINA;
}
public void test_enum() throws Exception {
Date date = new Date(1308841916550L);
Assert.assertEquals("1308841916550", JSON.toJSONString(date)); // 1308841916550
System.out.println(JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat)); // "2011-06-23T23:11:56.550"
SerializerFeature[] features = {SerializerFeature.UseISO8601DateFormat, SerializerFeature.UseSingleQuotes };
System.out.println(JSON.toJSONString(date, features)); // '2011-06-23T23:11:56.550'
Reported by PMD.
Line: 28
System.out.println(JSON.toJSONString(date, features)); // '2011-06-23T23:11:56.550'
}
public void test_enum_noasm() throws Exception {
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Date date = new Date(1308841916550L);
Assert.assertEquals("1308841916550", JSON.toJSONString(date, mapping)); // 1308841916550
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/ContextValueClassLevelTest.java
5 issues
Line: 15
public class ContextValueClassLevelTest extends TestCase {
public void test_0() throws Exception {
Object[] array = { new ModelA(), new ModelB() };
SerializeConfig config = new SerializeConfig();
config.addFilter(ModelA.class, //
new ContextValueFilter() {
Reported by PMD.
Line: 9
import com.alibaba.fastjson.serializer.BeanContext;
import com.alibaba.fastjson.serializer.ContextValueFilter;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.ValueFilter;
import junit.framework.TestCase;
public class ContextValueClassLevelTest extends TestCase {
Reported by PMD.
Line: 16
public class ContextValueClassLevelTest extends TestCase {
public void test_0() throws Exception {
Object[] array = { new ModelA(), new ModelB() };
SerializeConfig config = new SerializeConfig();
config.addFilter(ModelA.class, //
new ContextValueFilter() {
Reported by PMD.
Line: 16
public class ContextValueClassLevelTest extends TestCase {
public void test_0() throws Exception {
Object[] array = { new ModelA(), new ModelB() };
SerializeConfig config = new SerializeConfig();
config.addFilter(ModelA.class, //
new ContextValueFilter() {
Reported by PMD.
Line: 16
public class ContextValueClassLevelTest extends TestCase {
public void test_0() throws Exception {
Object[] array = { new ModelA(), new ModelB() };
SerializeConfig config = new SerializeConfig();
config.addFilter(ModelA.class, //
new ContextValueFilter() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/stream/JSONWriterTest.java
5 issues
Line: 13
@SuppressWarnings("deprecation")
public class JSONWriterTest extends TestCase {
public void test_0() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
writer.writeEndObject();
Reported by PMD.
Line: 24
Assert.assertEquals("{}", out.toString());
}
public void test_1() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
writer.writeKey("id");
Reported by PMD.
Line: 37
Assert.assertEquals("{\"id\":33}", out.toString());
}
public void test_2() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
Reported by PMD.
Line: 55
Assert.assertEquals("{\"id\":33,\"name\":\"jobs\"}", out.toString());
}
public void test_3() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
Reported by PMD.
Line: 84
Assert.assertEquals("{\"id\":33,\"name\":\"jobs\",\"children\":[{},{}]}", out.toString());
}
public void test_4() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartArray();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/TestEnum.java
5 issues
Line: 14
Big, Medium, Small
}
public void test_enum() throws Exception {
Assert.assertEquals(Type.Big, JSON.parseObject("{value:\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{value:0}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":0}", VO.class).getValue());
}
Reported by PMD.
Line: 15
}
public void test_enum() throws Exception {
Assert.assertEquals(Type.Big, JSON.parseObject("{value:\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{value:0}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":0}", VO.class).getValue());
}
Reported by PMD.
Line: 16
public void test_enum() throws Exception {
Assert.assertEquals(Type.Big, JSON.parseObject("{value:\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{value:0}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":0}", VO.class).getValue());
}
public static class VO {
Reported by PMD.
Line: 17
public void test_enum() throws Exception {
Assert.assertEquals(Type.Big, JSON.parseObject("{value:\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{value:0}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":0}", VO.class).getValue());
}
public static class VO {
Reported by PMD.
Line: 18
Assert.assertEquals(Type.Big, JSON.parseObject("{value:\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":\"Big\"}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{value:0}", VO.class).getValue());
Assert.assertEquals(Type.Big, JSON.parseObject("{\"value\":0}", VO.class).getValue());
}
public static class VO {
private Type value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/util/AntiCollisionHashMapTest_writeClassName.java
5 issues
Line: 11
import java.util.Map;
public class AntiCollisionHashMapTest_writeClassName extends TestCase {
public void test_for_bug() throws Exception {
Model m = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}}", Model.class);
assertTrue(m.value.getInnerMap() instanceof AntiCollisionHashMap);
}
public static class Model {
Reported by PMD.
Line: 13
public class AntiCollisionHashMapTest_writeClassName extends TestCase {
public void test_for_bug() throws Exception {
Model m = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}}", Model.class);
assertTrue(m.value.getInnerMap() instanceof AntiCollisionHashMap);
}
public static class Model {
public JSONObject value;
}
Reported by PMD.
Line: 13
public class AntiCollisionHashMapTest_writeClassName extends TestCase {
public void test_for_bug() throws Exception {
Model m = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}}", Model.class);
assertTrue(m.value.getInnerMap() instanceof AntiCollisionHashMap);
}
public static class Model {
public JSONObject value;
}
Reported by PMD.
Line: 17
}
public static class Model {
public JSONObject value;
}
}
Reported by PMD.
Line: 8
import com.alibaba.fastjson.util.AntiCollisionHashMap;
import junit.framework.TestCase;
import java.util.Map;
public class AntiCollisionHashMapTest_writeClassName extends TestCase {
public void test_for_bug() throws Exception {
Model m = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}}", Model.class);
assertTrue(m.value.getInnerMap() instanceof AntiCollisionHashMap);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/URLDeserializerTest.java
5 issues
Line: 18
public class URLDeserializerTest extends TestCase {
public void test_url() throws Exception {
Assert.assertEquals(new URL("http://www.alibaba.com"), JSON.parseObject("'http://www.alibaba.com'", URL.class));
Assert.assertEquals(null, JSON.parseObject("null", URL.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Reported by PMD.
Line: 24
Assert.assertEquals(null, JSON.parseObject("null", URL.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
}
public void test_url_error() throws Exception {
Reported by PMD.
Line: 25
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
}
public void test_url_error() throws Exception {
JSONException ex = null;
Reported by PMD.
Line: 29
}
public void test_url_error() throws Exception {
JSONException ex = null;
try {
JSON.parseObject("'123'", URL.class);
} catch (JSONException e) {
ex = e;
Reported by PMD.
Line: 30
}
public void test_url_error() throws Exception {
JSONException ex = null;
try {
JSON.parseObject("'123'", URL.class);
} catch (JSONException e) {
ex = e;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/list/ListStringFieldTest_createError.java
5 issues
Line: 17
public class ListStringFieldTest_createError extends TestCase {
public void test_null() throws Exception {
Exception error = null;
try {
String text = "{\"values\":[]}";
JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
Reported by PMD.
Line: 28
Assert.assertNotNull(error);
}
public void test_reader() throws Exception {
Exception error = null;
try {
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
reader.readObject(Model.class);
Reported by PMD.
Line: 54
}
public static class MyErrorList<T> extends ArrayList<T> {
public MyErrorList(){
throw new IllegalStateException();
}
}
Reported by PMD.
Line: 18
public class ListStringFieldTest_createError extends TestCase {
public void test_null() throws Exception {
Exception error = null;
try {
String text = "{\"values\":[]}";
JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 29
}
public void test_reader() throws Exception {
Exception error = null;
try {
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest7.java
5 issues
Line: 12
public class DefaultObjectDeserializerTest7 extends TestCase {
public void test_0() throws Exception {
VO<A> vo = JSON.parseObject("{\"value\":[{\"id\":123}]}", new TypeReference<VO<A>>() {
});
A a = vo.getValue()[0];
Assert.assertEquals(123, a.getId());
}
Reported by PMD.
Line: 16
VO<A> vo = JSON.parseObject("{\"value\":[{\"id\":123}]}", new TypeReference<VO<A>>() {
});
A a = vo.getValue()[0];
Assert.assertEquals(123, a.getId());
}
public static class VO<T> {
private T[] value;
Reported by PMD.
Line: 24
private T[] value;
public T[] getValue() {
return value;
}
public void setValue(T[] value) {
this.value = value;
}
Reported by PMD.
Line: 27
return value;
}
public void setValue(T[] value) {
this.value = value;
}
}
Reported by PMD.
Line: 27
return value;
}
public void setValue(T[] value) {
this.value = value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_error3.java
5 issues
Line: 14
public class JSONCreatorTest_error3 extends TestCase {
public void test_create() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":123,\"name\":\"abc\"}").toJavaObject(Entity.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 17
public void test_create() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":123,\"name\":\"abc\"}").toJavaObject(Entity.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 30
private final String name;
@JSONCreator
public Entity(@JSONField(name = "id") int id, @JSONField(name = "name") String name){
throw new UnsupportedOperationException();
}
public int getId() {
return id;
Reported by PMD.
Line: 30
private final String name;
@JSONCreator
public Entity(@JSONField(name = "id") int id, @JSONField(name = "name") String name){
throw new UnsupportedOperationException();
}
public int getId() {
return id;
Reported by PMD.
Line: 15
public class JSONCreatorTest_error3 extends TestCase {
public void test_create() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":123,\"name\":\"abc\"}").toJavaObject(Entity.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/stream/LargeTest.java
5 issues
Line: 24
list.add(Integer.toString(i));
}
File file = File.createTempFile("fastjson-stream-large", "json");
JSONWriter writer = new JSONWriter(new FileWriter(file));
writer.startArray();
writer.writeObject(list);
writer.endArray();
writer.close();
Reported by PMD.
Line: 32
System.out.println(FileUtils.readFileToString(file));
JSONReader reader = new JSONReader(new FileReader(file));
reader.startArray();
reader.readObject();
reader.endArray();
reader.close();
Reported by PMD.
Line: 30
writer.endArray();
writer.close();
System.out.println(FileUtils.readFileToString(file));
JSONReader reader = new JSONReader(new FileReader(file));
reader.startArray();
reader.readObject();
reader.endArray();
Reported by PMD.
Line: 18
public class LargeTest extends TestCase {
public void test_0() throws Exception {
List<String> list = new ArrayList<String>(1000 * 1);
for (int i = 0; i < 100 * 1; ++i) {
list.add(Integer.toString(i));
}
File file = File.createTempFile("fastjson-stream-large", "json");
Reported by PMD.
Line: 18
public class LargeTest extends TestCase {
public void test_0() throws Exception {
List<String> list = new ArrayList<String>(1000 * 1);
for (int i = 0; i < 100 * 1; ++i) {
list.add(Integer.toString(i));
}
File file = File.createTempFile("fastjson-stream-large", "json");
Reported by PMD.