The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1079.java
6 issues
Line: 14
* Created by wenshao on 17/03/2017.
*/
public class Issue1079 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\n" +
"\t\"Response\": [{\n" +
"\t\t\"Status\": {\n" +
"\t\t\t\"StatusCode\": {\n" +
"\t\t\t\t\"Value\": \"urn:oasis:names:tc:xacml:1.0:status:ok\"\n" +
Reported by PMD.
Line: 14
* Created by wenshao on 17/03/2017.
*/
public class Issue1079 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\n" +
"\t\"Response\": [{\n" +
"\t\t\"Status\": {\n" +
"\t\t\t\"StatusCode\": {\n" +
"\t\t\t\t\"Value\": \"urn:oasis:names:tc:xacml:1.0:status:ok\"\n" +
Reported by PMD.
Line: 33
public static class PdpResponse {
@JSONField(name ="Response")
public List<Response> response;
public static class Response {
public List<InnerObject> innerObjects;
}
Reported by PMD.
Line: 36
public List<Response> response;
public static class Response {
public List<InnerObject> innerObjects;
}
public static class InnerObject {
@JSONField(name = "Status")
public Status status;
Reported by PMD.
Line: 43
@JSONField(name = "Status")
public Status status;
@JSONField(name = "Decision")
public String decision;
}
public static class Status {
@JSONField(name = "StatusCode")
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import junit.framework.TestCase;
import java.util.List;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest.java
6 issues
Line: 13
public class JSONCreatorTest extends TestCase {
public void test_create() throws Exception {
Entity entity = new Entity(123, "菜姐");
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getId(), entity2.getId());
Reported by PMD.
Line: 18
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getId(), entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123, "菜姐");
Reported by PMD.
Line: 19
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getId(), entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123, "菜姐");
String text = JSON.toJSONString(entity);
Reported by PMD.
Line: 22
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
Reported by PMD.
Line: 30
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity.getId(), entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 31
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity.getId(), entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
private final int id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3300/Issue3351.java
6 issues
Line: 11
* @Date :Created in 00:14 2020/7/18
*/
public class Issue3351 extends TestCase {
public void test_for_issue() throws Exception {
String cString = "c110";
boolean cValid = JSONValidator.from(cString).validate();
assertFalse(cValid);
String jsonString = "{\"forecast\":\"sss\"}";
Reported by PMD.
Line: 11
* @Date :Created in 00:14 2020/7/18
*/
public class Issue3351 extends TestCase {
public void test_for_issue() throws Exception {
String cString = "c110";
boolean cValid = JSONValidator.from(cString).validate();
assertFalse(cValid);
String jsonString = "{\"forecast\":\"sss\"}";
Reported by PMD.
Line: 13
public class Issue3351 extends TestCase {
public void test_for_issue() throws Exception {
String cString = "c110";
boolean cValid = JSONValidator.from(cString).validate();
assertFalse(cValid);
String jsonString = "{\"forecast\":\"sss\"}";
boolean jsonValid = JSONValidator.from(jsonString).validate();
assertTrue(jsonValid);
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String cString = "c110";
boolean cValid = JSONValidator.from(cString).validate();
assertFalse(cValid);
String jsonString = "{\"forecast\":\"sss\"}";
boolean jsonValid = JSONValidator.from(jsonString).validate();
assertTrue(jsonValid);
}
Reported by PMD.
Line: 17
assertFalse(cValid);
String jsonString = "{\"forecast\":\"sss\"}";
boolean jsonValid = JSONValidator.from(jsonString).validate();
assertTrue(jsonValid);
}
}
Reported by PMD.
Line: 18
String jsonString = "{\"forecast\":\"sss\"}";
boolean jsonValid = JSONValidator.from(jsonString).validate();
assertTrue(jsonValid);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_Module.java
6 issues
Line: 46
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
int features) throws IOException {
System.out.println("-------------myModule.createSerializer-------------------");
org.json.JSONObject req = (org.json.JSONObject) object;
serializer.out.write(req.toString());
}
};
}
Reported by PMD.
Line: 21
public class Issue1780_Module extends TestCase {
public void test_for_issue() {
org.json.JSONObject req = new org.json.JSONObject();
SerializeConfig config = new SerializeConfig();
config.register(new myModule());
req.put("id", 1111);
Reported by PMD.
Line: 30
req.put("name", "name11");
String text = JSON.toJSONString(req, SerializerFeature.SortField);
assertTrue("{\"id\":1111,\"name\":\"name11\"}".equals(text) || "{\"name\":\"name11\",\"id\":1111}".equals(text));
}
public class myModule implements Module {
@SuppressWarnings("rawtypes")
Reported by PMD.
Line: 48
int features) throws IOException {
System.out.println("-------------myModule.createSerializer-------------------");
org.json.JSONObject req = (org.json.JSONObject) object;
serializer.out.write(req.toString());
}
};
}
}
Reported by PMD.
Line: 48
int features) throws IOException {
System.out.println("-------------myModule.createSerializer-------------------");
org.json.JSONObject req = (org.json.JSONObject) object;
serializer.out.write(req.toString());
}
};
}
}
Reported by PMD.
Line: 7
import java.lang.reflect.Type;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.JSONSerializer;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/bug/Bug_for_lingzhi.java
6 issues
Line: 11
import java.util.List;
public class Bug_for_lingzhi extends TestCase {
public void test_0() throws Exception {
String str = "[\n" +
"{\n" +
"\"isDefault\":false,\n" +
"\"msgId\": \"expireTransitionChange\",\n" +
"\"msgText\": \"xxx\",\n" +
Reported by PMD.
Line: 11
import java.util.List;
public class Bug_for_lingzhi extends TestCase {
public void test_0() throws Exception {
String str = "[\n" +
"{\n" +
"\"isDefault\":false,\n" +
"\"msgId\": \"expireTransitionChange\",\n" +
"\"msgText\": \"xxx\",\n" +
Reported by PMD.
Line: 23
"\"rule\": {\n" +
"\"aliUid\":[39314],\n" +
"\"regionNo\":[]\n" +
"}\n" +
"},\n" +
"{\n" +
"\"isDefault\":true,\n" +
"\"msgId\": \"expireTransitionUnChange\",\n" +
"\"msgText\": \"xxx\",\n" +
Reported by PMD.
Line: 57
JSON.parseObject(str, new TypeReference<List<EcsTransitionDisplayedMsgConfig>>(){});
}
public static class EcsTransitionDisplayedMsgConfig {
/**
* 是否默认文案
*/
private Boolean isDefault;
Reported by PMD.
Line: 149
}
}
public static class EcsTransitionConfigRule {
/** 0 过保迁移, 1 非过保迁移 **/
private List<Integer> transType;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.util.List;
public class Bug_for_lingzhi extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONReader_error.java
6 issues
Line: 13
public class JSONReader_error extends TestCase {
public void test_0() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[]"));
Exception error = null;
try {
reader.hasNext();
Reported by PMD.
Line: 19
Exception error = null;
try {
reader.hasNext();
} catch (Exception e) {
error = e;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 26
}
public void test_1() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
reader.startObject();
reader.readObject();
Reported by PMD.
Line: 35
Exception error = null;
try {
reader.hasNext();
} catch (Exception e) {
error = e;
}
Assert.assertNotNull(error);
}
}
Reported by PMD.
Line: 16
public void test_0() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[]"));
Exception error = null;
try {
reader.hasNext();
} catch (Exception e) {
error = e;
}
Reported by PMD.
Line: 32
reader.startObject();
reader.readObject();
Exception error = null;
try {
reader.hasNext();
} catch (Exception e) {
error = e;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3300/Issue3373.java
6 issues
Line: 19
items.add(new Item("item1",category));
items.add(new Item("item2",category));
System.out.println(JSON.toJSONString(items,refAfterFilterTest));
}
public static class RefBeforeFilterTest extends BeforeFilter {
private Category category = new Category("afterFilterCategory");
Reported by PMD.
Line: 11
import java.util.List;
public class Issue3373 extends TestCase {
public void test_for_issue() throws Exception {
RefBeforeFilterTest refAfterFilterTest = new RefBeforeFilterTest();
List<Item> items = new ArrayList<Item>(2);
Category category = new Category("category");
items.add(new Item("item1",category));
Reported by PMD.
Line: 11
import java.util.List;
public class Issue3373 extends TestCase {
public void test_for_issue() throws Exception {
RefBeforeFilterTest refAfterFilterTest = new RefBeforeFilterTest();
List<Item> items = new ArrayList<Item>(2);
Category category = new Category("category");
items.add(new Item("item1",category));
Reported by PMD.
Line: 24
public static class RefBeforeFilterTest extends BeforeFilter {
private Category category = new Category("afterFilterCategory");
@Override
public void writeBefore(Object object) {
if (object instanceof Item) {
Reported by PMD.
Line: 24
public static class RefBeforeFilterTest extends BeforeFilter {
private Category category = new Category("afterFilterCategory");
@Override
public void writeBefore(Object object) {
if (object instanceof Item) {
Reported by PMD.
Line: 58
}
}
public static class Item {
private String name;
private Category category;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_double.java
6 issues
Line: 13
public class JSONCreatorTest_double extends TestCase {
public void test_create() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Reported by PMD.
Line: 18
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
Reported by PMD.
Line: 19
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
String text = JSON.toJSONString(entity);
Reported by PMD.
Line: 22
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
Reported by PMD.
Line: 29
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 30
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
private final double id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1134.java
6 issues
Line: 12
*/
public class Issue1134 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model.blockpos = new BlockPos();
model.blockpos.x = 526;
model.blockpos.y = 65;
model.blockpos.z = 554;
Reported by PMD.
Line: 21
model.passCode = "010";
String text = JSON.toJSONString(model);
assertEquals("{\"Dimension\":0,\"PassCode\":\"010\",\"BlockPos\":{\"x\":526,\"y\":65,\"z\":554}}", text);
}
public static class Model {
@JSONField(ordinal = 1, name="Dimension")
private int dimension;
Reported by PMD.
Line: 24
assertEquals("{\"Dimension\":0,\"PassCode\":\"010\",\"BlockPos\":{\"x\":526,\"y\":65,\"z\":554}}", text);
}
public static class Model {
@JSONField(ordinal = 1, name="Dimension")
private int dimension;
@JSONField(ordinal = 2, name="PassCode")
private String passCode;
@JSONField(ordinal = 3, name="BlockPos")
Reported by PMD.
Line: 58
}
public static class BlockPos {
public int x;
public int y;
public int z;
}
}
Reported by PMD.
Line: 59
public static class BlockPos {
public int x;
public int y;
public int z;
}
}
Reported by PMD.
Line: 60
public static class BlockPos {
public int x;
public int y;
public int z;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3300/Issue3397.java
6 issues
Line: 18
* @Date :Created in 16:32 2020/8/16
*/
public class Issue3397 extends TestCase {
@Override
public void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getDefault();
JSON.defaultLocale = Locale.CHINA;
}
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String text = "{\"date\":\"2020-08-16 16:35:18.188\"}";
VO vo = JSON.parseObject(text, VO.class);
JSONObject json = (JSONObject) JSONObject.toJSON(vo);
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String text = "{\"date\":\"2020-08-16 16:35:18.188\"}";
VO vo = JSON.parseObject(text, VO.class);
JSONObject json = (JSONObject) JSONObject.toJSON(vo);
Reported by PMD.
Line: 30
JSONObject json = (JSONObject) JSONObject.toJSON(vo);
Date date = json.getDate("date");
// assertEquals("Sun Aug 16 16:35:18 CST 2020", date.toString());
}
public static class VO {
@JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS")
Reported by PMD.
Line: 30
JSONObject json = (JSONObject) JSONObject.toJSON(vo);
Date date = json.getDate("date");
// assertEquals("Sun Aug 16 16:35:18 CST 2020", date.toString());
}
public static class VO {
@JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS")
Reported by PMD.
Line: 30
JSONObject json = (JSONObject) JSONObject.toJSON(vo);
Date date = json.getDate("date");
// assertEquals("Sun Aug 16 16:35:18 CST 2020", date.toString());
}
public static class VO {
@JSONField(format = "yyyy-MM-dd HH:mm:ss.SSS")
Reported by PMD.