The following issues were found
src/main/java/com/alibaba/fastjson/serializer/CharArrayCodec.java
19 issues
Line: 14
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class CharArrayCodec implements ObjectDeserializer {
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
return (T) deserialze(parser);
}
Reported by PMD.
Line: 14
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class CharArrayCodec implements ObjectDeserializer {
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
return (T) deserialze(parser);
}
Reported by PMD.
Line: 22
}
@SuppressWarnings("unchecked")
public static <T> T deserialze(DefaultJSONParser parser) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
Reported by PMD.
Line: 22
}
@SuppressWarnings("unchecked")
public static <T> T deserialze(DefaultJSONParser parser) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
Reported by PMD.
Line: 22
}
@SuppressWarnings("unchecked")
public static <T> T deserialze(DefaultJSONParser parser) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
Reported by PMD.
Line: 22
}
@SuppressWarnings("unchecked")
public static <T> T deserialze(DefaultJSONParser parser) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
Reported by PMD.
Line: 24
@SuppressWarnings("unchecked")
public static <T> T deserialze(DefaultJSONParser parser) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
}
Reported by PMD.
Line: 27
if (lexer.token() == JSONToken.LITERAL_STRING) {
String val = lexer.stringVal();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toCharArray();
}
if (lexer.token() == JSONToken.LITERAL_INT) {
Number val = lexer.integerValue();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 30
return (T) val.toCharArray();
}
if (lexer.token() == JSONToken.LITERAL_INT) {
Number val = lexer.integerValue();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toString().toCharArray();
}
Reported by PMD.
Line: 33
if (lexer.token() == JSONToken.LITERAL_INT) {
Number val = lexer.integerValue();
lexer.nextToken(JSONToken.COMMA);
return (T) val.toString().toCharArray();
}
Object value = parser.parse();
if (value instanceof String) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DateParserTest.java
19 issues
Line: 18
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
public class DateParserTest extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
Reported by PMD.
Line: 19
import com.alibaba.fastjson.parser.ParserConfig;
public class DateParserTest extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_date_new() throws Exception {
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_date_new() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
Reported by PMD.
Line: 33
parser.close();
}
public void test_date_new_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = (java.util.Date) parser.parse();
Assert.assertEquals(new java.util.Date(1294552193254L), date);
Reported by PMD.
Line: 42
parser.close();
}
public void test_date_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");
java.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
Reported by PMD.
Line: 51
parser.close();
}
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
java.util.Date date = parser.parseObject(java.util.Date.class);
Reported by PMD.
Line: 62
parser.close();
}
public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
java.util.Date date = parser.parseObject(java.util.Date.class);
Reported by PMD.
Line: 72
parser.close();
}
public void test_date_3() throws Exception {
java.util.Date date = JSON.parseObject("\"2011-01-09T13:49:53\"", java.util.Date.class, Feature.AllowISO8601DateFormat);
Assert.assertEquals(new java.util.Date(1294552193000L), date);
}
Reported by PMD.
Line: 78
Assert.assertEquals(new java.util.Date(1294552193000L), date);
}
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
java.util.Date date = parser.parseObject(java.util.Date.class);
Reported by PMD.
Line: 89
parser.close();
}
public void test_date_5() throws Exception {
JSONObject object = JSON.parseObject("{d:'2011-01-09T13:49:53'}", Feature.AllowISO8601DateFormat);
Assert.assertEquals(new java.util.Date(1294552193000L), object.get("d"));
}
public void test_date_6() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/CharArrayDeserializerTest.java
18 issues
Line: 10
public class CharArrayDeserializerTest extends TestCase {
public void test_charArray() throws Exception {
Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Reported by PMD.
Line: 11
public class CharArrayDeserializerTest extends TestCase {
public void test_charArray() throws Exception {
Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Reported by PMD.
Line: 12
public void test_charArray() throws Exception {
Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Reported by PMD.
Line: 13
public void test_charArray() throws Exception {
Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Reported by PMD.
Line: 14
Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Reported by PMD.
Line: 15
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
Reported by PMD.
Line: 15
Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
Reported by PMD.
Line: 16
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));
Reported by PMD.
Line: 16
Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));
Reported by PMD.
Line: 17
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));
Assert.assertEquals("{}", new String(JSON.parseObject("{\"value\":{}}", VO.class).getValue()));
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/BooleanFieldTest_array.java
18 issues
Line: 15
public class BooleanFieldTest_array extends TestCase {
public void test_model_error_t() throws Exception {
Exception error = null;
try {
JSON.parseObject("[t", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 25
Assert.assertNotNull(error);
}
public void test_model_error_tr() throws Exception {
Exception error = null;
try {
JSON.parseObject("[tr", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 35
Assert.assertNotNull(error);
}
public void test_model_error_tru() throws Exception {
Exception error = null;
try {
JSON.parseObject("[tru", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 46
}
public void test_model_error_true_notclose() throws Exception {
Exception error = null;
try {
JSON.parseObject("[true", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 56
Assert.assertNotNull(error);
}
public void test_model_error_false_notclose() throws Exception {
Exception error = null;
try {
JSON.parseObject("[false", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 66
Assert.assertNotNull(error);
}
public void test_model_error_f() throws Exception {
Exception error = null;
try {
JSON.parseObject("[f", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 76
Assert.assertNotNull(error);
}
public void test_model_error_fa() throws Exception {
Exception error = null;
try {
JSON.parseObject("[fa", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 86
Assert.assertNotNull(error);
}
public void test_model_error_fal() throws Exception {
Exception error = null;
try {
JSON.parseObject("[fal", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 97
}
public void test_model_error_fals() throws Exception {
Exception error = null;
try {
JSON.parseObject("[fals", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 16
public class BooleanFieldTest_array extends TestCase {
public void test_model_error_t() throws Exception {
Exception error = null;
try {
JSON.parseObject("[t", Model.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/BugTest0.java
18 issues
Line: 14
public class BugTest0 extends TestCase {
public void test_0() throws Exception {
Timestamp t = new Timestamp(System.currentTimeMillis());
String text = JSON.toJSONString(t);
Timestamp t1 = JSON.parseObject(text, Timestamp.class);
Reported by PMD.
Line: 23
Assert.assertEquals(t, t1);
}
public void test_1() throws Exception {
long t1 = System.currentTimeMillis();
String text = JSON.toJSONString(t1);
Timestamp t2 = JSON.parseObject(text, Timestamp.class);
Assert.assertEquals(t1, t2.getTime());
Reported by PMD.
Line: 28
String text = JSON.toJSONString(t1);
Timestamp t2 = JSON.parseObject(text, Timestamp.class);
Assert.assertEquals(t1, t2.getTime());
}
public void test_2() throws Exception {
Date t = new Date(System.currentTimeMillis());
Reported by PMD.
Line: 31
Assert.assertEquals(t1, t2.getTime());
}
public void test_2() throws Exception {
Date t = new Date(System.currentTimeMillis());
String text = JSON.toJSONString(t);
Date t1 = JSON.parseObject(text, Date.class);
Reported by PMD.
Line: 40
Assert.assertEquals(t, t1);
}
public void test_3() throws Exception {
long t1 = System.currentTimeMillis();
String text = JSON.toJSONString(t1);
Date t2 = JSON.parseObject(text, Date.class);
Assert.assertEquals(t1, t2.getTime());
Reported by PMD.
Line: 45
String text = JSON.toJSONString(t1);
Date t2 = JSON.parseObject(text, Date.class);
Assert.assertEquals(t1, t2.getTime());
}
public void test_4() throws Exception {
A a = new A();
a.setDate(new java.sql.Date(System.currentTimeMillis()));
Reported by PMD.
Line: 48
Assert.assertEquals(t1, t2.getTime());
}
public void test_4() throws Exception {
A a = new A();
a.setDate(new java.sql.Date(System.currentTimeMillis()));
a.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
String text = JSON.toJSONString(a);
Reported by PMD.
Line: 56
A a1 = JSON.parseObject(text, A.class);
Assert.assertEquals(a.getDate(), a1.getDate());
Assert.assertEquals(a.getTime(), a1.getTime());
}
public void test_error_0() throws Exception {
Exception error = null;
Reported by PMD.
Line: 57
A a1 = JSON.parseObject(text, A.class);
Assert.assertEquals(a.getDate(), a1.getDate());
Assert.assertEquals(a.getTime(), a1.getTime());
}
public void test_error_0() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 60
Assert.assertEquals(a.getTime(), a1.getTime());
}
public void test_error_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("\"222A\"", Timestamp.class);
} catch (JSONException e) {
error = e;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestExternal6.java
18 issues
Line: 37
{
String text = JSON.toJSONString(obj);
System.out.println(text);
}
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
Reported by PMD.
Line: 41
}
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
Reported by PMD.
Line: 20
import com.alibaba.fastjson.serializer.SerializerFeature;
public class TestExternal6 extends TestCase {
ParserConfig confg = ParserConfig.global;
protected void setUp() throws Exception {
confg.addAccept("org.mule.esb.model");
}
Reported by PMD.
Line: 22
public class TestExternal6 extends TestCase {
ParserConfig confg = ParserConfig.global;
protected void setUp() throws Exception {
confg.addAccept("org.mule.esb.model");
}
public void test_0() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Reported by PMD.
Line: 26
confg.addAccept("org.mule.esb.model");
}
public void test_0() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
Method[] methods = clazz.getMethods();
Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });
Reported by PMD.
Line: 29
public void test_0() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
Method[] methods = clazz.getMethods();
Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });
Object obj = clazz.newInstance();
// method.invoke(obj, "AAAA");
Reported by PMD.
Line: 30
ExtClassLoader classLoader = new ExtClassLoader();
Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
Method[] methods = clazz.getMethods();
Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });
Object obj = clazz.newInstance();
// method.invoke(obj, "AAAA");
{
Reported by PMD.
Line: 32
Method[] methods = clazz.getMethods();
Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });
Object obj = clazz.newInstance();
// method.invoke(obj, "AAAA");
{
String text = JSON.toJSONString(obj);
System.out.println(text);
Reported by PMD.
Line: 43
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
public static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 43
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
public static class ExtClassLoader extends ClassLoader {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/list/ArrayListTypeFieldTest.java
18 issues
Line: 14
public class ArrayListTypeFieldTest extends TestCase {
public void test_0() throws Exception {
Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_1() throws Exception {
Reported by PMD.
Line: 16
public void test_0() throws Exception {
Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
Reported by PMD.
Line: 16
public void test_0() throws Exception {
Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
Reported by PMD.
Line: 16
public void test_0() throws Exception {
Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
Reported by PMD.
Line: 19
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_null() throws Exception {
Reported by PMD.
Line: 21
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_null() throws Exception {
Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList());
Reported by PMD.
Line: 21
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_null() throws Exception {
Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList());
Reported by PMD.
Line: 21
public void test_1() throws Exception {
Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_null() throws Exception {
Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList());
Reported by PMD.
Line: 24
Assert.assertEquals(3, entity.getList().get(0).getValue());
}
public void test_null() throws Exception {
Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList());
}
public void test_null2() throws Exception {
Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Reported by PMD.
Line: 26
public void test_null() throws Exception {
Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList());
}
public void test_null2() throws Exception {
Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
Assert.assertEquals(null, entity.getList().get(0));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_smoothrat4.java
18 issues
Line: 18
entity.setValue(3L);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3L}",
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Long.valueOf(3), entity2.getValue());
Reported by PMD.
Line: 33
entity.setValue(3);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
}
Reported by PMD.
Line: 47
entity.setValue((short) 3);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3S}",
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Short.valueOf((short) 3), entity2.getValue());
Reported by PMD.
Line: 62
entity.setValue((byte) 3);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3B}",
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Byte.valueOf((byte) 3), entity2.getValue());
Reported by PMD.
Line: 77
entity.setValue(3F);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0F}",
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(3F, entity2.getValue());
Reported by PMD.
Line: 92
entity.setValue(3D);
String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0D}",
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(3D, entity2.getValue());
Reported by PMD.
Line: 11
public class Bug_for_smoothrat4 extends TestCase {
public void test_long() throws Exception {
Entity entity = new Entity();
entity.setValue(3L);
Reported by PMD.
Line: 23
text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Long.valueOf(3), entity2.getValue());
}
public void test_int() throws Exception {
Entity entity = new Entity();
Reported by PMD.
Line: 26
Assert.assertEquals(Long.valueOf(3), entity2.getValue());
}
public void test_int() throws Exception {
Entity entity = new Entity();
entity.setValue(3);
Reported by PMD.
Line: 37
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
}
public void test_short() throws Exception {
Entity entity = new Entity();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jsonpatch/JSONPatchTest_0.java
18 issues
Line: 8
import junit.framework.TestCase;
public class JSONPatchTest_0 extends TestCase {
public void test_for_multi_0() throws Exception {
String original = "{\n" +
" \"baz\": \"qux\",\n" +
" \"foo\": \"bar\"\n" +
"}";
Reported by PMD.
Line: 21
"]";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
}
public void test_for_add_1() throws Exception {
String original = "{}";
Reported by PMD.
Line: 24
assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
}
public void test_for_add_1() throws Exception {
String original = "{}";
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 30
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
Reported by PMD.
Line: 30
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
Reported by PMD.
Line: 33
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 39
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
assertEquals("{}", result);
}
public void test_for_remove_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
Reported by PMD.
Line: 42
assertEquals("{}", result);
}
public void test_for_remove_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 48
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{}}}", result);
}
public void test_for_replace_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
Reported by PMD.
Line: 51
assertEquals("{\"a\":{\"b\":{}}}", result);
}
public void test_for_replace_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
String patch = "{ \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 42 }";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_430.java
18 issues
Line: 14
import junit.framework.TestCase;
public class Bug_for_issue_430 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_issue_430");
}
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
Reported by PMD.
Line: 15
public class Bug_for_issue_430 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_issue_430");
}
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Reported by PMD.
Line: 18
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_issue_430");
}
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Reported by PMD.
Line: 21
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
Reported by PMD.
Line: 21
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
Reported by PMD.
Line: 22
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
Reported by PMD.
Line: 22
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
Reported by PMD.
Line: 24
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
public void test_for_issue_1() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
Reported by PMD.
Line: 25
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel)array.get(0)).fooCollection);
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
public void test_for_issue_1() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = (JSONArray) JSON.parse(text);
Reported by PMD.
Line: 28
Assert.assertNull(((FooModel)array.get(1)).fooCollection);
}
public void test_for_issue_1() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Reported by PMD.