The following issues were found
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest14.java
5 issues
Line: 11
* Created by wenshao on 29/01/2017.
*/
public class DenyTest14 extends TestCase {
public void test_deny() throws Exception {
String text = "{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest14$MyException\"}}";
Model model = JSON.parseObject(text, Model.class);
assertTrue(model.value instanceof MyException);
}
Reported by PMD.
Line: 14
public void test_deny() throws Exception {
String text = "{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest14$MyException\"}}";
Model model = JSON.parseObject(text, Model.class);
assertTrue(model.value instanceof MyException);
}
public static class Model {
public Throwable value;
}
Reported by PMD.
Line: 18
}
public static class Model {
public Throwable value;
}
public static class MyException extends Exception {
}
Reported by PMD.
Line: 21
public Throwable value;
}
public static class MyException extends Exception {
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.parser.deser.deny;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import junit.framework.TestCase;
/**
* Created by wenshao on 29/01/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_paths_test5.java
5 issues
Line: 14
*/
public class JSONPath_paths_test5 extends TestCase {
public void test_array() throws Exception {
String[] array = new String[]{"1001", "wenshao"};
Map<String, Object> paths = JSONPath.paths(array);
Assert.assertEquals(3, paths.size());
Reported by PMD.
Line: 19
Map<String, Object> paths = JSONPath.paths(array);
Assert.assertEquals(3, paths.size());
Assert.assertSame(array, paths.get("/"));
Assert.assertEquals("1001", paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 20
Map<String, Object> paths = JSONPath.paths(array);
Assert.assertEquals(3, paths.size());
Assert.assertSame(array, paths.get("/"));
Assert.assertEquals("1001", paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 21
Assert.assertEquals(3, paths.size());
Assert.assertSame(array, paths.get("/"));
Assert.assertEquals("1001", paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 22
Assert.assertEquals(3, paths.size());
Assert.assertSame(array, paths.get("/"));
Assert.assertEquals("1001", paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/asm/TestASM_short.java
5 issues
Line: 19
public static class V0 {
private short i = 12;
public short getI() {
return i;
}
Reported by PMD.
Line: 21
private short i = 12;
public short getI() {
return i;
}
public void setI(short i) {
this.i = i;
Reported by PMD.
Line: 25
return i;
}
public void setI(short i) {
this.i = i;
}
}
}
Reported by PMD.
Line: 10
public class TestASM_short extends TestCase {
public void test_asm() throws Exception {
V0 v = new V0();
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getI(), v1.getI());
}
Reported by PMD.
Line: 14
V0 v = new V0();
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getI(), v1.getI());
}
public static class V0 {
private short i = 12;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/asm/TestASM_primitive.java
5 issues
Line: 14
public class TestASM_primitive extends TestCase {
public void test_asm() throws Exception {
ASMDeserializerFactory factory = new ASMDeserializerFactory(new ASMClassLoader());
Exception error = null;
try {
JavaBeanInfo beanInfo = JavaBeanInfo.build(int.class, int.class, null);
Reported by PMD.
Line: 21
try {
JavaBeanInfo beanInfo = JavaBeanInfo.build(int.class, int.class, null);
factory.createJavaBeanDeserializer(ParserConfig.getGlobalInstance(), beanInfo);
} catch (Exception ex) {
error = ex;
}
assertNotNull(error);
}
Reported by PMD.
Line: 24
} catch (Exception ex) {
error = ex;
}
assertNotNull(error);
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.parser.deser.asm;
import org.junit.Assert;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ASMDeserializerFactory;
import com.alibaba.fastjson.util.ASMClassLoader;
import com.alibaba.fastjson.util.JavaBeanInfo;
Reported by PMD.
Line: 17
public void test_asm() throws Exception {
ASMDeserializerFactory factory = new ASMDeserializerFactory(new ASMClassLoader());
Exception error = null;
try {
JavaBeanInfo beanInfo = JavaBeanInfo.build(int.class, int.class, null);
factory.createJavaBeanDeserializer(ParserConfig.getGlobalInstance(), beanInfo);
} catch (Exception ex) {
error = ex;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_paths_test1.java
5 issues
Line: 14
import junit.framework.TestCase;
public class JSONPath_paths_test1 extends TestCase {
public void test_map() throws Exception {
List<Object> list = new ArrayList<Object>();
list.add(1001);
list.add("wenshao");
Reported by PMD.
Line: 22
Map<String, Object> paths = JSONPath.paths(list);
Assert.assertEquals(3, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 23
Map<String, Object> paths = JSONPath.paths(list);
Assert.assertEquals(3, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 24
Assert.assertEquals(3, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
Line: 25
Assert.assertEquals(3, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/retrofit/Retrofit2ConverterFactoryTest0.java
5 issues
Line: 21
import java.nio.charset.Charset;
public class Retrofit2ConverterFactoryTest0 extends TestCase {
public void test_for_coverage() throws Exception {
Retrofit2ConverterFactory f = new Retrofit2ConverterFactory();
f.getParserConfig();
f.getParserFeatures();
f.getParserFeatureValues();
f.getSerializeConfig();
Reported by PMD.
Line: 44
final Headers headers = Headers.of("Content-Type", "application/json; charset=UTF-8");
final ResponseBody body = new RealResponseBody(headers, buffer);
RequestBody requestBody = Retrofit2ConverterFactory.create()
.requestBodyConverter(Model.class, null, null, null)
.convert(model);
Assert.assertNotEquals(requestBody.contentLength(), 0);
Reported by PMD.
Line: 44
final Headers headers = Headers.of("Content-Type", "application/json; charset=UTF-8");
final ResponseBody body = new RealResponseBody(headers, buffer);
RequestBody requestBody = Retrofit2ConverterFactory.create()
.requestBodyConverter(Model.class, null, null, null)
.convert(model);
Assert.assertNotEquals(requestBody.contentLength(), 0);
Reported by PMD.
Line: 50
Assert.assertNotEquals(requestBody.contentLength(), 0);
Model mode2 = (Model) Retrofit2ConverterFactory.create()
.responseBodyConverter(Model.class, null, null)
.convert(body);
Assert.assertEquals(JSON.toJSONString(mode2), json);
}
Reported by PMD.
Line: 50
Assert.assertNotEquals(requestBody.contentLength(), 0);
Model mode2 = (Model) Retrofit2ConverterFactory.create()
.responseBodyConverter(Model.class, null, null)
.convert(body);
Assert.assertEquals(JSON.toJSONString(mode2), json);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_paths_test.java
5 issues
Line: 13
import junit.framework.TestCase;
public class JSONPath_paths_test extends TestCase {
public void test_map() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 1001);
map.put("name", "wenshao");
Map<String, Object> paths = JSONPath.paths(map);
Reported by PMD.
Line: 20
Map<String, Object> paths = JSONPath.paths(map);
Assert.assertEquals(3, paths.size());
Assert.assertSame(map, paths.get("/"));
Assert.assertEquals(1001, paths.get("/id"));
Assert.assertEquals("wenshao", paths.get("/name"));
}
}
Reported by PMD.
Line: 21
Map<String, Object> paths = JSONPath.paths(map);
Assert.assertEquals(3, paths.size());
Assert.assertSame(map, paths.get("/"));
Assert.assertEquals(1001, paths.get("/id"));
Assert.assertEquals("wenshao", paths.get("/name"));
}
}
Reported by PMD.
Line: 22
Assert.assertEquals(3, paths.size());
Assert.assertSame(map, paths.get("/"));
Assert.assertEquals(1001, paths.get("/id"));
Assert.assertEquals("wenshao", paths.get("/name"));
}
}
Reported by PMD.
Line: 23
Assert.assertEquals(3, paths.size());
Assert.assertSame(map, paths.get("/"));
Assert.assertEquals(1001, paths.get("/id"));
Assert.assertEquals("wenshao", paths.get("/name"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_oracle_compatible_test.java
5 issues
Line: 11
public class JSONPath_oracle_compatible_test
extends TestCase
{
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject(str);
assertEquals("Sayings of the Century", JSONPath.eval(object, "$.store.book[0].title"));
assertEquals("Sayings of the Century", JSONPath.eval(object, "$['store']['book'][0]['title']"));
}
Reported by PMD.
Line: 11
public class JSONPath_oracle_compatible_test
extends TestCase
{
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject(str);
assertEquals("Sayings of the Century", JSONPath.eval(object, "$.store.book[0].title"));
assertEquals("Sayings of the Century", JSONPath.eval(object, "$['store']['book'][0]['title']"));
}
Reported by PMD.
Line: 14
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject(str);
assertEquals("Sayings of the Century", JSONPath.eval(object, "$.store.book[0].title"));
assertEquals("Sayings of the Century", JSONPath.eval(object, "$['store']['book'][0]['title']"));
}
public static final String str = "{\n" +
Reported by PMD.
Line: 15
JSONObject object = JSON.parseObject(str);
assertEquals("Sayings of the Century", JSONPath.eval(object, "$.store.book[0].title"));
assertEquals("Sayings of the Century", JSONPath.eval(object, "$['store']['book'][0]['title']"));
}
public static final String str = "{\n" +
" \"store\": {\n" +
Reported by PMD.
Line: 22
public static final String str = "{\n" +
" \"store\": {\n" +
" \"book\": [\n" +
" {\n" +
" \"category\": \"reference\",\n" +
"\n" +
" \"author\": \"Nigel Rees\",\n" +
"\n" +
" \"title\": \"Sayings of the Century\",\n" +
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializerFeatureTest.java
5 issues
Line: 10
public class SerializerFeatureTest extends TestCase {
public void test_0 () throws Exception {
int feature = 0;
feature = SerializerFeature.config(feature, SerializerFeature.BrowserCompatible, true);
Assert.assertEquals(true, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserCompatible));
feature = SerializerFeature.config(feature, SerializerFeature.BrowserCompatible, false);
Assert.assertEquals(false, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserCompatible));
Reported by PMD.
Line: 18
Assert.assertEquals(false, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserCompatible));
}
public void test_1 () throws Exception {
int feature = 0;
feature = SerializerFeature.config(feature, SerializerFeature.BrowserSecure, true);
Assert.assertEquals(true, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserSecure));
feature = SerializerFeature.config(feature, SerializerFeature.BrowserSecure, false);
Assert.assertEquals(false, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserSecure));
Reported by PMD.
Line: 26
Assert.assertEquals(false, SerializerFeature.isEnabled(feature, SerializerFeature.BrowserSecure));
}
public void test_assert_cnt() throws Exception {
int len = SerializerFeature.values().length;
assertTrue(len <= 32);
}
}
Reported by PMD.
Line: 27
}
public void test_assert_cnt() throws Exception {
int len = SerializerFeature.values().length;
assertTrue(len <= 32);
}
}
Reported by PMD.
Line: 28
public void test_assert_cnt() throws Exception {
int len = SerializerFeature.values().length;
assertTrue(len <= 32);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/fieldbase/FieldBaseTest0.java
5 issues
Line: 14
public class FieldBaseTest0 extends TestCase {
private static SerializeConfig config = new SerializeConfig(true);
private static ParserConfig parserConfig = new ParserConfig(true);
public void test_0() throws Exception {
Model model = new Model();
model.id = 123;
assertEquals("{\"id\":123}", JSON.toJSONString(model, config));
Reported by PMD.
Line: 14
public class FieldBaseTest0 extends TestCase {
private static SerializeConfig config = new SerializeConfig(true);
private static ParserConfig parserConfig = new ParserConfig(true);
public void test_0() throws Exception {
Model model = new Model();
model.id = 123;
assertEquals("{\"id\":123}", JSON.toJSONString(model, config));
Reported by PMD.
Line: 19
Model model = new Model();
model.id = 123;
assertEquals("{\"id\":123}", JSON.toJSONString(model, config));
Model model2 = JSON.parseObject("{\"id\":123}", Model.class, parserConfig);
assertEquals(model.id, model2.id);
}
Reported by PMD.
Line: 22
assertEquals("{\"id\":123}", JSON.toJSONString(model, config));
Model model2 = JSON.parseObject("{\"id\":123}", Model.class, parserConfig);
assertEquals(model.id, model2.id);
}
public static class Model {
private int id;
}
Reported by PMD.
Line: 26
}
public static class Model {
private int id;
}
}
Reported by PMD.