The following issues were found
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_float2_private.java
8 issues
Line: 13
import junit.framework.TestCase;
public class WriteAsArray_float2_private extends TestCase {
public void test_0 () throws Exception {
VO vo = new VO();
vo.setId(123F);
vo.setName("wenshao");
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Reported by PMD.
Line: 26
Assert.assertEquals(vo.name, vo2.name);
}
public void test_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 36
Assert.assertNotNull(error);
}
public void test_error1() throws Exception {
Exception error = null;
try {
JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 46
Assert.assertNotNull(error);
}
public void test_error2() throws Exception {
Exception error = null;
try {
JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 56
Assert.assertNotNull(error);
}
private static class VO {
private float id;
private String name;
public float getId() {
return id;
Reported by PMD.
Line: 27
}
public void test_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 37
}
public void test_error1() throws Exception {
Exception error = null;
try {
JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 47
}
public void test_error2() throws Exception {
Exception error = null;
try {
JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_yanpei2.java
8 issues
Line: 11
import junit.framework.TestCase;
public class Bug_for_yanpei2 extends TestCase {
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
Reported by PMD.
Line: 14
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 14
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 16
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
Line: 16
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_yanpei.java
8 issues
Line: 11
import junit.framework.TestCase;
public class Bug_for_yanpei extends TestCase {
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
Reported by PMD.
Line: 14
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 14
public void test_for_sepcial_chars() throws Exception {
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 15
String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 16
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
Line: 16
JSONObject obj = JSON.parseObject(text);
Assert.assertEquals(true, obj.get("answerAllow"));;
Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_xujin_int.java
8 issues
Line: 14
public class Bug_for_xujin_int extends TestCase {
public void test_for_xujin() throws Exception {
String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
System.out.println(JSON.VERSION);
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
public static class ResultDTO<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 3682481175041925854L;
Reported by PMD.
Line: 12
* Created by wenshao on 09/02/2017.
*/
public class Bug_for_xujin_int extends TestCase {
public void test_for_xujin() throws Exception {
String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
System.out.println(JSON.VERSION);
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
Reported by PMD.
Line: 12
* Created by wenshao on 09/02/2017.
*/
public class Bug_for_xujin_int extends TestCase {
public void test_for_xujin() throws Exception {
String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
System.out.println(JSON.VERSION);
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
Reported by PMD.
Line: 15
public void test_for_xujin() throws Exception {
String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
System.out.println(JSON.VERSION);
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
public static class ResultDTO<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 3682481175041925854L;
private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
Reported by PMD.
Line: 18
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
public static class ResultDTO<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 3682481175041925854L;
private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
private String errorMsg;
private String errorCode;
private int success;
Reported by PMD.
Line: 20
public static class ResultDTO<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 3682481175041925854L;
private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
private String errorMsg;
private String errorCode;
private int success;
private T module;
Reported by PMD.
Line: 23
private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
private String errorMsg;
private String errorCode;
private int success;
private T module;
public ResultDTO() {
Reported by PMD.
Line: 15
public void test_for_xujin() throws Exception {
String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
System.out.println(JSON.VERSION);
ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
}
public static class ResultDTO<T extends Serializable> implements Serializable {
private static final long serialVersionUID = 3682481175041925854L;
private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_xiedun.java
8 issues
Line: 13
import java.io.FileReader;
public class Bug_for_xiedun extends TestCase {
public void test_for_issue() throws Exception {
// File file = new File("/Users/wenshao/Downloads/json.txt");
//
// BufferedReader reader = new BufferedReader(new FileReader(file));
// char[] buf = new char[20480];
// int readed = reader.read(buf);
Reported by PMD.
Line: 13
import java.io.FileReader;
public class Bug_for_xiedun extends TestCase {
public void test_for_issue() throws Exception {
// File file = new File("/Users/wenshao/Downloads/json.txt");
//
// BufferedReader reader = new BufferedReader(new FileReader(file));
// char[] buf = new char[20480];
// int readed = reader.read(buf);
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Reported by PMD.
Line: 8
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Bug_for_xiedun extends TestCase {
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 9
import org.apache.commons.io.IOUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Bug_for_xiedun extends TestCase {
public void test_for_issue() throws Exception {
// File file = new File("/Users/wenshao/Downloads/json.txt");
Reported by PMD.
Line: 10
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Bug_for_xiedun extends TestCase {
public void test_for_issue() throws Exception {
// File file = new File("/Users/wenshao/Downloads/json.txt");
//
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Object.java
8 issues
Line: 14
public class WriteAsArray_Object extends TestCase {
public void test_0() throws Exception {
A a = new A();
a.setId(123);
a.setName("wenshao");
VO vo = new VO();
Reported by PMD.
Line: 26
Assert.assertEquals("[[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
private A a;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
private A a;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
}
private static class VO {
private A a;
Reported by PMD.
Line: 44
}
private static class A {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/util/Base64Test.java
8 issues
Line: 7
import junit.framework.TestCase;
public class Base64Test extends TestCase {
public void test_base64() throws Exception {
String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";
byte[] bytes = str.getBytes("UTF8");
String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Base64Test extends TestCase {
public void test_base64() throws Exception {
String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";
byte[] bytes = str.getBytes("UTF8");
String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
Reported by PMD.
Line: 10
public void test_base64() throws Exception {
String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";
byte[] bytes = str.getBytes("UTF8");
String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
{
byte[] bytes2 = Base64.decodeFast(base64Str);
assertEquals(str, new String(bytes2, "UTF8"));
Reported by PMD.
Line: 10
public void test_base64() throws Exception {
String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";
byte[] bytes = str.getBytes("UTF8");
String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
{
byte[] bytes2 = Base64.decodeFast(base64Str);
assertEquals(str, new String(bytes2, "UTF8"));
Reported by PMD.
Line: 11
String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";
byte[] bytes = str.getBytes("UTF8");
String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
{
byte[] bytes2 = Base64.decodeFast(base64Str);
assertEquals(str, new String(bytes2, "UTF8"));
}
Reported by PMD.
Line: 15
{
byte[] bytes2 = Base64.decodeFast(base64Str);
assertEquals(str, new String(bytes2, "UTF8"));
}
{
byte[] bytes2 = Base64.decodeFast(base64Str, 0, base64Str.length());
assertEquals(str, new String(bytes2, "UTF8"));
Reported by PMD.
Line: 20
{
byte[] bytes2 = Base64.decodeFast(base64Str, 0, base64Str.length());
assertEquals(str, new String(bytes2, "UTF8"));
}
{
byte[] bytes2 = Base64.decodeFast(base64Str.toCharArray(), 0, base64Str.length());
assertEquals(str, new String(bytes2, "UTF8"));
Reported by PMD.
Line: 25
{
byte[] bytes2 = Base64.decodeFast(base64Str.toCharArray(), 0, base64Str.length());
assertEquals(str, new String(bytes2, "UTF8"));
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2800/Issue2894.java
8 issues
Line: 14
import java.util.TimeZone;
public class Issue2894 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getDefault();
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 19
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
Pojo pojo = JSONObject.parseObject(json, Pojo.class);
int nanos = pojo.timestamp.getNanos();
assertEquals(nanos, 350000000);
assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
Reported by PMD.
Line: 19
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
Pojo pojo = JSONObject.parseObject(json, Pojo.class);
int nanos = pojo.timestamp.getNanos();
assertEquals(nanos, 350000000);
assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
Reported by PMD.
Line: 22
public void test_for_issue() throws Exception {
String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
Pojo pojo = JSONObject.parseObject(json, Pojo.class);
int nanos = pojo.timestamp.getNanos();
assertEquals(nanos, 350000000);
assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
}
public static class Pojo {
Reported by PMD.
Line: 23
String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
Pojo pojo = JSONObject.parseObject(json, Pojo.class);
int nanos = pojo.timestamp.getNanos();
assertEquals(nanos, 350000000);
assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
}
public static class Pojo {
@JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")
Reported by PMD.
Line: 24
Pojo pojo = JSONObject.parseObject(json, Pojo.class);
int nanos = pojo.timestamp.getNanos();
assertEquals(nanos, 350000000);
assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
}
public static class Pojo {
@JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")
public Timestamp timestamp;
Reported by PMD.
Line: 29
public static class Pojo {
@JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")
public Timestamp timestamp;
}
}
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Locale;
import java.util.TimeZone;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1558.java
8 issues
Line: 11
import java.io.Serializable;
public class Issue1558 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
String text = "{\"id\": \"439a3213-e734-4bf3-9870-2c471f43d651\", \"instance\": \"v1\", \"interface\": \"com.xxx.aplan.UICommands\", \"method\": \"start\", \"params\": [\"tony\"], \"@type\": \"com.alibaba.json.bvt.issue_1500.Issue1558$Request\"}";
JSON.parseObject(text, Request.class, config);
Reported by PMD.
Line: 11
import java.io.Serializable;
public class Issue1558 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
String text = "{\"id\": \"439a3213-e734-4bf3-9870-2c471f43d651\", \"instance\": \"v1\", \"interface\": \"com.xxx.aplan.UICommands\", \"method\": \"start\", \"params\": [\"tony\"], \"@type\": \"com.alibaba.json.bvt.issue_1500.Issue1558$Request\"}";
JSON.parseObject(text, Request.class, config);
Reported by PMD.
Line: 20
}
@JSONType
public static class Request implements Serializable {
private String id;
private String instance;
private String _interface;
private String method;
private Object[] params;
Reported by PMD.
Line: 20
}
@JSONType
public static class Request implements Serializable {
private String id;
private String instance;
private String _interface;
private String method;
private Object[] params;
Reported by PMD.
Line: 23
public static class Request implements Serializable {
private String id;
private String instance;
private String _interface;
private String method;
private Object[] params;
public String getId() {
return id;
}
Reported by PMD.
Line: 51
this.method = method;
}
public Object[] getParams() {
return params;
}
public void setParams(Object[] params) {
this.params = params;
}
}
Reported by PMD.
Line: 53
public Object[] getParams() {
return params;
}
public void setParams(Object[] params) {
this.params = params;
}
}
}
Reported by PMD.
Line: 53
public Object[] getParams() {
return params;
}
public void setParams(Object[] params) {
this.params = params;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2800/Issue2830.java
8 issues
Line: 8
import junit.framework.TestCase;
public class Issue2830 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue2830 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
Reported by PMD.
Line: 11
public void test_for_issue() throws Exception {
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.
Line: 11
public void test_for_issue() throws Exception {
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.
Line: 12
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.
Line: 12
JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.
Line: 13
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.
Line: 13
assertEquals(10, jsonObject.getIntValue("qty"));
assertEquals(10, jsonObject.getIntValue("qty1"));
assertEquals(10, jsonObject.getIntValue("qty2"));
}
}
Reported by PMD.