The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_BrowserSecure.java
22 issues
Line: 16
public class SerializeWriterTest_BrowserSecure extends TestCase {
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 16
public class SerializeWriterTest_BrowserSecure extends TestCase {
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 21
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserSecure);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 21
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserSecure);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 22
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserSecure);
}
public void test_1() throws Exception {
StringBuilder buf = new StringBuilder();
Reported by PMD.
Line: 26
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserSecure);
}
public void test_1() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 26
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserSecure);
}
public void test_1() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 31
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserSecure);
}
Reported by PMD.
Line: 31
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserSecure);
}
Reported by PMD.
Line: 32
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserSecure);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2754.java
22 issues
Line: 11
import java.util.TimeZone;
public class Issue2754 extends TestCase {
public void test_for_issue0() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
Reported by PMD.
Line: 15
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
Reported by PMD.
Line: 15
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
Reported by PMD.
Line: 17
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 17
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Pacific/Chatham"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 20
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue1() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
Reported by PMD.
Line: 24
String s = "{\"p1\":\"2019-09-18T20:35:00+12:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
Reported by PMD.
Line: 26
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 26
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("NZ-CHAT"));
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
Reported by PMD.
Line: 29
assertEquals("2019-09-18T20:35:00+12:45", sdf.format(c.p1.getTime()));
}
public void test_for_issue2() throws Exception {
String s = "{\"p1\":\"2019-09-18T20:35:00+05:45\"}";
C c = JSON.parseObject(s, C.class);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Kathmandu"));
Reported by PMD.
src/test/java/com/alibaba/json/test/FNVHashTest.java
22 issues
Line: 24
// Map<Long, char[]> map = new HashMap<Long, char[]>(COUNT);
long id_hash = fnv_hash("id".toCharArray());
System.out.printf("id : " + id_hash);
System.out.println();
for (int i = 0; i < digLetters.length; ++i) {
System.out.print(digLetters[i]);
System.out.print(",");
}
Reported by PMD.
Line: 25
long id_hash = fnv_hash("id".toCharArray());
System.out.printf("id : " + id_hash);
System.out.println();
for (int i = 0; i < digLetters.length; ++i) {
System.out.print(digLetters[i]);
System.out.print(",");
}
// for (int i = 0; i < COUNT; ++i) {
Reported by PMD.
Line: 27
System.out.printf("id : " + id_hash);
System.out.println();
for (int i = 0; i < digLetters.length; ++i) {
System.out.print(digLetters[i]);
System.out.print(",");
}
// for (int i = 0; i < COUNT; ++i) {
// char[] chars = gen();
// int hash = fnv_hash32(chars);
Reported by PMD.
Line: 28
System.out.println();
for (int i = 0; i < digLetters.length; ++i) {
System.out.print(digLetters[i]);
System.out.print(",");
}
// for (int i = 0; i < COUNT; ++i) {
// char[] chars = gen();
// int hash = fnv_hash32(chars);
// if (hash == id_hash) {
Reported by PMD.
Line: 14
* Created by wenshao on 05/01/2017.
*/
public class FNVHashTest extends TestCase {
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
Random r = new Random();
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
Reported by PMD.
Line: 15
*/
public class FNVHashTest extends TestCase {
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
Random r = new Random();
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
int collision_cnt = 0;
Reported by PMD.
Line: 17
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
Random r = new Random();
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
int collision_cnt = 0;
// Map<Long, char[]> map = new HashMap<Long, char[]>(COUNT);
Reported by PMD.
Line: 17
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
Random r = new Random();
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
int collision_cnt = 0;
// Map<Long, char[]> map = new HashMap<Long, char[]>(COUNT);
Reported by PMD.
Line: 18
Random r = new Random();
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
int collision_cnt = 0;
// Map<Long, char[]> map = new HashMap<Long, char[]>(COUNT);
long id_hash = fnv_hash("id".toCharArray());
Reported by PMD.
Line: 20
public void test_fnv_hash() throws Exception {
int COUNT = 1000 * 1000 * 1000;
int collision_cnt = 0;
// Map<Long, char[]> map = new HashMap<Long, char[]>(COUNT);
long id_hash = fnv_hash("id".toCharArray());
System.out.printf("id : " + id_hash);
System.out.println();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilter_byte.java
22 issues
Line: 15
public class PropertyFilter_byte extends TestCase {
public void test_0() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
Reported by PMD.
Line: 25
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 34
Assert.assertEquals("{}", text);
}
public void test_1() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("id".equals(name)) {
Assert.assertTrue(value instanceof Byte);
Reported by PMD.
Line: 48
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 57
Assert.assertEquals("{\"id\":0}", text);
}
public void test_2() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 61
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
}
return false;
}
};
Reported by PMD.
Line: 70
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
a.setName("chennp2008");
serializer.write(a);
Reported by PMD.
Line: 80
Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
public void test_3() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 93
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "chennp2008");
serializer.write(map);
Reported by PMD.
Line: 103
Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
public void test_4() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return false;
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/TypeCollector.java
22 issues
Line: 13
private static String JSONType = ASMUtils.desc(com.alibaba.fastjson.annotation.JSONType.class);
private static final Map<String, String> primitives = new HashMap<String, String>() {
{
put("int","I");
put("boolean","Z");
put("byte", "B");
put("char","C");
put("short","S");
Reported by PMD.
Line: 25
}
};
private final String methodName;
private final Class<?>[] parameterTypes;
protected MethodCollector collector;
Reported by PMD.
Line: 27
private final String methodName;
private final Class<?>[] parameterTypes;
protected MethodCollector collector;
protected boolean jsonType;
Reported by PMD.
Line: 29
private final Class<?>[] parameterTypes;
protected MethodCollector collector;
protected boolean jsonType;
public TypeCollector(String methodName, Class<?>[] parameterTypes) {
this.methodName = methodName;
Reported by PMD.
Line: 31
protected MethodCollector collector;
protected boolean jsonType;
public TypeCollector(String methodName, Class<?>[] parameterTypes) {
this.methodName = methodName;
this.parameterTypes = parameterTypes;
this.collector = null;
Reported by PMD.
Line: 33
protected boolean jsonType;
public TypeCollector(String methodName, Class<?>[] parameterTypes) {
this.methodName = methodName;
this.parameterTypes = parameterTypes;
this.collector = null;
}
Reported by PMD.
Line: 36
public TypeCollector(String methodName, Class<?>[] parameterTypes) {
this.methodName = methodName;
this.parameterTypes = parameterTypes;
this.collector = null;
}
protected MethodCollector visitMethod(int access, String name, String desc) {
if (collector != null) {
return null;
Reported by PMD.
Line: 39
this.collector = null;
}
protected MethodCollector visitMethod(int access, String name, String desc) {
if (collector != null) {
return null;
}
if (!name.equals(methodName)) {
Reported by PMD.
Line: 52
int longOrDoubleQuantity = 0;
for (Type t : argTypes) {
String className = t.getClassName();
if (className.equals("long") || className.equals("double")) {
longOrDoubleQuantity++;
}
}
if (argTypes.length != this.parameterTypes.length) {
Reported by PMD.
Line: 52
int longOrDoubleQuantity = 0;
for (Type t : argTypes) {
String className = t.getClassName();
if (className.equals("long") || className.equals("double")) {
longOrDoubleQuantity++;
}
}
if (argTypes.length != this.parameterTypes.length) {
Reported by PMD.
src/test/java/com/alibaba/json/test/UTF8Test_decode.java
22 issues
Line: 28
CharBuffer charBuffer;
public void setUp() throws Exception {
System.out.println(System.getProperty("java.runtime.version"));
}
public void test_encode() throws Exception {
String text = new StringBuilder().append(T0).append(System.currentTimeMillis()).toString();
Reported by PMD.
Line: 44
// f1(); // 695
// f2(); // 975
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
}
public void test_encode_en() throws Exception {
String text = new StringBuilder().append(T1).append(System.currentTimeMillis()).toString();
Reported by PMD.
Line: 60
// f1(); // 1296 1058
// f2(); // 615 635
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
}
private void f0() throws Exception {
for (int i = 0; i < 1000 * 1000; ++i) {
Reported by PMD.
Line: 14
* Created by wenshao on 24/07/2017.
*/
public class UTF8Test_decode extends TestCase {
String T0 = "央视的报道《陆军第82集团军:聚合重塑 强军路上当先锋!》披露,从南昌起义到平江起义,从井冈山斗争到两万五千里长征,从首战平型关到历经三大战役,从穿插三所里到全歼美军北极熊团,22勇士飞夺泸定桥、18勇士强渡乌江、鏖战冀中“野八旅”、屡战屡胜“老虎连”、万岁军,一支支善战的部队,一个个滚烫的名字,熔铸成第82集团军新的灵魂。";
String T1 = "Model and actress Emily Ratajkowski would you like you to know she has wonderful abs. We don’t know this because we’re psychic, but rather can surmise this desire from her many photos she posts on Instagram. Whether it’s due to genetics, diet, great Instagram techniques, or some combination of the above, the rising star takes ample opportunity to show you what she’s got, and her fans love it.";
Charset charset = Charset.forName("UTF-8");
Reported by PMD.
Line: 15
*/
public class UTF8Test_decode extends TestCase {
String T0 = "央视的报道《陆军第82集团军:聚合重塑 强军路上当先锋!》披露,从南昌起义到平江起义,从井冈山斗争到两万五千里长征,从首战平型关到历经三大战役,从穿插三所里到全歼美军北极熊团,22勇士飞夺泸定桥、18勇士强渡乌江、鏖战冀中“野八旅”、屡战屡胜“老虎连”、万岁军,一支支善战的部队,一个个滚烫的名字,熔铸成第82集团军新的灵魂。";
String T1 = "Model and actress Emily Ratajkowski would you like you to know she has wonderful abs. We don’t know this because we’re psychic, but rather can surmise this desire from her many photos she posts on Instagram. Whether it’s due to genetics, diet, great Instagram techniques, or some combination of the above, the rising star takes ample opportunity to show you what she’s got, and her fans love it.";
Charset charset = Charset.forName("UTF-8");
Reported by PMD.
Line: 18
String T1 = "Model and actress Emily Ratajkowski would you like you to know she has wonderful abs. We don’t know this because we’re psychic, but rather can surmise this desire from her many photos she posts on Instagram. Whether it’s due to genetics, diet, great Instagram techniques, or some combination of the above, the rising star takes ample opportunity to show you what she’s got, and her fans love it.";
Charset charset = Charset.forName("UTF-8");
char[] chars;
byte[] bytes;
Reported by PMD.
Line: 21
Charset charset = Charset.forName("UTF-8");
char[] chars;
byte[] bytes;
CharBuffer charBuffer;
Reported by PMD.
Line: 22
char[] chars;
byte[] bytes;
CharBuffer charBuffer;
public void setUp() throws Exception {
Reported by PMD.
Line: 25
byte[] bytes;
CharBuffer charBuffer;
public void setUp() throws Exception {
System.out.println(System.getProperty("java.runtime.version"));
}
Reported by PMD.
Line: 27
CharBuffer charBuffer;
public void setUp() throws Exception {
System.out.println(System.getProperty("java.runtime.version"));
}
public void test_encode() throws Exception {
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/NumberDeserializer.java
22 issues
Line: 61
if (clazz == short.class || clazz == Short.class) {
BigDecimal val = lexer.decimalValue();
lexer.nextToken(JSONToken.COMMA);
short shortValue = TypeUtils.shortValue(val);
return (T) Short.valueOf(shortValue);
}
if (clazz == byte.class || clazz == Byte.class) {
BigDecimal val = lexer.decimalValue();
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;
public class NumberDeserializer implements ObjectDeserializer {
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;
public class NumberDeserializer implements ObjectDeserializer {
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 18
public final static NumberDeserializer instance = new NumberDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
Reported by PMD.
Line: 20
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.LITERAL_INT) {
if (clazz == double.class || clazz == Double.class) {
String val = lexer.numberString();
lexer.nextToken(JSONToken.COMMA);
return (T) Double.valueOf(Double.parseDouble(val));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayTest_date.java
22 issues
Line: 19
import junit.framework.TestCase;
public class BeanToArrayTest_date extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
long time = System.currentTimeMillis();
Model model = JSON.parseObject("[" + time + "," + time + "]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
Reported by PMD.
Line: 27
public void test_date() throws Exception {
long time = System.currentTimeMillis();
Model model = JSON.parseObject("[" + time + "," + time + "]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_reader() throws Exception {
long time = System.currentTimeMillis();
Reported by PMD.
Line: 28
long time = System.currentTimeMillis();
Model model = JSON.parseObject("[" + time + "," + time + "]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_reader() throws Exception {
long time = System.currentTimeMillis();
Model model = new JSONReader(new StringReader("[" + time + "," + time + "]"), Feature.SupportArrayToBean).readObject(Model.class);
Reported by PMD.
Line: 31
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_reader() throws Exception {
long time = System.currentTimeMillis();
Model model = new JSONReader(new StringReader("[" + time + "," + time + "]"), Feature.SupportArrayToBean).readObject(Model.class);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
Reported by PMD.
Line: 34
public void test_date_reader() throws Exception {
long time = System.currentTimeMillis();
Model model = new JSONReader(new StringReader("[" + time + "," + time + "]"), Feature.SupportArrayToBean).readObject(Model.class);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_null() throws Exception {
Model model = JSON.parseObject("[null,null]", Model.class, Feature.SupportArrayToBean);
Reported by PMD.
Line: 35
long time = System.currentTimeMillis();
Model model = new JSONReader(new StringReader("[" + time + "," + time + "]"), Feature.SupportArrayToBean).readObject(Model.class);
Assert.assertEquals(time, model.v1.getTime());
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_null() throws Exception {
Model model = JSON.parseObject("[null,null]", Model.class, Feature.SupportArrayToBean);
Assert.assertNull(model.v1);
Reported by PMD.
Line: 38
Assert.assertEquals(time, model.v2.getTime());
}
public void test_date_null() throws Exception {
Model model = JSON.parseObject("[null,null]", Model.class, Feature.SupportArrayToBean);
Assert.assertNull(model.v1);
Assert.assertNull(model.v2);
}
Reported by PMD.
Line: 44
Assert.assertNull(model.v2);
}
public void test_date_null_reader() throws Exception {
Model model = new JSONReader(new StringReader("[null,null]"), Feature.SupportArrayToBean).readObject(Model.class);
Assert.assertNull(model.v1);
Assert.assertNull(model.v2);
}
Reported by PMD.
Line: 50
Assert.assertNull(model.v2);
}
public void test_date2() throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Model model = JSON.parseObject("[\"2016-01-01\",\"2016-01-02\"]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(dateFormat.parse("2016-01-01").getTime(), model.v1.getTime());
Assert.assertEquals(dateFormat.parse("2016-01-02").getTime(), model.v2.getTime());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayTest_private.java
22 issues
Line: 17
public class BeanToArrayTest_private extends TestCase {
public void test_beanToArray_parse() throws Exception {
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Reported by PMD.
Line: 21
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
Reported by PMD.
Line: 22
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 22
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 23
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 23
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 23
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 24
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 24
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayTest.java
22 issues
Line: 18
public class BeanToArrayTest extends TestCase {
public void test_beanToArray_parse() throws Exception {
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Reported by PMD.
Line: 22
String text = "{\"go\":[[\"0\",[true,false],9999999999999,99,\"012345678901234567890123\",\"ftp://gfw.yma.co/x160\",\"xxxx\",\"9876543210123456\",[[\"m\",\"不要开心\",\"http://gfw.meiya.co\",\"123456@gg.com\",\"麻麻\",\"add\",null,\"9876543210123456\"]],null,[\"add\",\"ww\"],999,1234567890123]],\"success\":true}";
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
Reported by PMD.
Line: 23
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 23
GR result = JSON.parseObject(text, GR.class);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 24
Assert.assertNotNull(result);
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.
Line: 25
Assert.assertEquals(1, result.go.size());
Assert.assertEquals("0", result.go.get(0).bi);
Assert.assertEquals(true, result.go.get(0).co.qu);
Assert.assertEquals(false, result.go.get(0).co.sa);
Assert.assertEquals(9999999999999L, result.go.get(0).gm.getTime());
Assert.assertEquals(99, result.go.get(0).grCo);
}
public static class GR {
Reported by PMD.