The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Issue1005.java
29 issues
Line: 12
* Created by wenshao on 18/01/2017.
*/
public class Issue1005 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":[[1,2,3]]}", Model.class);
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
Reported by PMD.
Line: 12
* Created by wenshao on 18/01/2017.
*/
public class Issue1005 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":[[1,2,3]]}", Model.class);
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":[[1,2,3]]}", Model.class);
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
Reported by PMD.
Line: 16
Model model = JSON.parseObject("{\"values\":[[1,2,3]]}", Model.class);
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
Reported by PMD.
Line: 17
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Reported by PMD.
Line: 17
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Reported by PMD.
Line: 17
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Reported by PMD.
Line: 18
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Model2 model = JSON.parseObject("{\"values\":[1,2,3]}", Model2.class);
Reported by PMD.
Line: 18
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Model2 model = JSON.parseObject("{\"values\":[1,2,3]}", Model2.class);
Reported by PMD.
Line: 18
assertNotNull(model.values);
assertEquals(3, model.values[0].size());
assertEquals(Byte.class, model.values[0].get(0).getClass());
assertEquals(Byte.class, model.values[0].get(1).getClass());
assertEquals(Byte.class, model.values[0].get(2).getClass());
}
public void test_for_List() throws Exception {
Model2 model = JSON.parseObject("{\"values\":[1,2,3]}", Model2.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_like.java
29 issues
Line: 14
public class JSONPath_field_access_filter_like extends TestCase {
public void test_list_like_extract() throws Exception {
JSONPath path = new JSONPath("$[?(@.name like 'ljw2083')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 18
JSONPath path = new JSONPath("$[?(@.name like 'ljw2083')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Reported by PMD.
Line: 19
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Reported by PMD.
Line: 24
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[?(@.name not like 'ljw2083')]");
Reported by PMD.
Line: 25
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[?(@.name not like 'ljw2083')]");
Reported by PMD.
Line: 28
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[?(@.name not like 'ljw2083')]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 34
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Reported by PMD.
Line: 38
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
Reported by PMD.
Line: 39
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
public void test_list_like_left_match() throws Exception {
Reported by PMD.
Line: 40
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
public void test_list_like_left_match() throws Exception {
JSONPath path = new JSONPath("$[?(@.name like 'ljw%')]");
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2100/Issue2185.java
29 issues
Line: 13
public class Issue2185 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSONObject origin = new JSONObject();
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
Reported by PMD.
Line: 13
public class Issue2185 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSONObject origin = new JSONObject();
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
Reported by PMD.
Line: 18
try {
JSONObject origin = new JSONObject();
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 18
try {
JSONObject origin = new JSONObject();
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 20
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
Reported by PMD.
Line: 20
JSONArray jsonArray = new JSONArray().fluentAdd(origin.getInnerMap());
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
Reported by PMD.
Line: 21
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
}
Reported by PMD.
Line: 21
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
}
Reported by PMD.
Line: 21
jsonArray.getJSONObject(0).put("key", "value");
// now we expect jsonArray is [{"key":"value"}]
assertEquals(1, jsonArray.getJSONObject(0).size());
assertTrue(origin.getInnerMap() == jsonArray.getJSONObject(0).getInnerMap());
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
}
Reported by PMD.
Line: 25
} catch (JSONException ex) {
error = ex;
}
assertNull(error);
}
/**
* To prove casting from Map<Object,Object> won't cause exception
*
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_castToBigDecimal.java
29 issues
Line: 15
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
public void test_FloatNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0f / 0.0f));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0f / 0.0f));
// NaN
Reported by PMD.
Line: 15
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
public void test_FloatNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0f / 0.0f));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0f / 0.0f));
// NaN
Reported by PMD.
Line: 17
*/
public void test_FloatNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0f / 0.0f));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0f / 0.0f));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0f / 0.0f));
}
Reported by PMD.
Line: 19
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0f / 0.0f));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0f / 0.0f));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0f / 0.0f));
}
/**
Reported by PMD.
Line: 21
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0f / 0.0f));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0f / 0.0f));
}
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
Reported by PMD.
Line: 27
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
public void test_DoubleNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0d / 0.0d));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0d / 0.0d));
// NaN
Reported by PMD.
Line: 27
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
public void test_DoubleNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0d / 0.0d));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0d / 0.0d));
// NaN
Reported by PMD.
Line: 29
*/
public void test_DoubleNanInfinite() throws Exception {
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0d / 0.0d));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0d / 0.0d));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0d / 0.0d));
}
Reported by PMD.
Line: 31
// 正无穷大
assertNull(TypeUtils.castToBigDecimal(1.0d / 0.0d));
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0d / 0.0d));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0d / 0.0d));
}
/**
Reported by PMD.
Line: 33
// 负无穷大
assertNull(TypeUtils.castToBigDecimal(-1.0d / 0.0d));
// NaN
assertNull(TypeUtils.castToBigDecimal(0.0d / 0.0d));
}
/**
* NaN和正负无穷大的时候转BigDecimal都会报转换异常,修改为返回null
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/StringSerializerTest.java
28 issues
Line: 13
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class StringSerializerTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(
new TestEntity(null), SerializerFeature.WriteMapNullValue));
Reported by PMD.
Line: 15
public class StringSerializerTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(
new TestEntity(null), SerializerFeature.WriteMapNullValue));
SerializeWriter out = new SerializeWriter();
Reported by PMD.
Line: 28
Assert.assertEquals("\"123\"\"456\"", out.toString());
}
public void test_2() throws Exception {
StringWriter out = new StringWriter();
JSONSerializer.write(out, new TestEntity(null));
Assert.assertEquals("{}", out.toString());
}
Reported by PMD.
Line: 35
Assert.assertEquals("{}", out.toString());
}
public void test_2_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer.write(out, new TestEntity(null));
Assert.assertEquals("{}", out.toString());
}
Reported by PMD.
Line: 42
Assert.assertEquals("{}", out.toString());
}
public void test_3() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.config(SerializerFeature.UseSingleQuotes, true);
serializer.write(new TestEntity("张三"));
Reported by PMD.
Line: 51
Assert.assertEquals("{'value':'张三'}", out.toString());
}
public void test_4() throws Exception {
StringWriter out = new StringWriter();
JSONSerializer.write(out, new TestEntity("张三"));
Assert.assertEquals("{\"value\":\"张三\"}", out.toString());
}
Reported by PMD.
Line: 58
Assert.assertEquals("{\"value\":\"张三\"}", out.toString());
}
public void test_5() throws Exception {
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeString((String) null);
Assert.assertEquals("null", out.toString());
Reported by PMD.
Line: 63
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeString((String) null);
Assert.assertEquals("null", out.toString());
}
public void test_5_d() throws Exception {
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.UseSingleQuotes, true);
Reported by PMD.
Line: 66
Assert.assertEquals("null", out.toString());
}
public void test_5_d() throws Exception {
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeString((String) null);
Assert.assertEquals("null", out.toString());
Reported by PMD.
Line: 74
Assert.assertEquals("null", out.toString());
}
public void test_6() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeString((String) null);
Assert.assertEquals("null", out.toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_rlike.java
28 issues
Line: 14
public class JSONPath_field_access_filter_rlike extends TestCase {
public void test_list_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name rlike 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 18
JSONPath path = new JSONPath("$[name rlike 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Reported by PMD.
Line: 19
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Reported by PMD.
Line: 24
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not rlike 'wenshao']");
Reported by PMD.
Line: 25
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not rlike 'wenshao']");
Reported by PMD.
Line: 28
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not rlike 'wenshao']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 34
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Reported by PMD.
Line: 38
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
}
public void test_list_like_left_match() throws Exception {
Reported by PMD.
Line: 39
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
}
public void test_list_like_left_match() throws Exception {
JSONPath path = new JSONPath("$[?(@.name like 'ljw%')]");
Reported by PMD.
Line: 40
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
}
public void test_list_like_left_match() throws Exception {
JSONPath path = new JSONPath("$[?(@.name like 'ljw%')]");
Reported by PMD.
src/test/java/com/alibaba/json/demo/Forguard.java
28 issues
Line: 26
return new String(value_chars);
}
public static char[] get(char[] json, int json_len, char[] key, int key_len) {
if (json_len == 0) {
return new char[0];
}
Parser parser = new Parser();
Reported by PMD.
Line: 14
String json = "{\"id\":\"a123\", \"name\":\"wxf\"}";
String value = javaGet(json, "id");
System.out.println(value);
}
public static String javaGet(String json, String key) {
char[] json_chars = json.toCharArray();
char[] key_chars = key.toCharArray();
Reported by PMD.
Line: 146
parser.token = Token.EOF;
return;
}
break;
}
switch (parser.ch) {
case '{':
parser.token = Token.LBRACE;
Reported by PMD.
Line: 8
/**
* Created by wenshao on 10/03/2017.
*/
public class Forguard extends TestCase {
public void test_0() throws Exception {
String json = "{\"id\":\"a123\", \"name\":\"wxf\"}";
String value = javaGet(json, "id");
Reported by PMD.
Line: 8
/**
* Created by wenshao on 10/03/2017.
*/
public class Forguard extends TestCase {
public void test_0() throws Exception {
String json = "{\"id\":\"a123\", \"name\":\"wxf\"}";
String value = javaGet(json, "id");
Reported by PMD.
Line: 10
*/
public class Forguard extends TestCase {
public void test_0() throws Exception {
String json = "{\"id\":\"a123\", \"name\":\"wxf\"}";
String value = javaGet(json, "id");
System.out.println(value);
}
Reported by PMD.
Line: 10
*/
public class Forguard extends TestCase {
public void test_0() throws Exception {
String json = "{\"id\":\"a123\", \"name\":\"wxf\"}";
String value = javaGet(json, "id");
System.out.println(value);
}
Reported by PMD.
Line: 26
return new String(value_chars);
}
public static char[] get(char[] json, int json_len, char[] key, int key_len) {
if (json_len == 0) {
return new char[0];
}
Parser parser = new Parser();
Reported by PMD.
Line: 26
return new String(value_chars);
}
public static char[] get(char[] json, int json_len, char[] key, int key_len) {
if (json_len == 0) {
return new char[0];
}
Parser parser = new Parser();
Reported by PMD.
Line: 26
return new String(value_chars);
}
public static char[] get(char[] json, int json_len, char[] key, int key_len) {
if (json_len == 0) {
return new char[0];
}
Parser parser = new Parser();
Reported by PMD.
src/test/java/com/alibaba/fastjson/JSONPathTest.java
28 issues
Line: 20
package com.alibaba.fastjson;
import com.alibaba.fastjson.JSONPath;
import com.diffblue.deeptestutils.Reflector;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Reported by PMD.
Line: 54
Object b = null;
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(false, retval);
}
Reported by PMD.
Line: 54
Object b = null;
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(false, retval);
}
Reported by PMD.
Line: 55
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(false, retval);
}
Reported by PMD.
Line: 56
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(false, retval);
}
/*
Reported by PMD.
Line: 73
Object b = null;
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(true, retval);
}
Reported by PMD.
Line: 74
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(true, retval);
}
Reported by PMD.
Line: 75
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath");
Method m = c.getDeclaredMethod("eq", Reflector.forName("java.lang.Object"), Reflector.forName("java.lang.Object"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, a, b);
// Assert result
Assert.assertEquals(true, retval);
}
/*
Reported by PMD.
Line: 90
// Arrange
char ch = '2';
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath$JSONPathParser");
Method m = c.getDeclaredMethod("isDigitFirst", Reflector.forName("char"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, ch);
// Assert result
Assert.assertEquals(true, retval);
Reported by PMD.
Line: 91
char ch = '2';
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.JSONPath$JSONPathParser");
Method m = c.getDeclaredMethod("isDigitFirst", Reflector.forName("char"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, ch);
// Assert result
Assert.assertEquals(true, retval);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue124.java
28 issues
Line: 38
try {
if (r % 2 == 0) {
// System.out.println(mapper.writeValueAsString(info));
System.out.println(JSON.toJSONString(new SuccessReturn(info),
SerializerFeature.WriteDateUseDateFormat));
} else {
// System.out.println(mapper.writeValueAsString(vo));
System.out.println(JSON.toJSONString(new SuccessReturn(vo),
SerializerFeature.WriteDateUseDateFormat));
Reported by PMD.
Line: 42
SerializerFeature.WriteDateUseDateFormat));
} else {
// System.out.println(mapper.writeValueAsString(vo));
System.out.println(JSON.toJSONString(new SuccessReturn(vo),
SerializerFeature.WriteDateUseDateFormat));
}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
Reported by PMD.
Line: 14
public class Issue124 extends TestCase {
public void test_for_issue() throws Exception {
// final ObjectMapper mapper = new ObjectMapper();
// mapper.setSerializationInclusion(Include.NON_NULL);
final Random random = new Random();
final int threadCount = 1000;
final CountDownLatch latch = new CountDownLatch(threadCount);
Reported by PMD.
Line: 14
public class Issue124 extends TestCase {
public void test_for_issue() throws Exception {
// final ObjectMapper mapper = new ObjectMapper();
// mapper.setSerializationInclusion(Include.NON_NULL);
final Random random = new Random();
final int threadCount = 1000;
final CountDownLatch latch = new CountDownLatch(threadCount);
Reported by PMD.
Line: 28
// SerializerFeature.WriteDateUseDateFormat);
// }
for (int i = 0; i < threadCount; i++) {
new Thread() {
@Override
public void run() {
UserInfo info = new UserInfo();
CheckInfoVo vo = new CheckInfoVo(100);
Reported by PMD.
Line: 32
@Override
public void run() {
UserInfo info = new UserInfo();
CheckInfoVo vo = new CheckInfoVo(100);
int r = random.nextInt();
try {
if (r % 2 == 0) {
// System.out.println(mapper.writeValueAsString(info));
Reported by PMD.
Line: 33
@Override
public void run() {
UserInfo info = new UserInfo();
CheckInfoVo vo = new CheckInfoVo(100);
int r = random.nextInt();
try {
if (r % 2 == 0) {
// System.out.println(mapper.writeValueAsString(info));
System.out.println(JSON.toJSONString(new SuccessReturn(info),
Reported by PMD.
Line: 38
try {
if (r % 2 == 0) {
// System.out.println(mapper.writeValueAsString(info));
System.out.println(JSON.toJSONString(new SuccessReturn(info),
SerializerFeature.WriteDateUseDateFormat));
} else {
// System.out.println(mapper.writeValueAsString(vo));
System.out.println(JSON.toJSONString(new SuccessReturn(vo),
SerializerFeature.WriteDateUseDateFormat));
Reported by PMD.
Line: 42
SerializerFeature.WriteDateUseDateFormat));
} else {
// System.out.println(mapper.writeValueAsString(vo));
System.out.println(JSON.toJSONString(new SuccessReturn(vo),
SerializerFeature.WriteDateUseDateFormat));
}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
Reported by PMD.
Line: 45
System.out.println(JSON.toJSONString(new SuccessReturn(vo),
SerializerFeature.WriteDateUseDateFormat));
}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
} finally {
latch.countDown();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_luogongwu.java
28 issues
Line: 39
foo.thumbnails = imageList;
String jsonString = JSON.toJSONString(foo);
System.out.println(jsonString);
Foo foo1 = JSON.parseObject(jsonString, Foo.class);
assertEquals(1, foo1.thumbnails.size());
assertNotNull(foo1.thumbnails.get(0));
Reported by PMD.
Line: 54
fooNotAsm.thumbnails = imageList;
jsonString = JSON.toJSONString(foo);
System.out.println(jsonString);
FooNotAsm fooNotAsm1 = JSON.parseObject(jsonString, FooNotAsm.class);
assertEquals(1, fooNotAsm1.thumbnails.size());
assertNotNull(fooNotAsm1.thumbnails.get(0));
Reported by PMD.
Line: 19
*/
public class Bug_for_luogongwu extends TestCase {
public void test_for_issue() throws Exception {
List<IflowItemImage> imageList = new ArrayList<IflowItemImage>();
IflowItemImage image = new IflowItemImage();
image.id = "72c7275c6b";
imageList.add(image);
Reported by PMD.
Line: 19
*/
public class Bug_for_luogongwu extends TestCase {
public void test_for_issue() throws Exception {
List<IflowItemImage> imageList = new ArrayList<IflowItemImage>();
IflowItemImage image = new IflowItemImage();
image.id = "72c7275c6b";
imageList.add(image);
Reported by PMD.
Line: 31
imageList.add(image);
// force ASM
boolean asm = SerializeConfig.globalInstance.isAsmEnable();
SerializeConfig.globalInstance.setAsmEnable(true);
// Test ASM
Foo foo = new Foo();
foo.thumbnails = imageList;
Reported by PMD.
Line: 32
// force ASM
boolean asm = SerializeConfig.globalInstance.isAsmEnable();
SerializeConfig.globalInstance.setAsmEnable(true);
// Test ASM
Foo foo = new Foo();
foo.thumbnails = imageList;
Reported by PMD.
Line: 43
Foo foo1 = JSON.parseObject(jsonString, Foo.class);
assertEquals(1, foo1.thumbnails.size());
assertNotNull(foo1.thumbnails.get(0));
assertSame(foo1.getThumbnail(), foo1.thumbnails.get(0));
// test Not ASM
Reported by PMD.
Line: 43
Foo foo1 = JSON.parseObject(jsonString, Foo.class);
assertEquals(1, foo1.thumbnails.size());
assertNotNull(foo1.thumbnails.get(0));
assertSame(foo1.getThumbnail(), foo1.thumbnails.get(0));
// test Not ASM
Reported by PMD.
Line: 44
Foo foo1 = JSON.parseObject(jsonString, Foo.class);
assertEquals(1, foo1.thumbnails.size());
assertNotNull(foo1.thumbnails.get(0));
assertSame(foo1.getThumbnail(), foo1.thumbnails.get(0));
// test Not ASM
SerializeConfig.globalInstance.setAsmEnable(false);
Reported by PMD.
Line: 44
Foo foo1 = JSON.parseObject(jsonString, Foo.class);
assertEquals(1, foo1.thumbnails.size());
assertNotNull(foo1.thumbnails.get(0));
assertSame(foo1.getThumbnail(), foo1.thumbnails.get(0));
// test Not ASM
SerializeConfig.globalInstance.setAsmEnable(false);
Reported by PMD.