The following issues were found
src/test/java/com/alibaba/json/bvt/basicType/LongNullTest_primitive.java
17 issues
Line: 10
* Created by wenshao on 10/08/2017.
*/
public class LongNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 10
* Created by wenshao on 10/08/2017.
*/
public class LongNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 12
public class LongNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Reported by PMD.
Line: 13
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
Reported by PMD.
Line: 14
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
Reported by PMD.
Line: 17
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 17
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 19
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Reported by PMD.
Line: 20
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\" }", Model.class);
Reported by PMD.
Line: 21
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\" }", Model.class);
assertNotNull(model);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TypeUtils_parseDouble_Test.java
17 issues
Line: 9
import java.util.Random;
public class TypeUtils_parseDouble_Test extends TestCase {
public void test_0() throws Exception {
Random r = new Random();
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Float.toString(r.nextFloat());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
Reported by PMD.
Line: 14
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Float.toString(r.nextFloat());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
}
}
public void test_0_d() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 18
}
}
public void test_0_d() throws Exception {
Random r = new Random();
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Double.toString(r.nextDouble());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
Reported by PMD.
Line: 23
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Double.toString(r.nextDouble());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
}
}
public void test_1() throws Exception {
Reported by PMD.
Line: 28
}
public void test_1() throws Exception {
Random r = new Random();
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
Reported by PMD.
Line: 33
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
}
}
public void test_2() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 37
}
}
public void test_2() throws Exception {
Random r = new Random();
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt(1000000000));
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
Reported by PMD.
Line: 42
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt(1000000000));
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
}
}
public void test_3() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 46
}
}
public void test_3() throws Exception {
Random r = new Random();
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Long.toString(r.nextLong());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
Reported by PMD.
Line: 51
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Long.toString(r.nextLong());
assertEquals(Double.parseDouble(str), TypeUtils.parseDouble(str));
}
}
public void test_4() throws Exception {
String[] array = new String[] {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/IntNullTest_primitive.java
17 issues
Line: 10
* Created by wenshao on 10/08/2017.
*/
public class IntNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 10
* Created by wenshao on 10/08/2017.
*/
public class IntNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 12
public class IntNullTest_primitive extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Reported by PMD.
Line: 13
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
Reported by PMD.
Line: 14
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertEquals(0, model.v1);
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
Reported by PMD.
Line: 17
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 17
assertEquals(0,model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
Reported by PMD.
Line: 19
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Reported by PMD.
Line: 20
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\" }", Model.class);
Reported by PMD.
Line: 21
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
assertEquals(0,model.v1);
assertEquals(0,model.v2);
}
public void test_null_2() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\" }", Model.class);
assertNotNull(model);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/IntegerFieldDeserializerTest3.java
17 issues
Line: 13
public class IntegerFieldDeserializerTest3 extends TestCase {
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:123, f2:null}", Entity.class);
Assert.assertEquals(123, a.getF1());
Assert.assertEquals(null, a.getF2());
}
Reported by PMD.
Line: 15
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:123, f2:null}", Entity.class);
Assert.assertEquals(123, a.getF1());
Assert.assertEquals(null, a.getF2());
}
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Reported by PMD.
Line: 16
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:123, f2:null}", Entity.class);
Assert.assertEquals(123, a.getF1());
Assert.assertEquals(null, a.getF2());
}
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Assert.assertEquals(22, a.getF1());
Reported by PMD.
Line: 19
Assert.assertEquals(null, a.getF2());
}
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
Reported by PMD.
Line: 21
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Reported by PMD.
Line: 22
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Assert.assertEquals(22, a.getF1());
Reported by PMD.
Line: 22
public void test_1() throws Exception {
Entity a = JSON.parseObject("{f1:22, f2:'33'}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Assert.assertEquals(22, a.getF1());
Reported by PMD.
Line: 25
Assert.assertEquals(33, a.getF2().intValue());
}
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
Reported by PMD.
Line: 27
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
public static class Entity {
Reported by PMD.
Line: 28
public void test_2() throws Exception {
Entity a = JSON.parseObject("{f1:'22', f2:33}", Entity.class);
Assert.assertEquals(22, a.getF1());
Assert.assertEquals(33, a.getF2().intValue());
}
public static class Entity {
private int f1 = 124;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultExtJSONParserTest_3.java
17 issues
Line: 15
public class DefaultExtJSONParserTest_3 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
Reported by PMD.
Line: 19
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 22
Assert.assertEquals(3, a.getV1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
Reported by PMD.
Line: 27
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 30
Assert.assertEquals(3, a.getV1());
}
public void test_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
Reported by PMD.
Line: 35
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 38
Assert.assertEquals(3, a.getV1());
}
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(true, a.getO1() != null);
Reported by PMD.
Line: 43
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(true, a.getO1() != null);
}
public void test_4() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 46
Assert.assertEquals(true, a.getO1() != null);
}
public void test_4() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3L, a.getV5().longValue());
Reported by PMD.
Line: 51
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3L, a.getV5().longValue());
}
public void test_5() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/JacksonCodec.java
17 issues
Line: 22
try {
return mapper.readValue(text, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
Reported by PMD.
Line: 31
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
try {
Reported by PMD.
Line: 40
return (Collection<T>) mapper.readValue(text, new TypeReference<T>() {
});
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public final Object decodeObject(String text) {
try {
Reported by PMD.
Line: 48
try {
return (ObjectNode) mapper.readTree(text);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public Object decode(String text) {
try {
Reported by PMD.
Line: 56
try {
return mapper.readTree(text);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public String encode(Object object) throws Exception {
return mapper.writeValueAsString(object);
Reported by PMD.
Line: 12
public class JacksonCodec implements Codec {
private ObjectMapper mapper = new ObjectMapper();
public String getName() {
return "jackson ";
}
Reported by PMD.
Line: 12
public class JacksonCodec implements Codec {
private ObjectMapper mapper = new ObjectMapper();
public String getName() {
return "jackson ";
}
Reported by PMD.
Line: 21
public final <T> T decodeObject(String text, Class<T> clazz) {
try {
return mapper.readValue(text, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
Reported by PMD.
Line: 27
}
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
Reported by PMD.
Line: 30
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/AtomicCodec.java
16 issues
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class AtomicCodec implements ObjectSerializer, ObjectDeserializer {
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 34
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class AtomicCodec implements ObjectSerializer, ObjectDeserializer {
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 38
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof AtomicInteger) {
AtomicInteger val = (AtomicInteger) object;
out.writeInt(val.get());
Reported by PMD.
Line: 38
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof AtomicInteger) {
AtomicInteger val = (AtomicInteger) object;
out.writeInt(val.get());
Reported by PMD.
Line: 38
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof AtomicInteger) {
AtomicInteger val = (AtomicInteger) object;
out.writeInt(val.get());
Reported by PMD.
Line: 38
public final static AtomicCodec instance = new AtomicCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object instanceof AtomicInteger) {
AtomicInteger val = (AtomicInteger) object;
out.writeInt(val.get());
Reported by PMD.
Line: 43
if (object instanceof AtomicInteger) {
AtomicInteger val = (AtomicInteger) object;
out.writeInt(val.get());
return;
}
if (object instanceof AtomicLong) {
AtomicLong val = (AtomicLong) object;
Reported by PMD.
Line: 49
if (object instanceof AtomicLong) {
AtomicLong val = (AtomicLong) object;
out.writeLong(val.get());
return;
}
if (object instanceof AtomicBoolean) {
AtomicBoolean val = (AtomicBoolean) object;
Reported by PMD.
Line: 55
if (object instanceof AtomicBoolean) {
AtomicBoolean val = (AtomicBoolean) object;
out.append(val.get() ? "true" : "false");
return;
}
if (object == null) {
out.writeNull(SerializerFeature.WriteNullListAsEmpty);
Reported by PMD.
Line: 66
if (object instanceof AtomicIntegerArray) {
AtomicIntegerArray array = (AtomicIntegerArray) object;
int len = array.length();
out.write('[');
for (int i = 0; i < len; ++i) {
int val = array.get(i);
if (i != 0) {
out.write(',');
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/DLATest_0.java
16 issues
Line: 13
import java.io.InputStreamReader;
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
Reported by PMD.
Line: 13
import java.io.InputStreamReader;
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
Reported by PMD.
Line: 14
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Reported by PMD.
Line: 14
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Reported by PMD.
Line: 14
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Reported by PMD.
Line: 15
public class DLATest_0 extends TestCase {
public void test_dla() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Reported by PMD.
Line: 19
String json = IOUtils.readAll(reader);
Object object = JSON.parse(json, Feature.IgnoreAutoType, Feature.OrderedField);
Object result = JSONPath.eval(object, "$..elapsedTime");
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Object result2 = JSONPath.eval(object, "$..self");
assertEquals("[\"http://172.17.246.55:10001/v1/query/20181024_040507_3_f32vb\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.0\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.0.0?shufferNettyServerPort=39524&commandNettyServerPort=37207\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.1\",\"http://172.17.246.55:14005/v1/task/20181024_040507_3_f32vb.1.0?shufferNettyServerPort=33921&commandNettyServerPort=45121\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.1.1?shufferNettyServerPort=39524&commandNettyServerPort=37207\"]", JSON.toJSONString(result2));
}
Reported by PMD.
Line: 22
assertEquals("[\"1.48s\",1031,1031,1005,1005,1011,1011]", JSON.toJSONString(result));
Object result2 = JSONPath.eval(object, "$..self");
assertEquals("[\"http://172.17.246.55:10001/v1/query/20181024_040507_3_f32vb\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.0\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.0.0?shufferNettyServerPort=39524&commandNettyServerPort=37207\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.1\",\"http://172.17.246.55:14005/v1/task/20181024_040507_3_f32vb.1.0?shufferNettyServerPort=33921&commandNettyServerPort=45121\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.1.1?shufferNettyServerPort=39524&commandNettyServerPort=37207\"]", JSON.toJSONString(result2));
}
public void test_dla_extract() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
Reported by PMD.
Line: 25
assertEquals("[\"http://172.17.246.55:10001/v1/query/20181024_040507_3_f32vb\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.0\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.0.0?shufferNettyServerPort=39524&commandNettyServerPort=37207\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.1\",\"http://172.17.246.55:14005/v1/task/20181024_040507_3_f32vb.1.0?shufferNettyServerPort=33921&commandNettyServerPort=45121\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.1.1?shufferNettyServerPort=39524&commandNettyServerPort=37207\"]", JSON.toJSONString(result2));
}
public void test_dla_extract() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object result = JSONPath.extract(json, "$..elapsedTime");
Reported by PMD.
Line: 25
assertEquals("[\"http://172.17.246.55:10001/v1/query/20181024_040507_3_f32vb\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.0\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.0.0?shufferNettyServerPort=39524&commandNettyServerPort=37207\",\"http://172.17.246.55:10001/v1/stage/20181024_040507_3_f32vb.1\",\"http://172.17.246.55:14005/v1/task/20181024_040507_3_f32vb.1.0?shufferNettyServerPort=33921&commandNettyServerPort=45121\",\"http://172.17.246.56:14005/v1/task/20181024_040507_3_f32vb.1.1?shufferNettyServerPort=39524&commandNettyServerPort=37207\"]", JSON.toJSONString(result2));
}
public void test_dla_extract() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/dla_01.json");
InputStreamReader reader = new InputStreamReader(is);
String json = IOUtils.readAll(reader);
Object result = JSONPath.extract(json, "$..elapsedTime");
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue869_1.java
16 issues
Line: 14
* Created by wenshao on 2016/11/13.
*/
public class Issue869_1 extends TestCase {
public void test_for_issue() throws Exception {
List<DoublePoint> doublePointList = new ArrayList<DoublePoint>();
{
DoublePoint doublePoint = new DoublePoint();
doublePoint.startPoint = new Point(22, 35);
doublePoint.endPoint = doublePoint.startPoint;
Reported by PMD.
Line: 30
}
String json = JSON.toJSONString(doublePointList);
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"$ref\":\"$[1].endPoint\"}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
Reported by PMD.
Line: 33
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"$ref\":\"$[1].endPoint\"}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 33
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"$ref\":\"$[1].endPoint\"}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 37
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
Reported by PMD.
Line: 38
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
Reported by PMD.
Line: 39
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 39
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 39
List<Issue869.DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<Issue869.DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 40
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
public Point endPoint;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/stream/ReaderLongFieldTest.java
16 issues
Line: 16
public class ReaderLongFieldTest extends TestCase {
public void test_long_error_0() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":1.A}"));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 27
Assert.assertNotNull(error);
}
public void test_long_error_1() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":9223372036854775808}"));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 38
Assert.assertNotNull(error);
}
public void test_long_error_1_x() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":922337203685477580892233720368547758088}"));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 49
Assert.assertNotNull(error);
}
public void test_long_error_2() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":AA}"));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 60
Assert.assertNotNull(error);
}
public void test_long_normal() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"value\":1001,\"value2\":-2001}"));
Model model = reader.readObject(Model.class);
Assert.assertEquals(1001L, model.value);
Assert.assertEquals(-2001L, model.value2);
reader.close();
Reported by PMD.
Line: 68
reader.close();
}
public void test_long_normal_2() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"model\":{\"value\":3001,\"value2\":-4001}}"));
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Model model = map.get("model");
Assert.assertEquals(3001L, model.value);
Reported by PMD.
Line: 78
reader.close();
}
public void test_long_error_map() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"model\":{\"value\":3001,\"value2\":-4001}["));
reader.readObject(new TypeReference<Map<String, Model>>() {
});
Reported by PMD.
Line: 90
Assert.assertNotNull(error);
}
public void test_long_error_end() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":1001,\"value2\":-2001["));
reader.readObject(Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 103
private static class Model {
public long value;
public long value2;
}
}
Reported by PMD.
Line: 104
private static class Model {
public long value;
public long value2;
}
}
Reported by PMD.