The following issues were found
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest10.java
10 issues
Line: 10
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
Reported by PMD.
Line: 13
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
Reported by PMD.
Line: 15
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
public static class HeaderDTO {
private String title;
Reported by PMD.
Line: 16
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
public static class HeaderDTO {
private String title;
private String link;
Reported by PMD.
Line: 20
}
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
Reported by PMD.
Line: 20
}
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
Reported by PMD.
Line: 21
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
this.link = link;
Reported by PMD.
Line: 21
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
this.link = link;
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.parser.creator;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SpecialTest.java
10 issues
Line: 16
count++;
}
}
System.out.println(count);
}
final static long flags;
static {
long val = 0L;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.serializer.SerializerFeature;
public class SpecialTest {
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
Reported by PMD.
Line: 7
public class SpecialTest {
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
Reported by PMD.
Line: 28
}
static boolean isSpecial(char ch) {
if (ch <= 31) {
return true;
}
if (ch > '\\') { // 92
return false;
Reported by PMD.
Line: 32
return true;
}
if (ch > '\\') { // 92
return false;
}
return ((1L << (ch - 31)) & flags) != 0;
}
Reported by PMD.
Line: 44
// return false;
// }
if (ch == ' ') { // 32
return false;
}
if (ch == '/') { // 47
return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
Reported by PMD.
Line: 48
return false;
}
if (ch == '/') { // 47
return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
}
if (ch > '#' // 35
&& ch != '\\' // 92
Reported by PMD.
Line: 58
return false;
}
if (ch <= 0x1F // 31
|| ch == '\\' // 92
|| ch == '"' // 34
) {
return true;
}
Reported by PMD.
Line: 9
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
count++;
}
Reported by PMD.
Line: 13
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
count++;
}
}
System.out.println(count);
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/JSONLibDataFormatSerializer.java
10 issues
Line: 17
@SuppressWarnings("deprecation")
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
if (object == null) {
serializer.out.writeNull();
return;
}
Date date = (Date) object;
Reported by PMD.
Line: 24
Date date = (Date) object;
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
Reported by PMD.
Line: 25
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
Reported by PMD.
Line: 26
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
Reported by PMD.
Line: 27
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
Reported by PMD.
Line: 28
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
Reported by PMD.
Line: 29
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
Reported by PMD.
Line: 30
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
Reported by PMD.
Line: 31
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
}
Reported by PMD.
Line: 32
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_12.java
10 issues
Line: 44
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 45
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 12
public class JSONPath_12
extends TestCase {
public void test(){
JSONObject schemaResult = JSON.parseObject("{\n" +
" \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n" +
" \"title\": \"AE product schema\",\n" +
" \"description\": \"AE product schema\",\n" +
" \"type\": \"object\",\n" +
Reported by PMD.
Line: 12
public class JSONPath_12
extends TestCase {
public void test(){
JSONObject schemaResult = JSON.parseObject("{\n" +
" \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n" +
" \"title\": \"AE product schema\",\n" +
" \"description\": \"AE product schema\",\n" +
" \"type\": \"object\",\n" +
Reported by PMD.
Line: 38
" \"title\": \"Brand Name\",\n" +
" \"type\": \"String\"\n" +
"}");
assertTrue(
JSONPath.set(schemaResult, jsonPath + "['" + attributeName + "']" , attributeValue)
);
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
Reported by PMD.
Line: 42
JSONPath.set(schemaResult, jsonPath + "['" + attributeName + "']" , attributeValue)
);
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
Reported by PMD.
Line: 45
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 46
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 46
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.path;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
public class JSONPath_12
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_256.java
10 issues
Line: 42
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
public static class AisleDeployInfo {
Reported by PMD.
Line: 17
public class Bug_for_issue_256 extends TestCase {
public void test_for_issue() throws Exception {
List<AisleDeployInfo> list3 = new ArrayList<AisleDeployInfo>();
AisleDeployInfo aisleDeployInfo = new AisleDeployInfo();
aisleDeployInfo.setId(1L);
aisleDeployInfo.setProvinceArea("3,4,5");
list3.add(aisleDeployInfo);
Reported by PMD.
Line: 17
public class Bug_for_issue_256 extends TestCase {
public void test_for_issue() throws Exception {
List<AisleDeployInfo> list3 = new ArrayList<AisleDeployInfo>();
AisleDeployInfo aisleDeployInfo = new AisleDeployInfo();
aisleDeployInfo.setId(1L);
aisleDeployInfo.setProvinceArea("3,4,5");
list3.add(aisleDeployInfo);
Reported by PMD.
Line: 40
Map<String, List<AisleDeployInfo>> map1 = JSON.parseObject(str, new TypeReference<Map<String, List<AisleDeployInfo>>>(){});
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 40
Map<String, List<AisleDeployInfo>> map1 = JSON.parseObject(str, new TypeReference<Map<String, List<AisleDeployInfo>>>(){});
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 41
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 42
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
public static class AisleDeployInfo {
Reported by PMD.
Line: 47
}
}
public static class AisleDeployInfo {
private long id;
private String provinceArea;
public long getId() {
return id;
Reported by PMD.
Line: 75
}
public static class Model extends HashMap {
}
}
Reported by PMD.
Line: 8
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Collection.java
10 issues
Line: 22
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection$A\",\"list\":[{}]}",
text);
A a1 = (A) JSON.parse(text);
Reported by PMD.
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Collection extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 15
public class WriteClassNameTest_Collection extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
Reported by PMD.
Line: 18
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection$A\",\"list\":[{}]}",
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 6
import java.util.Collection;
import java.util.Collections;
import com.alibaba.fastjson.parser.ParserConfig;
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set2.java
10 issues
Line: 26
set.add(new B1());
a.setList(set);
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
// Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$B1\"}]}",
// text);
ParserConfig parserConfig = new ParserConfig();
parserConfig.addAccept("com.alibaba.json.bvt");
Reported by PMD.
Line: 15
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Set2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 16
public class WriteClassNameTest_Set2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Set<B> set = new LinkedHashSet<B>();
Reported by PMD.
Line: 19
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Set<B> set = new LinkedHashSet<B>();
set.add(new B());
set.add(new B1());
a.setList(set);
Reported by PMD.
Line: 34
parserConfig.addAccept("com.alibaba.json.bvt");
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 34
parserConfig.addAccept("com.alibaba.json.bvt");
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 35
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 35
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 36
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
private Set<B> list;
Reported by PMD.
Line: 36
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
private Set<B> list;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/ProxyTest2.java
10 issues
Line: 15
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
Reported by PMD.
Line: 12
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
Reported by PMD.
Line: 12
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
Reported by PMD.
Line: 13
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
Reported by PMD.
Line: 14
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
Reported by PMD.
Line: 15
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
Reported by PMD.
Line: 20
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
}
public static interface Model {
Reported by PMD.
Line: 21
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
}
public static interface Model {
int getId();
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import java.lang.reflect.Proxy;
/**
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
Reported by PMD.
Line: 14
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
Reported by PMD.
src/test/java/com/alibaba/fastjson/codegen/ClassGen.java
10 issues
Line: 6
import java.io.IOException;
import java.lang.reflect.Type;
public abstract class ClassGen {
protected Class<?> clazz;
protected Type type;
protected Appendable out;
Reported by PMD.
Line: 8
public abstract class ClassGen {
protected Class<?> clazz;
protected Type type;
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
Reported by PMD.
Line: 9
public abstract class ClassGen {
protected Class<?> clazz;
protected Type type;
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
Reported by PMD.
Line: 10
protected Class<?> clazz;
protected Type type;
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
public ClassGen(Class<?> clazz, Appendable out){
Reported by PMD.
Line: 12
protected Type type;
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
public ClassGen(Class<?> clazz, Appendable out){
this(clazz, null, out);
}
Reported by PMD.
Line: 12
protected Type type;
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
public ClassGen(Class<?> clazz, Appendable out){
this(clazz, null, out);
}
Reported by PMD.
Line: 13
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
public ClassGen(Class<?> clazz, Appendable out){
this(clazz, null, out);
}
Reported by PMD.
Line: 13
protected Appendable out;
private String indent = "\t";
private int indentCount = 0;
public ClassGen(Class<?> clazz, Appendable out){
this(clazz, null, out);
}
Reported by PMD.
Line: 44
protected void printPackage() throws IOException {
print("package ");
print(clazz.getPackage().getName());
println(";");
}
protected void beginClass(String className) throws IOException {
print("public class ");
Reported by PMD.
Line: 102
protected void printClassName(Class<?> clazz) throws IOException {
String name = clazz.getName();
name = name.replace('$', '.');
print(name);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_NonStringKeyMap.java
10 issues
Line: 22
vo.getMap().put(1L, new VAL());
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parse(text);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 33
submap.put("subkey", "subvalue");
map.put(submap, "value");
String jsonString = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(jsonString);
Object object = JSON.parse(jsonString);
System.out.println(object.toString());
}
public static class VO {
Reported by PMD.
Line: 35
String jsonString = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(jsonString);
Object object = JSON.parse(jsonString);
System.out.println(object.toString());
}
public static class VO {
private Map<Long, VAL> map = new HashMap<Long, VAL>();
Reported by PMD.
Line: 13
import junit.framework.TestCase;
public class Bug_for_NonStringKeyMap extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_NonStringKeyMap.");
}
public void test_bug() throws Exception {
VO vo = new VO();
Reported by PMD.
Line: 14
public class Bug_for_NonStringKeyMap extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_NonStringKeyMap.");
}
public void test_bug() throws Exception {
VO vo = new VO();
vo.getMap().put(1L, new VAL());
Reported by PMD.
Line: 17
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_NonStringKeyMap.");
}
public void test_bug() throws Exception {
VO vo = new VO();
vo.getMap().put(1L, new VAL());
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 17
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_NonStringKeyMap.");
}
public void test_bug() throws Exception {
VO vo = new VO();
vo.getMap().put(1L, new VAL());
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 27
JSON.parse(text);
}
public void test_1() throws Exception {
Map<Map<String, String>, String> map = new HashMap<Map<String, String>, String>();
Map<String, String> submap = new HashMap<String, String>();
submap.put("subkey", "subvalue");
map.put(submap, "value");
String jsonString = JSON.toJSONString(map, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 27
JSON.parse(text);
}
public void test_1() throws Exception {
Map<Map<String, String>, String> map = new HashMap<Map<String, String>, String>();
Map<String, String> submap = new HashMap<String, String>();
submap.put("subkey", "subvalue");
map.put(submap, "value");
String jsonString = JSON.toJSONString(map, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 35
String jsonString = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(jsonString);
Object object = JSON.parse(jsonString);
System.out.println(object.toString());
}
public static class VO {
private Map<Long, VAL> map = new HashMap<Long, VAL>();
Reported by PMD.