The following issues were found
src/main/java/com/alibaba/fastjson/JSONArray.java
15 issues
Line: 329
return castToShort(value);
}
public short getShortValue(int index) {
Object value = get(index);
Short shortVal = castToShort(value);
if (shortVal == null) {
return 0;
Reported by PMD.
Line: 461
}
@Override
public Object clone() {
return new JSONArray(new ArrayList<Object>(list));
}
public boolean equals(Object obj) {
return this.list.equals(obj);
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.fastjson;
import static com.alibaba.fastjson.util.TypeUtils.castToBigDecimal;
import static com.alibaba.fastjson.util.TypeUtils.castToBigInteger;
import static com.alibaba.fastjson.util.TypeUtils.castToBoolean;
import static com.alibaba.fastjson.util.TypeUtils.castToByte;
Reported by PMD.
Line: 46
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAccess, Serializable {
private static final long serialVersionUID = 1L;
private final List<Object> list;
protected transient Object relatedArray;
protected transient Type componentType;
Reported by PMD.
Line: 46
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAccess, Serializable {
private static final long serialVersionUID = 1L;
private final List<Object> list;
protected transient Object relatedArray;
protected transient Type componentType;
Reported by PMD.
Line: 49
public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAccess, Serializable {
private static final long serialVersionUID = 1L;
private final List<Object> list;
protected transient Object relatedArray;
protected transient Type componentType;
public JSONArray(){
this.list = new ArrayList<Object>();
Reported by PMD.
Line: 303
return false;
}
return castToBoolean(value).booleanValue();
}
public Byte getByte(int index) {
Object value = get(index);
Reported by PMD.
Line: 461
}
@Override
public Object clone() {
return new JSONArray(new ArrayList<Object>(list));
}
public boolean equals(Object obj) {
return this.list.equals(obj);
Reported by PMD.
Line: 461
}
@Override
public Object clone() {
return new JSONArray(new ArrayList<Object>(list));
}
public boolean equals(Object obj) {
return this.list.equals(obj);
Reported by PMD.
Line: 474
}
private void readObject(final java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
JSONObject.SecureObjectInputStream.ensureFields();
if (JSONObject.SecureObjectInputStream.fields != null && !JSONObject.SecureObjectInputStream.fields_error) {
ObjectInputStream secIn = new JSONObject.SecureObjectInputStream(in);
try {
secIn.defaultReadObject();
return;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1226.java
15 issues
Line: 12
* Created by wenshao on 16/05/2017.
*/
public class Issue1226 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
Reported by PMD.
Line: 12
* Created by wenshao on 16/05/2017.
*/
public class Issue1226 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 23
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
Line: 24
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
Line: 24
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/spring/FastJsonJsonView.java
15 issues
Line: 381
if (extractValueFromSingleKeyModel) {
if (result.size() == 1) {
for (Map.Entry<String, Object> entry : result.entrySet()) {
return entry.getValue();
}
}
}
return result;
}
Reported by PMD.
Line: 33
* @since 1.2.9
*/
public class FastJsonJsonView extends AbstractView {
/**
* default content type
*/
Reported by PMD.
Line: 49
/**
* Pattern for validating jsonp callback parameter values.
*/
private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_\\.]*");
@Deprecated
protected Charset charset = Charset.forName("UTF-8");
@Deprecated
Reported by PMD.
Line: 66
/**
* renderedAttributes
*/
private Set<String> renderedAttributes;
/**
* disableCaching
*/
private boolean disableCaching = true;
Reported by PMD.
Line: 71
/**
* disableCaching
*/
private boolean disableCaching = true;
/**
* updateContentLength
*/
private boolean updateContentLength = true;
Reported by PMD.
Line: 76
/**
* updateContentLength
*/
private boolean updateContentLength = true;
/**
* extractValueFromSingleKeyModel
*/
private boolean extractValueFromSingleKeyModel = false;
Reported by PMD.
Line: 81
/**
* extractValueFromSingleKeyModel
*/
private boolean extractValueFromSingleKeyModel = false;
/**
* with fastJson config
*/
private FastJsonConfig fastJsonConfig = new FastJsonConfig();
Reported by PMD.
Line: 91
/**
* jsonp parameter name
*/
private String[] jsonpParameterNames = {"jsonp", "callback"};
/**
* Set default param.
*/
public FastJsonJsonView() {
Reported by PMD.
Line: 264
*/
public void setJsonpParameterNames(Set<String> jsonpParameterNames) {
Assert.notEmpty(jsonpParameterNames, "jsonpParameterName cannot be empty");
this.jsonpParameterNames = jsonpParameterNames.toArray(new String[jsonpParameterNames.size()]);
}
private String getJsonpParameterValue(HttpServletRequest request) {
if (this.jsonpParameterNames != null) {
Reported by PMD.
Line: 318
ServletOutputStream out = response.getOutputStream();
outnew.writeTo(out);
outnew.close();
out.flush();
}
@Override
protected void prepareResponse(HttpServletRequest request, //
HttpServletResponse response) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_10.java
15 issues
Line: 11
public class SerializeWriterTest_10 extends TestCase {
public void test_erro_0() throws Exception {
SerializeWriter out = new SerializeWriter();
Exception error = null;
try {
out.write(new char[0], -1, 0);
} catch (Exception ex) {
Reported by PMD.
Line: 16
Exception error = null;
try {
out.write(new char[0], -1, 0);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
out.close();
}
Reported by PMD.
Line: 23
out.close();
}
public void test_erro_1() throws Exception {
SerializeWriter out = new SerializeWriter();
Exception error = null;
try {
out.write(new char[0], 1, 0);
} catch (Exception ex) {
Reported by PMD.
Line: 28
Exception error = null;
try {
out.write(new char[0], 1, 0);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
out.close();
}
Reported by PMD.
Line: 35
out.close();
}
public void test_erro_2() throws Exception {
SerializeWriter out = new SerializeWriter();
Exception error = null;
try {
out.write(new char[0], 0, -1);
} catch (Exception ex) {
Reported by PMD.
Line: 40
Exception error = null;
try {
out.write(new char[0], 0, -1);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
out.close();
}
Reported by PMD.
Line: 47
out.close();
}
public void test_erro_3() throws Exception {
SerializeWriter out = new SerializeWriter();
Exception error = null;
try {
out.write(new char[] { '0', '0' }, 1, 2);
} catch (Exception ex) {
Reported by PMD.
Line: 52
Exception error = null;
try {
out.write(new char[] { '0', '0' }, 1, 2);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
out.close();
}
Reported by PMD.
Line: 59
out.close();
}
public void test_erro_4() throws Exception {
SerializeWriter out = new SerializeWriter();
Exception error = null;
try {
out.write(new char[] { '0', '0' }, 1, Integer.MAX_VALUE);
} catch (Exception ex) {
Reported by PMD.
Line: 64
Exception error = null;
try {
out.write(new char[] { '0', '0' }, 1, Integer.MAX_VALUE);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
out.close();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_set.java
14 issues
Line: 11
public class JSONLexerTest_set extends TestCase {
public void test_treeSet() throws Exception {
JSON.parse("Set[]");
}
public void test_error() throws Exception {
Exception error = null;
Reported by PMD.
Line: 11
public class JSONLexerTest_set extends TestCase {
public void test_treeSet() throws Exception {
JSON.parse("Set[]");
}
public void test_error() throws Exception {
Exception error = null;
Reported by PMD.
Line: 15
JSON.parse("Set[]");
}
public void test_error() throws Exception {
Exception error = null;
try {
JSON.parse("S_t[]");
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 19
Exception error = null;
try {
JSON.parse("S_t[]");
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 25
Assert.assertNotNull(error);
}
public void test_error_1() throws Exception {
Exception error = null;
try {
JSON.parse("Se_[]");
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 29
Exception error = null;
try {
JSON.parse("Se_[]");
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 36
}
public void test_error_2() throws Exception {
Exception error = null;
try {
JSON.parse("Set_[]");
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 40
Exception error = null;
try {
JSON.parse("Set_[]");
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 46
Assert.assertNotNull(error);
}
public void test_error_3() throws Exception {
Exception error = null;
try {
JSON.parse("Xet[]");
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 50
Exception error = null;
try {
JSON.parse("Xet[]");
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest5.java
14 issues
Line: 20
model.a = b;
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
Reported by PMD.
Line: 34
model.a = a;
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class WriteClassNameTest5 extends TestCase {
public void test_for_writeClassName() throws Exception {
Model model = new Model();
B b = new B();
b.id = 1001;
b.value = 2017;
model.a = b;
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class WriteClassNameTest5 extends TestCase {
public void test_for_writeClassName() throws Exception {
Model model = new Model();
B b = new B();
b.id = 1001;
b.value = 2017;
model.a = b;
Reported by PMD.
Line: 21
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
Reported by PMD.
Line: 24
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
Reported by PMD.
Line: 27
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
a.id = 1001;
model.a = a;
Reported by PMD.
Line: 27
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
a.id = 1001;
model.a = a;
Reported by PMD.
Line: 35
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
Reported by PMD.
Line: 38
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
public A a;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set5.java
14 issues
Line: 14
public class WriteClassNameTest_Set5 extends TestCase {
public void test_list() throws Exception {
Model model = new Model();
LinkedHashSet tables = new LinkedHashSet();
tables.add(new ExtTable(1001));
tables.add(new Table());
model.setTables(tables);
Reported by PMD.
Line: 14
public class WriteClassNameTest_Set5 extends TestCase {
public void test_list() throws Exception {
Model model = new Model();
LinkedHashSet tables = new LinkedHashSet();
tables.add(new ExtTable(1001));
tables.add(new Table());
model.setTables(tables);
Reported by PMD.
Line: 22
model.setTables(tables);
String json = JSON.toJSONString(model);
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
Reported by PMD.
Line: 25
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
Reported by PMD.
Line: 25
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
Reported by PMD.
Line: 25
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
Reported by PMD.
Line: 25
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
Reported by PMD.
Line: 25
assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set5$ExtTable\",\"id\":1001},{}]}", json);
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
Reported by PMD.
Line: 28
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private LinkedHashSet<? extends Table> tables;
Reported by PMD.
Line: 28
assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":[{\"id\":1001},{}]}", jsonObject.toJSONString());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private LinkedHashSet<? extends Table> tables;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/list/ArrayDeserializerTest.java
14 issues
Line: 10
public class ArrayDeserializerTest extends TestCase {
public void test_null() throws Exception {
Assert.assertNull(JSON.parseObject("null", Object[].class));
Assert.assertNull(JSON.parseObject("null", String[].class));
Assert.assertNull(JSON.parseObject("null", VO[].class));
Assert.assertNull(JSON.parseObject("null", VO[][].class));
}
Reported by PMD.
Line: 11
public class ArrayDeserializerTest extends TestCase {
public void test_null() throws Exception {
Assert.assertNull(JSON.parseObject("null", Object[].class));
Assert.assertNull(JSON.parseObject("null", String[].class));
Assert.assertNull(JSON.parseObject("null", VO[].class));
Assert.assertNull(JSON.parseObject("null", VO[][].class));
}
Reported by PMD.
Line: 17
Assert.assertNull(JSON.parseObject("null", VO[][].class));
}
public void test_0() throws Exception {
Assert.assertEquals(0, JSON.parseObject("[]", Object[].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Reported by PMD.
Line: 18
}
public void test_0() throws Exception {
Assert.assertEquals(0, JSON.parseObject("[]", Object[].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Reported by PMD.
Line: 19
public void test_0() throws Exception {
Assert.assertEquals(0, JSON.parseObject("[]", Object[].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Reported by PMD.
Line: 20
public void test_0() throws Exception {
Assert.assertEquals(0, JSON.parseObject("[]", Object[].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
Reported by PMD.
Line: 21
Assert.assertEquals(0, JSON.parseObject("[]", Object[].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
}
Reported by PMD.
Line: 22
Assert.assertEquals(0, JSON.parseObject("[]", Object[][].class).length);
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
}
Reported by PMD.
Line: 23
Assert.assertEquals(0, JSON.parseObject("[]", Object[][][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
}
public static class VO {
Reported by PMD.
Line: 24
Assert.assertEquals(1, JSON.parseObject("[null]", Object[].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[[[[[[]]]]]]", Object[][].class).length);
Assert.assertEquals(1, JSON.parseObject("[null]", Object[][][].class).length);
Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue969.java
14 issues
Line: 17
* Created by wenshao on 08/05/2017.
*/
public class Issue969 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 17
* Created by wenshao on 08/05/2017.
*/
public class Issue969 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 22
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
Reported by PMD.
Line: 26
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 27
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 27
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 30
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 30
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 39
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public static class Model {
Reported by PMD.
Line: 40
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public static class Model {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TypeUtils_parseFloat_Test.java
14 issues
Line: 9
import java.util.Random;
public class TypeUtils_parseFloat_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(Float.parseFloat(str), TypeUtils.parseFloat(str));
Reported by PMD.
Line: 14
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Float.toString(r.nextFloat());
assertEquals(Float.parseFloat(str), TypeUtils.parseFloat(str));
}
}
public void test_1() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 18
}
}
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(Float.parseFloat(str), TypeUtils.parseFloat(str));
Reported by PMD.
Line: 23
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt());
assertEquals(Float.parseFloat(str), TypeUtils.parseFloat(str));
}
}
public void test_2() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 27
}
}
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(Float.parseFloat(str), TypeUtils.parseFloat(str));
Reported by PMD.
Line: 32
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Integer.toString(r.nextInt(1000000000));
assertEquals(Float.parseFloat(str), TypeUtils.parseFloat(str));
}
}
public void test_3() throws Exception {
Random r = new Random();
Reported by PMD.
Line: 36
}
}
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(Float.parseFloat(str), TypeUtils.parseFloat(str));
Reported by PMD.
Line: 41
for (int i = 0; i < 1000 * 1000; ++i) {
String str = Long.toString(r.nextLong());
assertEquals(Float.parseFloat(str), TypeUtils.parseFloat(str));
}
}
public void test_4() throws Exception {
String[] array = new String[] {
Reported by PMD.
Line: 45
}
}
public void test_4() throws Exception {
String[] array = new String[] {
"0.34856254",
"1",
"12",
"123",
Reported by PMD.
Line: 82
};
for (String str : array) {
assertEquals(Float.parseFloat(str), TypeUtils.parseFloat(str));
}
}
}
Reported by PMD.