The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumCustomCodecTest.java
8 issues
Line: 14
public class EnumCustomCodecTest extends TestCase {
public void test_for_enum() throws Exception {
Type type = Type.A;
String str =JSON.toJSONString(type);
assertEquals("{\"id\":1001,\"name\":\"aaa\"}", str);
Reported by PMD.
Line: 14
public class EnumCustomCodecTest extends TestCase {
public void test_for_enum() throws Exception {
Type type = Type.A;
String str =JSON.toJSONString(type);
assertEquals("{\"id\":1001,\"name\":\"aaa\"}", str);
Reported by PMD.
Line: 18
Type type = Type.A;
String str =JSON.toJSONString(type);
assertEquals("{\"id\":1001,\"name\":\"aaa\"}", str);
Type type2 = JSON.parseObject(str, Type.class);
Type type3 = JSON.parseObject(str, Type.class);
assertSame(type, type2);
Reported by PMD.
Line: 23
Type type2 = JSON.parseObject(str, Type.class);
Type type3 = JSON.parseObject(str, Type.class);
assertSame(type, type2);
assertSame(type, type3);
}
@JSONType(serializeEnumAsJavaBean = true, deserializer = TypeDeser.class)
Reported by PMD.
Line: 24
Type type3 = JSON.parseObject(str, Type.class);
assertSame(type, type2);
assertSame(type, type3);
}
@JSONType(serializeEnumAsJavaBean = true, deserializer = TypeDeser.class)
public static enum Type {
Reported by PMD.
Line: 42
}
public static Type valueOf(long id) {
if (id == 1001) {
return A;
} else if (id == 1002) {
return B;
}
return null;
Reported by PMD.
Line: 44
public static Type valueOf(long id) {
if (id == 1001) {
return A;
} else if (id == 1002) {
return B;
}
return null;
}
}
Reported by PMD.
Line: 55
public <T> T deserialze(DefaultJSONParser parser, java.lang.reflect.Type type, Object fieldName) {
JSONObject object = parser.parseObject();
long id = object.getLongValue("id");
return (T) Type.valueOf(id);
}
public int getFastMatchToken() {
return 0;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/PropertyProcessableTest_0.java
8 issues
Line: 13
* Created by wenshao on 15/07/2017.
*/
public class PropertyProcessableTest_0 extends TestCase {
public void test_processable() throws Exception {
VO vo = JSON.parseObject("{\"vo_id\":123,\"vo_name\":\"abc\",\"value\":{}}", VO.class);
assertEquals(123, vo.id);
assertEquals("abc", vo.name);
assertNotNull(vo.value);
}
Reported by PMD.
Line: 13
* Created by wenshao on 15/07/2017.
*/
public class PropertyProcessableTest_0 extends TestCase {
public void test_processable() throws Exception {
VO vo = JSON.parseObject("{\"vo_id\":123,\"vo_name\":\"abc\",\"value\":{}}", VO.class);
assertEquals(123, vo.id);
assertEquals("abc", vo.name);
assertNotNull(vo.value);
}
Reported by PMD.
Line: 15
public class PropertyProcessableTest_0 extends TestCase {
public void test_processable() throws Exception {
VO vo = JSON.parseObject("{\"vo_id\":123,\"vo_name\":\"abc\",\"value\":{}}", VO.class);
assertEquals(123, vo.id);
assertEquals("abc", vo.name);
assertNotNull(vo.value);
}
public static class VO implements PropertyProcessable {
Reported by PMD.
Line: 16
public void test_processable() throws Exception {
VO vo = JSON.parseObject("{\"vo_id\":123,\"vo_name\":\"abc\",\"value\":{}}", VO.class);
assertEquals(123, vo.id);
assertEquals("abc", vo.name);
assertNotNull(vo.value);
}
public static class VO implements PropertyProcessable {
public int id;
Reported by PMD.
Line: 17
VO vo = JSON.parseObject("{\"vo_id\":123,\"vo_name\":\"abc\",\"value\":{}}", VO.class);
assertEquals(123, vo.id);
assertEquals("abc", vo.name);
assertNotNull(vo.value);
}
public static class VO implements PropertyProcessable {
public int id;
public String name;
Reported by PMD.
Line: 21
}
public static class VO implements PropertyProcessable {
public int id;
public String name;
public Value value;
public Type getType(String name) {
if ("value".equals(name)) {
Reported by PMD.
Line: 22
public static class VO implements PropertyProcessable {
public int id;
public String name;
public Value value;
public Type getType(String name) {
if ("value".equals(name)) {
return Value.class;
Reported by PMD.
Line: 23
public static class VO implements PropertyProcessable {
public int id;
public String name;
public Value value;
public Type getType(String name) {
if ("value".equals(name)) {
return Value.class;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/TestSpecial_3.java
8 issues
Line: 15
public class TestSpecial_3 extends TestCase {
public void test_special() throws Exception {
String json = "[{\"@type\":\"NAME_CORRECTION\",\"value\":23}]";
JSONArray array = (JSONArray) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(array, "[\\@type='NAME_CORRECTION']");
assertNotNull(obj);
}
Reported by PMD.
Line: 19
String json = "[{\"@type\":\"NAME_CORRECTION\",\"value\":23}]";
JSONArray array = (JSONArray) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(array, "[\\@type='NAME_CORRECTION']");
assertNotNull(obj);
}
public void test_special_1() throws Exception {
String json = "[{\":lang\":\"NAME_CORRECTION\",\"value\":23}]";
JSONArray array = (JSONArray) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Reported by PMD.
Line: 22
assertNotNull(obj);
}
public void test_special_1() throws Exception {
String json = "[{\":lang\":\"NAME_CORRECTION\",\"value\":23}]";
JSONArray array = (JSONArray) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(array, "[\\:lang='NAME_CORRECTION']");
assertNotNull(obj);
}
Reported by PMD.
Line: 26
String json = "[{\":lang\":\"NAME_CORRECTION\",\"value\":23}]";
JSONArray array = (JSONArray) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(array, "[\\:lang='NAME_CORRECTION']");
assertNotNull(obj);
}
public void test_special_2() throws Exception {
String json = "{\"cpe-item\":{\"@name\":\"cpe:/a:google:chrome:4.0.249.19\",\"cpe-23:cpe23-item\":{\"@name\":\"cpe:2.3:a:google:chrome:4.0.249.19:*:*:*:*:*:*:*\"},\"title\":[{\"#text\":\"グーグル クローム 4.0.249.19\",\"@xml:lang\":\"ja-JP\"},{\"#text\":\"Google Chrome 4.0.249.19\",\"@xml:lang\":\"en-US\"}]}}";
String path = "['cpe-item']['title'][\\@xml\\:lang='en-US']['#text'][0]";
Reported by PMD.
Line: 29
assertNotNull(obj);
}
public void test_special_2() throws Exception {
String json = "{\"cpe-item\":{\"@name\":\"cpe:/a:google:chrome:4.0.249.19\",\"cpe-23:cpe23-item\":{\"@name\":\"cpe:2.3:a:google:chrome:4.0.249.19:*:*:*:*:*:*:*\"},\"title\":[{\"#text\":\"グーグル クローム 4.0.249.19\",\"@xml:lang\":\"ja-JP\"},{\"#text\":\"Google Chrome 4.0.249.19\",\"@xml:lang\":\"en-US\"}]}}";
String path = "['cpe-item']['title'][\\@xml\\:lang='en-US']['#text'][0]";
JSONObject object = (JSONObject) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(object, path);
assertNotNull(obj);
Reported by PMD.
Line: 34
String path = "['cpe-item']['title'][\\@xml\\:lang='en-US']['#text'][0]";
JSONObject object = (JSONObject) JSON.parse(json, Feature.DisableSpecialKeyDetect);
Object obj = JSONPath.eval(object, path);
assertNotNull(obj);
}
}
Reported by PMD.
Line: 10
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
public class TestSpecial_3 extends TestCase {
public void test_special() throws Exception {
Reported by PMD.
Line: 11
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
public class TestSpecial_3 extends TestCase {
public void test_special() throws Exception {
String json = "[{\"@type\":\"NAME_CORRECTION\",\"value\":23}]";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/date/DateTest_ISO8601_OneLetterISO8601TimeZone.java
8 issues
Line: 13
public class DateTest_ISO8601_OneLetterISO8601TimeZone extends TestCase {
public void f_test_date() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.2+08\"}";
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Reported by PMD.
Line: 16
public void f_test_date() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.2+08\"}";
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(8, date.getTimeZone().getRawOffset()/(3600*1000));
}
Reported by PMD.
Line: 19
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(8, date.getTimeZone().getRawOffset()/(3600*1000));
}
public void test_date_9() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.235+09\"}";
Reported by PMD.
Line: 19
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(8, date.getTimeZone().getRawOffset()/(3600*1000));
}
public void test_date_9() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.235+09\"}";
Reported by PMD.
Line: 22
Assert.assertEquals(8, date.getTimeZone().getRawOffset()/(3600*1000));
}
public void test_date_9() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.235+09\"}";
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Reported by PMD.
Line: 25
public void test_date_9() throws Exception {
String text = "{\"gmtCreate\":\"2014-08-21T09:51:36.235+09\"}";
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(9, date.getTimeZone().getRawOffset()/(3600*1000));
}
Reported by PMD.
Line: 28
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(9, date.getTimeZone().getRawOffset()/(3600*1000));
}
public static class VO {
private Calendar gmtCreate;
Reported by PMD.
Line: 28
Calendar date = JSON.parseObject(text, VO.class).getGmtCreate();
Assert.assertNotNull(date);
Assert.assertEquals(9, date.getTimeZone().getRawOffset()/(3600*1000));
}
public static class VO {
private Calendar gmtCreate;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Object_public.java
8 issues
Line: 13
public class WriteAsArray_Object_public 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: 25
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());
}
public static class VO {
Reported by PMD.
Line: 25
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());
}
public static class VO {
Reported by PMD.
Line: 25
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());
}
public static class VO {
Reported by PMD.
Line: 26
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());
}
public static class VO {
private A a;
Reported by PMD.
Line: 26
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());
}
public static class VO {
private A a;
Reported by PMD.
Line: 26
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());
}
public static class VO {
private A a;
Reported by PMD.
Line: 43
}
public static class A {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/jaxrs/FastJsonProviderTest.java
8 issues
Line: 22
public class FastJsonProviderTest extends TestCase {
@SuppressWarnings("deprecation")
public void test_1() throws Exception {
FastJsonProvider provider1 = new FastJsonProvider("UTF-8");
Assert.assertEquals("UTF-8", provider1.getCharset().name());
Reported by PMD.
Line: 25
@SuppressWarnings("deprecation")
public void test_1() throws Exception {
FastJsonProvider provider1 = new FastJsonProvider("UTF-8");
Assert.assertEquals("UTF-8", provider1.getCharset().name());
FastJsonProvider provider2 = new FastJsonProvider();
provider2.setCharset(Charset.forName("GBK"));
Reported by PMD.
Line: 26
public void test_1() throws Exception {
FastJsonProvider provider1 = new FastJsonProvider("UTF-8");
Assert.assertEquals("UTF-8", provider1.getCharset().name());
FastJsonProvider provider2 = new FastJsonProvider();
provider2.setCharset(Charset.forName("GBK"));
Assert.assertEquals("GBK", provider2.getCharset().name());
Reported by PMD.
Line: 31
FastJsonProvider provider2 = new FastJsonProvider();
provider2.setCharset(Charset.forName("GBK"));
Assert.assertEquals("GBK", provider2.getCharset().name());
Assert.assertNull(provider2.getDateFormat());
provider2.setDateFormat("yyyyMMdd");
provider2.setFeatures(SerializerFeature.IgnoreErrorGetter);
Reported by PMD.
Line: 37
provider2.setDateFormat("yyyyMMdd");
provider2.setFeatures(SerializerFeature.IgnoreErrorGetter);
Assert.assertEquals(1, provider2.getFeatures().length);
Assert.assertEquals(SerializerFeature.IgnoreErrorGetter,
provider2.getFeatures()[0]);
provider2.setFilters(serializeFilter);
Assert.assertEquals(1, provider2.getFilters().length);
Reported by PMD.
Line: 42
provider2.getFeatures()[0]);
provider2.setFilters(serializeFilter);
Assert.assertEquals(1, provider2.getFilters().length);
Assert.assertEquals(serializeFilter, provider2.getFilters()[0]);
FastJsonProvider provider = new FastJsonProvider(new Class[]{VO.class});
Assert.assertNotNull(provider.getFastJsonConfig());
Reported by PMD.
Line: 89
}
}
private SerializeFilter serializeFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (value == null) {
return "";
}
Reported by PMD.
Line: 89
}
}
private SerializeFilter serializeFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (value == null) {
return "";
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest14.java
8 issues
Line: 17
* Created by wenshao on 09/02/2017.
*/
public class TypeReferenceTest14 extends TestCase {
public void test_0() throws Exception {
String str = "{\"result\":{\"item\":[{\"key\":\"123\"}]}}";
ParserConfig config = new ParserConfig();
JSONObject.parseObject(str, OpenSearchResponse.class, config);
JSONObject.parseObject(str
Reported by PMD.
Line: 26
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
int size = config.getDeserializers().size();
for (int i = 0; i < 100 * 1; ++i) {
JSONObject.parseObject(str
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
assertEquals(size, config.getDeserializers().size());
Reported by PMD.
Line: 29
int size = config.getDeserializers().size();
for (int i = 0; i < 100 * 1; ++i) {
JSONObject.parseObject(str
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
assertEquals(size, config.getDeserializers().size());
}
}
Reported by PMD.
Line: 31
JSONObject.parseObject(str
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
assertEquals(size, config.getDeserializers().size());
}
}
public static class OpenSearchResponse<T> {
Reported by PMD.
Line: 31
JSONObject.parseObject(str
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
assertEquals(size, config.getDeserializers().size());
}
}
public static class OpenSearchResponse<T> {
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.parser.ParserConfig;
import java.util.List;
import junit.framework.TestCase;
import java.io.Serializable;
Reported by PMD.
Line: 11
import java.util.List;
import junit.framework.TestCase;
import java.io.Serializable;
/**
* Created by wenshao on 09/02/2017.
*/
public class TypeReferenceTest14 extends TestCase {
Reported by PMD.
Line: 26
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
int size = config.getDeserializers().size();
for (int i = 0; i < 100 * 1; ++i) {
JSONObject.parseObject(str
, new TypeReference<OpenSearchResponse<JSONObject>>() {}.getType()
, config, JSON.DEFAULT_PARSER_FEATURE);
assertEquals(size, config.getDeserializers().size());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest8.java
8 issues
Line: 12
public class DenyTest8 extends TestCase {
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Reported by PMD.
Line: 12
public class DenyTest8 extends TestCase {
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Reported by PMD.
Line: 15
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
Reported by PMD.
Line: 17
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
config.configFromPropety(properties);
Reported by PMD.
Line: 23
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest8");
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest8$Model\"}", Object.class, config);
Reported by PMD.
Line: 29
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest8$Model\"}", Object.class, config);
assertEquals(Model.class, obj.getClass());
}
public static class Model {
}
Reported by PMD.
Line: 29
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest8$Model\"}", Object.class, config);
assertEquals(Model.class, obj.getClass());
}
public static class Model {
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.parser.deser.deny;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.ParserConfig;
import junit.framework.TestCase;
import java.util.Properties;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderScannerTest_enum.java
8 issues
Line: 12
public class JSONReaderScannerTest_enum extends TestCase {
public void test_a() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"A\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.A, vo.getType());
parser.close();
}
Reported by PMD.
Line: 15
public void test_a() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"A\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.A, vo.getType());
parser.close();
}
public void test_b() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"B\"}"));
Reported by PMD.
Line: 19
parser.close();
}
public void test_b() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"B\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.B, vo.getType());
parser.close();
}
Reported by PMD.
Line: 22
public void test_b() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"B\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.B, vo.getType());
parser.close();
}
public void test_c() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"C\"}"));
Reported by PMD.
Line: 26
parser.close();
}
public void test_c() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"C\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.C, vo.getType());
parser.close();
}
Reported by PMD.
Line: 29
public void test_c() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"C\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.C, vo.getType());
parser.close();
}
public void test_x() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"XXXXXXXXXXXXXXXXXXXXXXXX\"}"));
Reported by PMD.
Line: 33
parser.close();
}
public void test_x() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"XXXXXXXXXXXXXXXXXXXXXXXX\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.XXXXXXXXXXXXXXXXXXXXXXXX, vo.getType());
parser.close();
}
Reported by PMD.
Line: 36
public void test_x() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"type\":\"XXXXXXXXXXXXXXXXXXXXXXXX\"}"));
VO vo = parser.parseObject(VO.class);
Assert.assertEquals(Type.XXXXXXXXXXXXXXXXXXXXXXXX, vo.getType());
parser.close();
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/DeepScanTest.java
8 issues
Line: 13
* Created by wenshao on 30/07/2017.
*/
public class DeepScanTest extends TestCase {
public void test_when_deep_scanning_illegal_property_access_is_ignored() {
Object result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo");
assertEquals(2, ((List) result).size());
Reported by PMD.
Line: 13
* Created by wenshao on 30/07/2017.
*/
public class DeepScanTest extends TestCase {
public void test_when_deep_scanning_illegal_property_access_is_ignored() {
Object result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo");
assertEquals(2, ((List) result).size());
Reported by PMD.
Line: 17
Object result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo");
assertEquals(2, ((List) result).size());
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo.bar");
assertEquals(1, ((List) result).size());
Reported by PMD.
Line: 22
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo.bar");
assertEquals(1, ((List) result).size());
assertEquals(4, ((List) result).get(0));
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
Reported by PMD.
Line: 23
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..foo.bar");
assertEquals(1, ((List) result).size());
assertEquals(4, ((List) result).get(0));
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
assertEquals(1, ((List) result).size());
Reported by PMD.
Line: 28
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
assertEquals(1, ((List) result).size());
assertEquals(4, ((List) result).get(0));
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"baz\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
Reported by PMD.
Line: 29
JSON.parseObject("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
assertEquals(1, ((List) result).size());
assertEquals(4, ((List) result).get(0));
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"baz\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
assertTrue(((List) result).isEmpty());
Reported by PMD.
Line: 34
result = JSONPath.eval(
JSON.parseObject("{\"x\": {\"foo\": {\"baz\": 4}}, \"y\": {\"foo\": 1}}")
, "$..[*].foo.bar");
assertTrue(((List) result).isEmpty());
}
}
Reported by PMD.