The following issues were found
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3637.java
3 issues
Line: 10
import java.sql.Timestamp;
public class Issue3637 extends TestCase {
public void test_for_issue() throws Exception {
// java.sql.Time.valueOf("01:00:00");
JSON.parseObject("\"01:00:00\"", java.sql.Time.class);
TypeUtils.castToJavaBean("01:00:00", java.sql.Time.class);
}
}
Reported by PMD.
Line: 10
import java.sql.Timestamp;
public class Issue3637 extends TestCase {
public void test_for_issue() throws Exception {
// java.sql.Time.valueOf("01:00:00");
JSON.parseObject("\"01:00:00\"", java.sql.Time.class);
TypeUtils.castToJavaBean("01:00:00", java.sql.Time.class);
}
}
Reported by PMD.
Line: 7
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import java.sql.Timestamp;
public class Issue3637 extends TestCase {
public void test_for_issue() throws Exception {
// java.sql.Time.valueOf("01:00:00");
JSON.parseObject("\"01:00:00\"", java.sql.Time.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1202.java
3 issues
Line: 15
* Created by wenshao on 16/05/2017.
*/
public class Issue1202 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.US;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 20
JSON.defaultLocale = Locale.US;
}
public void test_for_issue() throws Exception {
String text = "{\"date\":\"Apr 27, 2017 5:02:17 PM\"}";
Model model = JSON.parseObject(text, Model.class);
assertNotNull(model.date);
// assertEquals("{\"date\":\"Apr 27, 2017 5:02:17 PM\"}", JSON.toJSONString(model));
}
Reported by PMD.
Line: 23
public void test_for_issue() throws Exception {
String text = "{\"date\":\"Apr 27, 2017 5:02:17 PM\"}";
Model model = JSON.parseObject(text, Model.class);
assertNotNull(model.date);
// assertEquals("{\"date\":\"Apr 27, 2017 5:02:17 PM\"}", JSON.toJSONString(model));
}
public static class Model {
@JSONField(format = "MMM dd, yyyy h:mm:ss aa")
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_byte.java
3 issues
Line: 11
public class JSONCreatorTest_default_byte extends TestCase {
public void test_create() throws Exception {
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
Assert.assertEquals(0, model.id);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 20
public static class Model {
private final byte id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") byte id, @JSONField(name="name") String name) {
this.id = id;
Reported by PMD.
Line: 21
public static class Model {
private final byte id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") byte id, @JSONField(name="name") String name) {
this.id = id;
this.name = name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1188.java
3 issues
Line: 13
* Created by wenshao on 09/05/2017.
*/
public class Issue1188 extends TestCase {
public void test_for_issue_1188() throws Exception {
String json = "{\"ids\":\"a1,a2\",\"name\":\"abc\"}";
Info info = JSON.parseObject(json, Info.class);
assertNull(info.ids);
}
Reported by PMD.
Line: 16
public void test_for_issue_1188() throws Exception {
String json = "{\"ids\":\"a1,a2\",\"name\":\"abc\"}";
Info info = JSON.parseObject(json, Info.class);
assertNull(info.ids);
}
public static class Info{
@JSONField(deserialize=false)
Reported by PMD.
Line: 19
assertNull(info.ids);
}
public static class Info{
@JSONField(deserialize=false)
private List<Integer> ids;
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3614.java
3 issues
Line: 13
import java.util.zip.GZIPOutputStream;
public class Issue3614 extends TestCase {
public void test_for_issue() throws Exception {
byte[] gzipBytes = gzip(JSON.toJSONString(Collections.singletonMap("key", "value")).getBytes());
Object o = JSON.parseObject(gzipBytes, JSONObject.class);
assertEquals("{\"key\":\"value\"}", JSON.toJSONString(o));
}
Reported by PMD.
Line: 14
public class Issue3614 extends TestCase {
public void test_for_issue() throws Exception {
byte[] gzipBytes = gzip(JSON.toJSONString(Collections.singletonMap("key", "value")).getBytes());
Object o = JSON.parseObject(gzipBytes, JSONObject.class);
assertEquals("{\"key\":\"value\"}", JSON.toJSONString(o));
}
Reported by PMD.
Line: 17
byte[] gzipBytes = gzip(JSON.toJSONString(Collections.singletonMap("key", "value")).getBytes());
Object o = JSON.parseObject(gzipBytes, JSONObject.class);
assertEquals("{\"key\":\"value\"}", JSON.toJSONString(o));
}
private static byte[] gzip(byte[] source) throws IOException {
if (source == null) return null;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3400/Issue3470.java
3 issues
Line: 7
import junit.framework.TestCase;
public class Issue3470 extends TestCase {
public void test_for_issue() throws Exception {
String str = JSON.toJSONString(new Privacy().setPassword("test"));
assertEquals("{\"__password\":\"test\"}", str);
}
public static class Privacy {
Reported by PMD.
Line: 9
public class Issue3470 extends TestCase {
public void test_for_issue() throws Exception {
String str = JSON.toJSONString(new Privacy().setPassword("test"));
assertEquals("{\"__password\":\"test\"}", str);
}
public static class Privacy {
private String phone; //手机
private String password; //登录密码,隐藏字段
Reported by PMD.
Line: 14
public static class Privacy {
private String phone; //手机
private String password; //登录密码,隐藏字段
public Privacy() {
super();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_6.java
3 issues
Line: 13
public class JSONLexerTest_6 extends TestCase {
public void test_scanFieldString() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 17
Exception error = null;
try {
JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 14
public class JSONLexerTest_6 extends TestCase {
public void test_scanFieldString() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
} catch (Exception ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1177_2.java
3 issues
Line: 19
public void test_for_issue() throws Exception {
String text = "{\"a\":{\"x\":\"y\"},\"b\":{\"x\":\"y\"}}";
Map<String, Model> jsonObject = JSONObject.parseObject(text, new TypeReference<LinkedHashMap<String, Model>>(){});
System.out.println(JSON.toJSONString(jsonObject));
String jsonpath = "$..x";
String value="y2";
JSONPath.set(jsonObject, jsonpath, value);
assertEquals("{\"a\":{\"x\":\"y2\"},\"b\":{\"x\":\"y2\"}}", JSON.toJSONString(jsonObject));
Reported by PMD.
Line: 16
* Created by wenshao on 05/05/2017.
*/
public class Issue1177_2 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"a\":{\"x\":\"y\"},\"b\":{\"x\":\"y\"}}";
Map<String, Model> jsonObject = JSONObject.parseObject(text, new TypeReference<LinkedHashMap<String, Model>>(){});
System.out.println(JSON.toJSONString(jsonObject));
String jsonpath = "$..x";
String value="y2";
Reported by PMD.
Line: 23
String jsonpath = "$..x";
String value="y2";
JSONPath.set(jsonObject, jsonpath, value);
assertEquals("{\"a\":{\"x\":\"y2\"},\"b\":{\"x\":\"y2\"}}", JSON.toJSONString(jsonObject));
}
public static class Model {
public String x;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2736.java
3 issues
Line: 10
public void test_for_issue() throws Exception {
JSONObject s = JSONObject.parseObject("{1:2,3:4}");
for(String s1 : s.keySet()){
System.out.println(s1);
}
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue2736 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject s = JSONObject.parseObject("{1:2,3:4}");
for(String s1 : s.keySet()){
System.out.println(s1);
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue2736 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject s = JSONObject.parseObject("{1:2,3:4}");
for(String s1 : s.keySet()){
System.out.println(s1);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1725.java
3 issues
Line: 10
import java.util.Map;
public class Issue1725 extends TestCase {
public void test_for_issue() throws Exception {
Map<String, Object> map= new HashMap<String, Object>();
map.put("enumField", 0);
AbstractBean bean = JSON.parseObject(JSON.toJSONString(map), ConcreteBean.class);
assertEquals(FieldEnum.A, bean.enumField);
Reported by PMD.
Line: 15
map.put("enumField", 0);
AbstractBean bean = JSON.parseObject(JSON.toJSONString(map), ConcreteBean.class);
assertEquals(FieldEnum.A, bean.enumField);
}
public static class AbstractBean {
public FieldEnum enumField;
}
Reported by PMD.
Line: 19
}
public static class AbstractBean {
public FieldEnum enumField;
}
public static class ConcreteBean extends AbstractBean {
}
Reported by PMD.