The following issues were found
src/test/java/com/alibaba/json/bvt/kotlin/ResponseKotlinTest.java
5 issues
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class ResponseKotlinTest extends TestCase {
public void test_kotlin() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("ResponseKotlin");
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
Reported by PMD.
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class ResponseKotlinTest extends TestCase {
public void test_kotlin() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("ResponseKotlin");
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
Reported by PMD.
Line: 20
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
assertEquals("{\"text\":\"robohorse\",\"value\":99}", JSON.toJSONString(obj));
String json2 = "{\"text\":\"robohorse\"}";
Object obj2 = JSON.parseObject(json2, clazz);
assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
}
Reported by PMD.
Line: 24
String json2 = "{\"text\":\"robohorse\"}";
Object obj2 = JSON.parseObject(json2, clazz);
assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
}
public static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 34
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ResponseKotlin.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("ResponseKotlin", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2100/Issue2129.java
5 issues
Line: 8
import junit.framework.TestCase;
public class Issue2129 extends TestCase {
public void test_for_issue() throws Exception {
LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
map.put("a", "1");
map.put("a", "b");
map.put("b", "1");
String json = JSON.toJSONString(map);
Reported by PMD.
Line: 10
public class Issue2129 extends TestCase {
public void test_for_issue() throws Exception {
LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
map.put("a", "1");
map.put("a", "b");
map.put("b", "1");
String json = JSON.toJSONString(map);
assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
}
Reported by PMD.
Line: 11
public void test_for_issue() throws Exception {
LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
map.put("a", "1");
map.put("a", "b");
map.put("b", "1");
String json = JSON.toJSONString(map);
assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
}
}
Reported by PMD.
Line: 12
LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
map.put("a", "1");
map.put("a", "b");
map.put("b", "1");
String json = JSON.toJSONString(map);
assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
}
}
Reported by PMD.
Line: 14
map.put("a", "b");
map.put("b", "1");
String json = JSON.toJSONString(map);
assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3671.java
5 issues
Line: 8
import junit.framework.TestCase;
public class Issue3671 extends TestCase {
public void test_for_issue() throws Exception {
String json = "[{\n" +
" \"filters\": [],\n" +
" \"id\": \"baidu_route2\",\n" +
" \"order\": 0,\n" +
" \"predicates\": [{\n" +
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue3671 extends TestCase {
public void test_for_issue() throws Exception {
String json = "[{\n" +
" \"filters\": [],\n" +
" \"id\": \"baidu_route2\",\n" +
" \"order\": 0,\n" +
" \"predicates\": [{\n" +
Reported by PMD.
Line: 21
" }],\n" +
" \"uri\": \"https://www.baidu.com\"\n" +
"}]\n";
assertTrue(JSONValidator.from(json).validate());
assertTrue(JSON.isValid(json));
}
}
Reported by PMD.
Line: 21
" }],\n" +
" \"uri\": \"https://www.baidu.com\"\n" +
"}]\n";
assertTrue(JSONValidator.from(json).validate());
assertTrue(JSON.isValid(json));
}
}
Reported by PMD.
Line: 22
" \"uri\": \"https://www.baidu.com\"\n" +
"}]\n";
assertTrue(JSONValidator.from(json).validate());
assertTrue(JSON.isValid(json));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/kotlin/ResponseKotlin2Test.java
5 issues
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class ResponseKotlin2Test extends TestCase {
public void test_kotlin() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("ResponseKotlin2");
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
Reported by PMD.
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class ResponseKotlin2Test extends TestCase {
public void test_kotlin() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("ResponseKotlin2");
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
Reported by PMD.
Line: 20
String json = "{\"text\":\"robohorse\",\"value\":99}";
Object obj = JSON.parseObject(json, clazz);
assertEquals("{\"text\":\"robohorse\",\"value\":99}", JSON.toJSONString(obj));
String json2 = "{\"text\":\"robohorse\"}";
Object obj2 = JSON.parseObject(json2, clazz);
assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
}
Reported by PMD.
Line: 24
String json2 = "{\"text\":\"robohorse\"}";
Object obj2 = JSON.parseObject(json2, clazz);
assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
}
public static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 34
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ResponseKotlin2.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("ResponseKotlin2", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue_for_wuye.java
5 issues
Line: 9
import java.util.Date;
public class Issue_for_wuye extends TestCase {
public void test_for_issue() throws Exception {
String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
}
public static class TimeBean {
Reported by PMD.
Line: 9
import java.util.Date;
public class Issue_for_wuye extends TestCase {
public void test_for_issue() throws Exception {
String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
}
public static class TimeBean {
Reported by PMD.
Line: 11
public class Issue_for_wuye extends TestCase {
public void test_for_issue() throws Exception {
String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
}
public static class TimeBean {
private Date time1;
private Date time2;
Reported by PMD.
Line: 14
TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
}
public static class TimeBean {
private Date time1;
private Date time2;
public Date getTime1() {
return time1;
Reported by PMD.
Line: 11
public class Issue_for_wuye extends TestCase {
public void test_for_issue() throws Exception {
String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
}
public static class TimeBean {
private Date time1;
private Date time2;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2201.java
5 issues
Line: 9
import junit.framework.TestCase;
public class Issue2201 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().register("M2001", Model.class);
String json = "{\"@type\":\"M2001\",\"id\":3}";
Model m = (Model) JSON.parseObject(json, Object.class);
assertEquals(3, m.id);
Reported by PMD.
Line: 10
public class Issue2201 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().register("M2001", Model.class);
String json = "{\"@type\":\"M2001\",\"id\":3}";
Model m = (Model) JSON.parseObject(json, Object.class);
assertEquals(3, m.id);
}
Reported by PMD.
Line: 14
String json = "{\"@type\":\"M2001\",\"id\":3}";
Model m = (Model) JSON.parseObject(json, Object.class);
assertEquals(3, m.id);
}
public static class Model {
public int id;
}
Reported by PMD.
Line: 18
}
public static class Model {
public int id;
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
public class Issue2201 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().register("M2001", Model.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jsonp/JSONPParseTest4.java
5 issues
Line: 13
* Created by wenshao on 21/02/2017.
*/
public class JSONPParseTest4 extends TestCase {
public void test_f() throws Exception {
JSONPObject p = new JSONPObject();
p.setFunction("f");
assertEquals("f()", p.toJSONString());
}
}
Reported by PMD.
Line: 16
public void test_f() throws Exception {
JSONPObject p = new JSONPObject();
p.setFunction("f");
assertEquals("f()", p.toJSONString());
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.jsonp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.jsonp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
* Created by wenshao on 21/02/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/emoji/EmojiTest0.java
5 issues
Line: 22
JSON.writeJSONString(out, model);
String text = new String(out.toByteArray(), "UTF-8");
System.out.println(text);
}
public static class Model {
public String value;
}
Reported by PMD.
Line: 13
* Created by wenshao on 13/04/2017.
*/
public class EmojiTest0 extends TestCase {
public void test_for_emoji() throws Exception {
Model model = new Model();
model.value = "An 😀awesome 😃string with a few 😉emojis!";
ByteArrayOutputStream out = new ByteArrayOutputStream();
Reported by PMD.
Line: 13
* Created by wenshao on 13/04/2017.
*/
public class EmojiTest0 extends TestCase {
public void test_for_emoji() throws Exception {
Model model = new Model();
model.value = "An 😀awesome 😃string with a few 😉emojis!";
ByteArrayOutputStream out = new ByteArrayOutputStream();
Reported by PMD.
Line: 26
}
public static class Model {
public String value;
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.emoji;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.io.ByteArrayOutputStream;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/kotlin/Issue_for_kotlin_20181203.java
5 issues
Line: 32
+ " \"task_type\": \"57205\"\n"
+ " }]";
System.out.println(JSON.VERSION);
Object obj = JSONArray.parseArray(str, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);
Reported by PMD.
Line: 36
Object obj = JSONArray.parseArray(str, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);
}
private static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 12
import java.io.InputStream;
public class Issue_for_kotlin_20181203 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("com.autonavi.falcon.data.service.vulpeData.ProjectItemCheckItemRelation1");
String str = " [{\n"
+ " \"project_item\": \"1105067\",\n"
Reported by PMD.
Line: 37
Object obj = JSONArray.parseArray(str, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);
}
private static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 47
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ProjectItemCheckItemRelation1.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("com.autonavi.falcon.data.service.vulpeData.ProjectItemCheckItemRelation1", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/FeatureTest.java
5 issues
Line: 13
public class FeatureTest extends TestCase {
public void test_default() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("");
Assert.assertEquals(false, parser.isEnabled(Feature.AllowComment));
Assert.assertEquals(true, parser.isEnabled(Feature.AllowSingleQuotes));
Assert.assertEquals(true, parser.isEnabled(Feature.AllowUnQuotedFieldNames));
Reported by PMD.
Line: 23
Assert.assertEquals(true, parser.isEnabled(Feature.InternFieldNames));
}
public void test_config() throws Exception {
new IOUtils();
DefaultJSONParser parser = new DefaultJSONParser("");
Assert.assertEquals(false, parser.isEnabled(Feature.AllowComment));
Reported by PMD.
Line: 41
Assert.assertEquals(false, parser.isEnabled(Feature.InternFieldNames));
}
public void test_count() throws Exception {
assertTrue(Feature.values().length < 32);
}
}
Reported by PMD.
Line: 42
}
public void test_count() throws Exception {
assertTrue(Feature.values().length < 32);
}
}
Reported by PMD.
Line: 42
}
public void test_count() throws Exception {
assertTrue(Feature.values().length < 32);
}
}
Reported by PMD.