The following issues were found
src/test/java/com/alibaba/json/bvt/JSON_isValid_1_error.java
48 issues
Line: 7
import junit.framework.TestCase;
public class JSON_isValid_1_error extends TestCase {
public void test_for_isValid_0() throws Exception {
assertFalse(JSON.isValid(null));
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class JSON_isValid_1_error extends TestCase {
public void test_for_isValid_0() throws Exception {
assertFalse(JSON.isValid(null));
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
Reported by PMD.
Line: 8
public class JSON_isValid_1_error extends TestCase {
public void test_for_isValid_0() throws Exception {
assertFalse(JSON.isValid(null));
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
Reported by PMD.
Line: 9
public class JSON_isValid_1_error extends TestCase {
public void test_for_isValid_0() throws Exception {
assertFalse(JSON.isValid(null));
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
Reported by PMD.
Line: 12
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
Reported by PMD.
Line: 12
assertFalse(JSON.isValid(""));
}
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
Reported by PMD.
Line: 13
}
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
assertFalse(JSON.isValid("12.34,123"));
Reported by PMD.
Line: 14
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
assertFalse(JSON.isValid("12.34,123"));
assertFalse(JSON.isValid("tru"));
Reported by PMD.
Line: 15
public void test_for_isValid_value() throws Exception {
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
assertFalse(JSON.isValid("12.34,123"));
assertFalse(JSON.isValid("tru"));
assertFalse(JSON.isValid("true,123"));
Reported by PMD.
Line: 16
assertFalse(JSON.isValid("nul"));
assertFalse(JSON.isValid("null,null"));
assertFalse(JSON.isValid("123,"));
assertFalse(JSON.isValid("123,123"));
assertFalse(JSON.isValid("12.34,true"));
assertFalse(JSON.isValid("12.34,123"));
assertFalse(JSON.isValid("tru"));
assertFalse(JSON.isValid("true,123"));
assertFalse(JSON.isValid("fals"));
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/JSONSerializer.java
47 issues
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
Reported by PMD.
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
Reported by PMD.
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
Reported by PMD.
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
Reported by PMD.
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
Reported by PMD.
Line: 36
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
private String indent = "\t";
Reported by PMD.
Line: 36
*/
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
private String indent = "\t";
Reported by PMD.
Line: 37
public class JSONSerializer extends SerializeFilterable {
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
private String indent = "\t";
/**
Reported by PMD.
Line: 39
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
private String indent = "\t";
/**
* #1868 为了区分全局配置(FastJsonConfig)的日期格式配置以及toJSONString传入的日期格式配置
* 建议使用以下调整:
Reported by PMD.
Line: 39
protected final SerializeConfig config;
public final SerializeWriter out;
private int indentCount = 0;
private String indent = "\t";
/**
* #1868 为了区分全局配置(FastJsonConfig)的日期格式配置以及toJSONString传入的日期格式配置
* 建议使用以下调整:
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONSerializerFeatureTest.java
47 issues
Line: 15
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class JSONSerializerFeatureTest extends TestCase {
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
Reported by PMD.
Line: 17
public class JSONSerializerFeatureTest extends TestCase {
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
}
Reported by PMD.
Line: 24
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
}
public void test_0_g() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
}
Reported by PMD.
Line: 31
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
}
public void test_1() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
Reported by PMD.
Line: 42
serializer.write("abc");
Assert.assertEquals("'abc'", serializer.getWriter().toString());
}
public void test_1_s() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Reported by PMD.
Line: 45
Assert.assertEquals("'abc'", serializer.getWriter().toString());
}
public void test_1_s() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
Reported by PMD.
Line: 56
serializer.write("abc");
Assert.assertEquals("'abc'", serializer.getWriter().toString());
}
public void test_2() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Reported by PMD.
Line: 59
Assert.assertEquals("'abc'", serializer.getWriter().toString());
}
public void test_2() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
serializer.config(SerializerFeature.UseSingleQuotes, true);
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
Reported by PMD.
Line: 65
serializer.config(SerializerFeature.UseSingleQuotes, true);
Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));
serializer.write(Collections.singletonMap("age", 33));
Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
}
public void test_2_s() throws Exception {
Reported by PMD.
Line: 67
serializer.write(Collections.singletonMap("age", 33));
Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
}
public void test_2_s() throws Exception {
JSONSerializer serializer = new JSONSerializer(new SerializeWriter());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/LongTest2.java
47 issues
Line: 14
* Created by wenshao on 11/08/2017.
*/
public class LongTest2 extends TestCase {
public void test_0() throws Exception {
String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
Reported by PMD.
Line: 14
* Created by wenshao on 11/08/2017.
*/
public class LongTest2 extends TestCase {
public void test_0() throws Exception {
String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
Reported by PMD.
Line: 21
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
Reported by PMD.
Line: 22
Model m2 = JSON.parseObject(json2, Model.class);
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
Reported by PMD.
Line: 24
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
Reported by PMD.
Line: 25
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
assertEquals(-1883391953414482124L, m2.v1);
Reported by PMD.
Line: 26
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
assertEquals(-1883391953414482124L, m2.v1);
assertEquals(-3019416596934963650L, m2.v2);
Reported by PMD.
Line: 27
assertEquals(-1883391953414482124L, m1.v1);
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
assertEquals(-1883391953414482124L, m2.v1);
assertEquals(-3019416596934963650L, m2.v2);
assertEquals(6497525620823745793L, m2.v3);
Reported by PMD.
Line: 28
assertEquals(-3019416596934963650L, m1.v2);
assertEquals(6497525620823745793L, m1.v3);
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
assertEquals(-1883391953414482124L, m2.v1);
assertEquals(-3019416596934963650L, m2.v2);
assertEquals(6497525620823745793L, m2.v3);
assertEquals(2136224289077142499L, m2.v4);
Reported by PMD.
Line: 30
assertEquals(2136224289077142499L, m1.v4);
assertEquals(-2090575024006307745L, m1.v5);
assertEquals(-1883391953414482124L, m2.v1);
assertEquals(-3019416596934963650L, m2.v2);
assertEquals(6497525620823745793L, m2.v3);
assertEquals(2136224289077142499L, m2.v4);
assertEquals(-2090575024006307745L, m2.v5);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_yangzhou.java
47 issues
Line: 149
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
Reported by PMD.
Line: 156
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
Reported by PMD.
Line: 163
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
Reported by PMD.
Line: 1104
return orderCondition;
}
}
throw new RuntimeException("OrderCondition of " + name + " enum not exist");
}
@Override
public String toString() {
return columnName;
Reported by PMD.
Line: 1134
return sortType;
}
}
throw new RuntimeException("SortType of " + name + " enum not exist");
}
@Override
public String toString() {
return value;
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";
System.out.println(test);
CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
System.out.println(JSON.toJSONString(cabinetAuthCodeParam));
final String jsonString = JSON.toJSONString(cabinetAuthCodeParam);
assertEquals("{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"listValue\":false,\"noValue\":false,\"condition\":\"area_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"listValue\":false,\"noValue\":false,\"condition\":\"cabinet_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":500036},{\"listValue\":false,\"noValue\":false,\"condition\":\"status =\",\"betweenValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}", jsonString);
// CabinetAuthCodeRecordParam cabinetAuthCodeRecordParam = JSONObject.toJavaObject(JSON.parseObject(jsonString), CabinetAuthCodeRecordParam.class);
Reported by PMD.
Line: 17
System.out.println(test);
CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
System.out.println(JSON.toJSONString(cabinetAuthCodeParam));
final String jsonString = JSON.toJSONString(cabinetAuthCodeParam);
assertEquals("{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"listValue\":false,\"noValue\":false,\"condition\":\"area_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"listValue\":false,\"noValue\":false,\"condition\":\"cabinet_id =\",\"betweenValue\":false,\"singleValue\":true,\"value\":500036},{\"listValue\":false,\"noValue\":false,\"condition\":\"status =\",\"betweenValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}", jsonString);
// CabinetAuthCodeRecordParam cabinetAuthCodeRecordParam = JSONObject.toJavaObject(JSON.parseObject(jsonString), CabinetAuthCodeRecordParam.class);
// System.out.println(JSON.toJSONString(cabinetAuthCodeRecordParam));
}
Reported by PMD.
Line: 1
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Reported by PMD.
Line: 11
import java.util.Date;
import java.util.List;
public class Bug_for_yangzhou extends TestCase {
public void test_for_issue() throws Exception {
String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";
System.out.println(test);
CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
Reported by PMD.
Line: 12
import java.util.List;
public class Bug_for_yangzhou extends TestCase {
public void test_for_issue() throws Exception {
String test = "{\"distinct\":false,\"oredCriteria\":[{\"allCriteria\":[{\"betweenValue\":false,\"condition\":\"area_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":917477670000000000},{\"betweenValue\":false,\"condition\":\"cabinet_id =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":500036},{\"betweenValue\":false,\"condition\":\"status =\",\"listValue\":false,\"noValue\":false,\"singleValue\":true,\"value\":0}],\"criteria\":[{\"$ref\":\"$.oredCriteria[0].allCriteria[0]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[1]\"},{\"$ref\":\"$.oredCriteria[0].allCriteria[2]\"}],\"valid\":true}],\"page\":true,\"pageIndex\":0,\"pageSize\":1,\"pageStart\":1}";
System.out.println(test);
CabinetAuthCodeParam cabinetAuthCodeParam = JSONObject.toJavaObject(JSON.parseObject(test), CabinetAuthCodeParam.class);
System.out.println(JSON.toJSONString(cabinetAuthCodeParam));
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_cnhans.java
45 issues
Line: 17
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Bug_for_cnhans extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
Reported by PMD.
Line: 22
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
VO vo = new VO();
vo.setCalendar(Calendar.getInstance());
String text = JSON.toJSONString(vo);
Reported by PMD.
Line: 29
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
}
public void test_format() throws Exception {
VO vo = new VO();
vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));
Reported by PMD.
Line: 29
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
}
public void test_format() throws Exception {
VO vo = new VO();
vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));
Reported by PMD.
Line: 29
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
}
public void test_format() throws Exception {
VO vo = new VO();
vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));
Reported by PMD.
Line: 32
Assert.assertEquals(vo.getCalendar().getTime(), vo1.getCalendar().getTime());
}
public void test_format() throws Exception {
VO vo = new VO();
vo.setCalendar(Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale));
String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
Reported by PMD.
Line: 39
String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));
Reported by PMD.
Line: 39
String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));
Reported by PMD.
Line: 39
String text = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));
Reported by PMD.
Line: 40
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getCalendar().get(Calendar.YEAR), vo1.getCalendar().get(Calendar.YEAR));
Assert.assertEquals(vo.getCalendar().get(Calendar.MONTH), vo1.getCalendar().get(Calendar.MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.DAY_OF_MONTH), vo1.getCalendar().get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(vo.getCalendar().get(Calendar.HOUR_OF_DAY), vo1.getCalendar().get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(vo.getCalendar().get(Calendar.MINUTE), vo1.getCalendar().get(Calendar.MINUTE));
Assert.assertEquals(vo.getCalendar().get(Calendar.SECOND), vo1.getCalendar().get(Calendar.SECOND));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_2.java
45 issues
Line: 11
import junit.framework.TestCase;
public class JSONPath_2 extends TestCase {
public void test_path() throws Exception {
String json ="{\"user\":[{\"amount\":1.11,\"isadmin\":true,\"age\":18},{\"amount\":0.22,\"isadmin\":false,\"age\":28}]}";
{
JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
Reported by PMD.
Line: 17
{
JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Reported by PMD.
Line: 19
JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Reported by PMD.
Line: 19
JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Reported by PMD.
Line: 19
JSONArray array = (JSONArray) JSONPath.read(json, "$.user");
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Reported by PMD.
Line: 20
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
Reported by PMD.
Line: 20
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
Reported by PMD.
Line: 20
Assert.assertEquals(2, array.size());
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
Reported by PMD.
Line: 21
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
}
Reported by PMD.
Line: 21
Assert.assertTrue(1.11D == array.getJSONObject(0).getDoubleValue("amount"));
Assert.assertTrue(array.getJSONObject(0).getBoolean("isadmin"));
Assert.assertTrue(18 == array.getJSONObject(0).getIntValue("age"));
Assert.assertTrue(0.22D == array.getJSONObject(1).getDoubleValue("amount"));
Assert.assertFalse(array.getJSONObject(1).getBoolean("isadmin"));
Assert.assertTrue(28 == array.getJSONObject(1).getIntValue("age"));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest5.java
45 issues
Line: 12
import junit.framework.TestCase;
public class LocalDateTest5 extends TestCase {
private Locale origin;
protected void setUp() throws Exception {
origin = Locale.getDefault();
Reported by PMD.
Line: 14
public class LocalDateTest5 extends TestCase {
private Locale origin;
protected void setUp() throws Exception {
origin = Locale.getDefault();
}
Reported by PMD.
Line: 16
private Locale origin;
protected void setUp() throws Exception {
origin = Locale.getDefault();
}
protected void tearDown() throws Exception {
Locale.setDefault(origin);
Reported by PMD.
Line: 20
origin = Locale.getDefault();
}
protected void tearDown() throws Exception {
Locale.setDefault(origin);
}
public void test_for_tw() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);
Reported by PMD.
Line: 24
Locale.setDefault(origin);
}
public void test_for_tw() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
Reported by PMD.
Line: 27
public void test_for_tw() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public void test_for_jp() throws Exception {
Reported by PMD.
Line: 28
VO vo = JSON.parseObject("{\"date\":\"2016/05/06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public void test_for_jp() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);
Reported by PMD.
Line: 29
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public void test_for_jp() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);
Reported by PMD.
Line: 32
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public void test_for_jp() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
Reported by PMD.
Line: 35
public void test_for_jp() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016年5月6日\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public void test_for_kr() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/test/TestUtils.java
45 issues
Line: 105
return (Long) mbeanServer.getAttribute(objectName, "CollectionCount");
} catch (Exception e) {
throw new RuntimeException("error");
}
}
public static long getYoungGCTime() {
try {
Reported by PMD.
Line: 125
return (Long) mbeanServer.getAttribute(objectName, "CollectionTime");
} catch (Exception e) {
throw new RuntimeException("error", e);
}
}
public static long getFullGC() {
try {
Reported by PMD.
Line: 146
return (Long) mbeanServer.getAttribute(objectName, "CollectionCount");
} catch (Exception e) {
throw new RuntimeException("error");
}
}
}
Reported by PMD.
Line: 10
import com.alibaba.fastjson.util.IOUtils;
public class TestUtils {
// ****************************************************************************************
// * char[] version
// ****************************************************************************************
Reported by PMD.
Line: 24
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster.
* @return A BASE64 encoded array. Never <code>null</code>.
*/
private final static char[] encodeToChar(byte[] sArr, boolean lineSep) {
char[] CA = IOUtils.CA;
// Check special case
int sLen = sArr != null ? sArr.length : 0;
if (sLen == 0) return new char[0];
Reported by PMD.
Line: 24
* No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a little faster.
* @return A BASE64 encoded array. Never <code>null</code>.
*/
private final static char[] encodeToChar(byte[] sArr, boolean lineSep) {
char[] CA = IOUtils.CA;
// Check special case
int sLen = sArr != null ? sArr.length : 0;
if (sLen == 0) return new char[0];
Reported by PMD.
Line: 37
char[] dArr = new char[dLen];
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = CA[(i >>> 18) & 0x3f];
Reported by PMD.
Line: 39
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = CA[(i >>> 18) & 0x3f];
dArr[d++] = CA[(i >>> 12) & 0x3f];
dArr[d++] = CA[(i >>> 6) & 0x3f];
Reported by PMD.
Line: 39
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = CA[(i >>> 18) & 0x3f];
dArr[d++] = CA[(i >>> 12) & 0x3f];
dArr[d++] = CA[(i >>> 6) & 0x3f];
Reported by PMD.
Line: 39
// Encode even 24-bits
for (int s = 0, d = 0, cc = 0; s < eLen;) {
// Copy next three bytes into lower 24 bits of int, paying attension to sign.
int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 | (sArr[s++] & 0xff);
// Encode the int into four chars
dArr[d++] = CA[(i >>> 18) & 0x3f];
dArr[d++] = CA[(i >>> 12) & 0x3f];
dArr[d++] = CA[(i >>> 6) & 0x3f];
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/AbstractDateDeserializer.java
45 issues
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.util.TypeUtils;
public abstract class AbstractDateDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
return deserialze(parser, clazz, fieldName, null, 0);
}
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.*;
import com.alibaba.fastjson.util.TypeUtils;
public abstract class AbstractDateDeserializer extends ContextObjectDeserializer implements ObjectDeserializer {
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
return deserialze(parser, clazz, fieldName, null, 0);
}
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.
Line: 21
@Override
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName, String format, int features) {
JSONLexer lexer = parser.lexer;
Object val;
if (lexer.token() == JSONToken.LITERAL_INT) {
long millis = lexer.longValue();
Reported by PMD.