The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumFieldsTest8.java
6 issues
Line: 15
public class EnumFieldsTest8 extends TestCase {
public void test_enum() throws Exception {
Model model = new Model();
model.t1 = Type.A;
model.t2 = null;
ValueFilter valueFilter = new ValueFilter() {
Reported by PMD.
Line: 18
public void test_enum() throws Exception {
Model model = new Model();
model.t1 = Type.A;
model.t2 = null;
ValueFilter valueFilter = new ValueFilter() {
public Object process(Object object, String name, Object value) {
return value;
Reported by PMD.
Line: 41
public static class Model {
public Type t1;
public Type t2;
}
public static enum Type {
A, B, C
Reported by PMD.
Line: 42
public static class Model {
public Type t1;
public Type t2;
}
public static enum Type {
A, B, C
}
Reported by PMD.
Line: 20
model.t1 = Type.A;
model.t2 = null;
ValueFilter valueFilter = new ValueFilter() {
public Object process(Object object, String name, Object value) {
return value;
}
Reported by PMD.
Line: 20
model.t1 = Type.A;
model.t2 = null;
ValueFilter valueFilter = new ValueFilter() {
public Object process(Object object, String name, Object value) {
return value;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/stream/StreamWriterTest_writeString.java
6 issues
Line: 12
public class StreamWriterTest_writeString extends TestCase {
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars), 0, chars.length);
}
Reported by PMD.
Line: 24
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars), 0, chars.length);
}
writer.close();
String text = out.toString();
Assert.assertEquals(26 * blockSize, text.length());
Reported by PMD.
Line: 29
writer.close();
String text = out.toString();
Assert.assertEquals(26 * blockSize, text.length());
for (int i = 0; i < 26; ++i) {
for (int j = 0; j < blockSize; ++j) {
Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
}
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars), 0, chars.length);
}
Reported by PMD.
Line: 22
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars), 0, chars.length);
}
writer.close();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/stream/StreamWriterTest_writeString1.java
6 issues
Line: 12
public class StreamWriterTest_writeString1 extends TestCase {
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars));
}
Reported by PMD.
Line: 24
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars));
}
writer.close();
String text = out.toString();
Assert.assertEquals(26 * blockSize, text.length());
Reported by PMD.
Line: 29
writer.close();
String text = out.toString();
Assert.assertEquals(26 * blockSize, text.length());
for (int i = 0; i < 26; ++i) {
for (int j = 0; j < blockSize; ++j) {
Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
}
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars));
}
Reported by PMD.
Line: 22
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(new String(chars));
}
writer.close();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/str/StringTest_01.java
6 issues
Line: 14
public class StringTest_01 extends TestCase {
public void test_string() throws Exception {
char[] chars = new char[1024];
Arrays.fill(chars, '0');
StringBuilder buf = new StringBuilder();
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 20
StringBuilder buf = new StringBuilder();
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
buf.append("\\\\");
buf.append("\\\"");
buf.append(new String(chars));
}
buf.append("\"]");
Reported by PMD.
Line: 22
for (int i = 0; i < 16; ++i) {
buf.append("\\\\");
buf.append("\\\"");
buf.append(new String(chars));
}
buf.append("\"]");
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Reported by PMD.
Line: 28
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 32, item.length());
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 30
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 32, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1026) == '\\');
Assert.assertTrue(item.charAt(i * 1026 + 1) == '\"');
Reported by PMD.
Line: 31
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 32, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1026) == '\\');
Assert.assertTrue(item.charAt(i * 1026 + 1) == '\"');
for (int j = 0; j < 1024; ++j) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_like.java
6 issues
Line: 9
public class JSONPath_like extends TestCase {
public void test_like_not_match() throws Exception {
assertNull(
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE 'order_base%']"));
}
public void test_like_not_match_1() throws Exception {
Reported by PMD.
Line: 10
public class JSONPath_like extends TestCase {
public void test_like_not_match() throws Exception {
assertNull(
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE 'order_base%']"));
}
public void test_like_not_match_1() throws Exception {
assertEquals("{\"table\":\"_order_base\"}",
Reported by PMD.
Line: 14
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE 'order_base%']"));
}
public void test_like_not_match_1() throws Exception {
assertEquals("{\"table\":\"_order_base\"}",
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE '_order_base%']").toString());
}
}
Reported by PMD.
Line: 15
}
public void test_like_not_match_1() throws Exception {
assertEquals("{\"table\":\"_order_base\"}",
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE '_order_base%']").toString());
}
}
Reported by PMD.
Line: 16
public void test_like_not_match_1() throws Exception {
assertEquals("{\"table\":\"_order_base\"}",
JSONPath.read("{\"table\":\"_order_base\"}", "[table LIKE '_order_base%']").toString());
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
import org.junit.Assert;
public class JSONPath_like extends TestCase {
public void test_like_not_match() throws Exception {
assertNull(
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest5.java
6 issues
Line: 18
Exception error = null;
try {
obj = JSON.parseObject("{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
Reported by PMD.
Line: 10
public class DenyTest5 extends TestCase {
public void test_c3p0() throws Exception {
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
Object obj = null;
Exception error = null;
Reported by PMD.
Line: 14
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
Object obj = null;
Exception error = null;
try {
obj = JSON.parseObject("{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
Reported by PMD.
Line: 22
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
}
Reported by PMD.
Line: 14
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
Object obj = null;
Exception error = null;
try {
obj = JSON.parseObject("{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
Reported by PMD.
Line: 15
config.setAutoTypeSupport(true);
Object obj = null;
Exception error = null;
try {
obj = JSON.parseObject("{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/util/GenericFieldInfoTest.java
6 issues
Line: 11
* Created by wenshao on 30/05/2017.
*/
public class GenericFieldInfoTest extends TestCase {
public void test_generic() throws Exception {
A a = JSON.parseObject("{\"data\":3}", A4.class);
assertTrue(a.data instanceof Long);
}
public void test_generic_1() throws Exception {
Reported by PMD.
Line: 13
public class GenericFieldInfoTest extends TestCase {
public void test_generic() throws Exception {
A a = JSON.parseObject("{\"data\":3}", A4.class);
assertTrue(a.data instanceof Long);
}
public void test_generic_1() throws Exception {
A a = JSON.parseObject("{\"data\":3}", new TypeReference<A3<Long>>(){});
assertEquals(a.data.getClass(), Long.class);
Reported by PMD.
Line: 16
assertTrue(a.data instanceof Long);
}
public void test_generic_1() throws Exception {
A a = JSON.parseObject("{\"data\":3}", new TypeReference<A3<Long>>(){});
assertEquals(a.data.getClass(), Long.class);
}
public static class A <T> {
Reported by PMD.
Line: 18
public void test_generic_1() throws Exception {
A a = JSON.parseObject("{\"data\":3}", new TypeReference<A3<Long>>(){});
assertEquals(a.data.getClass(), Long.class);
}
public static class A <T> {
public T data;
}
Reported by PMD.
Line: 18
public void test_generic_1() throws Exception {
A a = JSON.parseObject("{\"data\":3}", new TypeReference<A3<Long>>(){});
assertEquals(a.data.getClass(), Long.class);
}
public static class A <T> {
public T data;
}
Reported by PMD.
Line: 22
}
public static class A <T> {
public T data;
}
public static class A1 <T> extends A<T> {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DoubleArrayFieldDeserializerTest.java
6 issues
Line: 11
public class DoubleArrayFieldDeserializerTest extends TestCase {
public void test_0() throws Exception {
Entity a = JSON.parseObject("{\"values\":[1,2]}", Entity.class);
Assert.assertTrue(1 == a.getValues()[0]);
Assert.assertTrue(2 == a.getValues()[1]);
}
Reported by PMD.
Line: 13
public void test_0() throws Exception {
Entity a = JSON.parseObject("{\"values\":[1,2]}", Entity.class);
Assert.assertTrue(1 == a.getValues()[0]);
Assert.assertTrue(2 == a.getValues()[1]);
}
public static class Entity {
Reported by PMD.
Line: 14
public void test_0() throws Exception {
Entity a = JSON.parseObject("{\"values\":[1,2]}", Entity.class);
Assert.assertTrue(1 == a.getValues()[0]);
Assert.assertTrue(2 == a.getValues()[1]);
}
public static class Entity {
Reported by PMD.
Line: 23
public double[] values;
public double[] getValues() {
return values;
}
public void setValues(double[] values) {
this.values = values;
}
Reported by PMD.
Line: 26
return values;
}
public void setValues(double[] values) {
this.values = values;
}
}
}
Reported by PMD.
Line: 26
return values;
}
public void setValues(double[] values) {
this.values = values;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/list/ListStringFieldTest.java
6 issues
Line: 14
public class ListStringFieldTest extends TestCase {
public void test_list() throws Exception {
String text = "[[\"a\",null,\"b\"]]";
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(3, model.values.size());
Assert.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Reported by PMD.
Line: 17
public void test_list() throws Exception {
String text = "[[\"a\",null,\"b\"]]";
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(3, model.values.size());
Assert.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Assert.assertEquals("b", model.values.get(2));
}
Reported by PMD.
Line: 18
String text = "[[\"a\",null,\"b\"]]";
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(3, model.values.size());
Assert.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Assert.assertEquals("b", model.values.get(2));
}
public void test_null() throws Exception {
Reported by PMD.
Line: 19
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(3, model.values.size());
Assert.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Assert.assertEquals("b", model.values.get(2));
}
public void test_null() throws Exception {
String text = "[null]";
Reported by PMD.
Line: 20
Assert.assertEquals(3, model.values.size());
Assert.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Assert.assertEquals("b", model.values.get(2));
}
public void test_null() throws Exception {
String text = "[null]";
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Reported by PMD.
Line: 23
Assert.assertEquals("b", model.values.get(2));
}
public void test_null() throws Exception {
String text = "[null]";
Model model = JSON.parseObject(text, Model.class, Feature.SupportArrayToBean);
Assert.assertNull(model.values);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/extract/JSONPath_extract_4_multi.java
6 issues
Line: 8
public class JSONPath_extract_4_multi extends TestCase {
public void test_0() throws Exception {
assertEquals("[\"male\",\"john\"]"
, JSONPath.extract(json, "$[0]['gender','name']")
.toString());
}
public void test_1() throws Exception {
Reported by PMD.
Line: 9
public class JSONPath_extract_4_multi extends TestCase {
public void test_0() throws Exception {
assertEquals("[\"male\",\"john\"]"
, JSONPath.extract(json, "$[0]['gender','name']")
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"john\",\"male\"]"
Reported by PMD.
Line: 10
public void test_0() throws Exception {
assertEquals("[\"male\",\"john\"]"
, JSONPath.extract(json, "$[0]['gender','name']")
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"john\",\"male\"]"
, JSONPath.extract(json, "$[0]['name','gender']")
Reported by PMD.
Line: 13
, JSONPath.extract(json, "$[0]['gender','name']")
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"john\",\"male\"]"
, JSONPath.extract(json, "$[0]['name','gender']")
.toString());
}
Reported by PMD.
Line: 14
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"john\",\"male\"]"
, JSONPath.extract(json, "$[0]['name','gender']")
.toString());
}
private static final String json = "[\n" +
Reported by PMD.
Line: 15
}
public void test_1() throws Exception {
assertEquals("[\"john\",\"male\"]"
, JSONPath.extract(json, "$[0]['name','gender']")
.toString());
}
private static final String json = "[\n" +
" {\n" +
Reported by PMD.