The following issues were found
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Eishay.java
10 issues
Line: 22
}
public static class VO {
private short id;
private String name;
public short getId() {
return id;
}
Reported by PMD.
Line: 25
private short id;
private String name;
public short getId() {
return id;
}
public void setId(short id) {
this.id = id;
Reported by PMD.
Line: 29
return id;
}
public void setId(short id) {
this.id = id;
}
public String getName() {
return name;
Reported by PMD.
Line: 17
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
public static class VO {
private short id;
Reported by PMD.
Line: 13
import data.media.MediaContent;
public class WriteAsArray_Eishay extends TestCase {
public void test_0 () throws Exception {
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
Reported by PMD.
Line: 13
import data.media.MediaContent;
public class WriteAsArray_Eishay extends TestCase {
public void test_0 () throws Exception {
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
Reported by PMD.
Line: 14
public class WriteAsArray_Eishay extends TestCase {
public void test_0 () throws Exception {
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
Reported by PMD.
Line: 17
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
public static class VO {
private short id;
Reported by PMD.
Line: 17
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
public static class VO {
private short id;
Reported by PMD.
Line: 21
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
public static class VO {
private short id;
private String name;
public short getId() {
return id;
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/test/java/com/alibaba/json/bvt/issue_1300/Issue1300.java
10 issues
Line: 14
* Created by wenshao on 01/07/2017.
*/
public class Issue1300 extends TestCase {
public void testFullJSON() {
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
Reported by PMD.
Line: 14
* Created by wenshao on 01/07/2017.
*/
public class Issue1300 extends TestCase {
public void testFullJSON() {
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
Reported by PMD.
Line: 18
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
Reported by PMD.
Line: 20
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
Reported by PMD.
Line: 21
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Reported by PMD.
Line: 22
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Assert.assertEquals(null, object.name);
Reported by PMD.
Line: 25
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Assert.assertEquals(null, object.name);
Assert.assertEquals(0, object.code);
}
Reported by PMD.
Line: 33
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
Reported by PMD.
Line: 34
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
@JSONField(name = "name") String name,
Reported by PMD.
Line: 35
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
@JSONField(name = "name") String name,
@JSONField(name = "pinyin") String pinyin) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_465.java
10 issues
Line: 13
import junit.framework.TestCase;
public class Bug_for_issue_465 extends TestCase {
public void test_for_issue() throws Exception {
String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
TestBean testBean = JSON.parseObject(json, TestBean.class);
Assert.assertEquals("abc", testBean.name);
Assert.assertEquals("efg", testBean.country);
Reported by PMD.
Line: 25
Assert.assertEquals(2, testBean.location[1]);
}
public void f_test_for_issue_private() throws Exception {
String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
TestBean1 testBean = JSON.parseObject(json, TestBean1.class);
Assert.assertEquals("abc", testBean.name);
Assert.assertEquals("efg", testBean.country);
Reported by PMD.
Line: 38
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
public static class TestBean {
private String name;
private String password;
private String country;
Reported by PMD.
Line: 75
}
public int[] getLocation() {
return location;
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
Reported by PMD.
Line: 79
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
Reported by PMD.
Line: 85
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
private static class TestBean1 {
private String name;
private String password;
private String country;
Reported by PMD.
Line: 122
}
public int[] getLocation() {
return location;
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
Reported by PMD.
Line: 126
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
}
Reported by PMD.
Line: 79
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
Reported by PMD.
Line: 126
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CurrencyTest5.java
10 issues
Line: 21
jsonObject.put("value", Currency.getInstance("CNY"));
String text = JSON.toJSONString(jsonObject, config);
System.out.println(text);
String str1 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"symbol\":\"CNY\"}}";
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
Reported by PMD.
Line: 12
public class CurrencyTest5 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.put(Currency.class
, config.createJavaBeanSerializer(Currency.class));
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 12
public class CurrencyTest5 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.put(Currency.class
, config.createJavaBeanSerializer(Currency.class));
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 26
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 26
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 27
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 28
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
Reported by PMD.
Line: 29
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
Reported by PMD.
Line: 31
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
public static class VO {
Reported by PMD.
Line: 33
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
public static class VO {
public Currency value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1303.java
10 issues
Line: 16
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
public void test_for_issue() {
String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
JSONArray jsonArray = JSON.parseArray(jsonString);
//jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
Reported by PMD.
Line: 16
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
public void test_for_issue() {
String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
JSONArray jsonArray = JSON.parseArray(jsonString);
//jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
Reported by PMD.
Line: 23
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 23
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 24
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 26
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Created by kimmking on 02/07/2017.
Reported by PMD.
Line: 10
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/mixins/MixinSerForFieldsTest.java
10 issues
Line: 20
}
}
abstract class MixIn {
@JSONField(serialize = false)
public String a;
@JSONField(name = "banana")
public String b;
}
Reported by PMD.
Line: 11
public class MixinSerForFieldsTest extends TestCase {
static class BeanClass {
public String a;
public String b;
public BeanClass(String a, String b) {
this.a = a;
this.b = b;
Reported by PMD.
Line: 12
public class MixinSerForFieldsTest extends TestCase {
static class BeanClass {
public String a;
public String b;
public BeanClass(String a, String b) {
this.a = a;
this.b = b;
}
Reported by PMD.
Line: 20
}
}
abstract class MixIn {
@JSONField(serialize = false)
public String a;
@JSONField(name = "banana")
public String b;
}
Reported by PMD.
Line: 27
public String b;
}
public void test() throws Exception{
BeanClass bean = new BeanClass("1", "2");
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
Reported by PMD.
Line: 27
public String b;
}
public void test() throws Exception{
BeanClass bean = new BeanClass("1", "2");
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
Reported by PMD.
Line: 33
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 33
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 34
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 34
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
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/issue_1200/Issue1271.java
10 issues
Line: 19
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
public void processExtra(Object object, String key, Object value) {
System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
count.incrementAndGet();
}
};
Reported by PMD.
Line: 12
* Created by kimmking on 15/06/2017.
*/
public class Issue1271 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"a\":1,\"b\":2}";
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
Reported by PMD.
Line: 12
* Created by kimmking on 15/06/2017.
*/
public class Issue1271 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"a\":1,\"b\":2}";
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
Reported by PMD.
Line: 19
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
public void processExtra(Object object, String key, Object value) {
System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
count.incrementAndGet();
}
};
Reported by PMD.
Line: 26
A a = JSON.parseObject(json,A.class,extraProcessor);
assertEquals(1,a.a);
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
Reported by PMD.
Line: 27
A a = JSON.parseObject(json,A.class,extraProcessor);
assertEquals(1,a.a);
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
Reported by PMD.
Line: 30
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
}
public static class A {
Reported by PMD.
Line: 31
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
}
public static class A {
public int a;
Reported by PMD.
Line: 36
}
public static class A {
public int a;
}
public static class B {
private int a;
Reported by PMD.
Line: 36
}
public static class A {
public int a;
}
public static class B {
private int a;
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.