The following issues were found
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest_collection.java
14 issues
Line: 54
public static class MyMap<K, V> extends HashMap {
public MyMap() {
throw new RuntimeException();
}
}
}
Reported by PMD.
Line: 14
public class DefaultObjectDeserializerTest_collection extends TestCase {
public void test_0() throws Exception {
String input = "[{}]";
List<HashMap> map = JSON.parseObject(input,
new TypeReference<List<HashMap>>() {
}.getType());
Reported by PMD.
Line: 21
new TypeReference<List<HashMap>>() {
}.getType());
Assert.assertEquals(HashMap.class, map.get(0).getClass());
}
public void test_1() throws Exception {
String input = "{}";
Reported by PMD.
Line: 21
new TypeReference<List<HashMap>>() {
}.getType());
Assert.assertEquals(HashMap.class, map.get(0).getClass());
}
public void test_1() throws Exception {
String input = "{}";
Reported by PMD.
Line: 24
Assert.assertEquals(HashMap.class, map.get(0).getClass());
}
public void test_1() throws Exception {
String input = "{}";
BO<HashMap> map = JSON.parseObject(input,
new TypeReference<BO<HashMap>>() {
}.getType());
Reported by PMD.
Line: 24
Assert.assertEquals(HashMap.class, map.get(0).getClass());
}
public void test_1() throws Exception {
String input = "{}";
BO<HashMap> map = JSON.parseObject(input,
new TypeReference<BO<HashMap>>() {
}.getType());
Reported by PMD.
Line: 27
public void test_1() throws Exception {
String input = "{}";
BO<HashMap> map = JSON.parseObject(input,
new TypeReference<BO<HashMap>>() {
}.getType());
}
public void test_2() throws Exception {
Reported by PMD.
Line: 32
}.getType());
}
public void test_2() throws Exception {
Exception error = null;
try {
String input = "{'map':{}}";
Reported by PMD.
Line: 38
try {
String input = "{'map':{}}";
MyMap<String, HashMap> map = JSON.parseObject(input,
new TypeReference<MyMap<String, HashMap>>() {
}.getType());
} catch (Exception ex) {
error = ex;
}
Reported by PMD.
Line: 41
MyMap<String, HashMap> map = JSON.parseObject(input,
new TypeReference<MyMap<String, HashMap>>() {
}.getType());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
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/serializer/ConcurrentHashMapTest7.java
14 issues
Line: 18
public class ConcurrentHashMapTest7 extends TestCase {
public void test_concurrentHashmap() throws Exception {
OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
wrapper.getOffsetTable().put(new MessageQueue(), new SoftReference<A>(new A(true)));
String text = JSON.toJSONString(wrapper);
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
Reported by PMD.
Line: 25
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
Reported by PMD.
Line: 25
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 30
Iterator<Map.Entry<MessageQueue, SoftReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, SoftReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
private ConcurrentHashMap<MessageQueue, SoftReference<A>> offsetTable = new ConcurrentHashMap<MessageQueue, SoftReference<A>>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue869.java
14 issues
Line: 15
* Created by wenshao on 2016/10/19.
*/
public class Issue869 extends TestCase {
public void test_for_issue() throws Exception {
List<DoublePoint> doublePointList = new ArrayList<DoublePoint>();
{
DoublePoint doublePoint = new DoublePoint();
doublePoint.startPoint = new Point(22, 35);
doublePoint.endPoint = doublePoint.startPoint;
Reported by PMD.
Line: 31
}
String json = JSON.toJSONString(doublePointList);
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
Reported by PMD.
Line: 34
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 34
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 38
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
Reported by PMD.
Line: 39
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 41
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
public Point endPoint;
Reported by PMD.
src/test/java/com/alibaba/fastjson/serializer/SerializeWriterTest.java
14 issues
Line: 19
public class SerializeWriterTest {
private final Logger logger = Logger.getLogger(SerializeWriterTest.class.getSimpleName());
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final SerializeWriter writer = new SerializeWriter(new OutputStreamWriter(baos));
Reported by PMD.
Line: 19
public class SerializeWriterTest {
private final Logger logger = Logger.getLogger(SerializeWriterTest.class.getSimpleName());
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final SerializeWriter writer = new SerializeWriter(new OutputStreamWriter(baos));
Reported by PMD.
Line: 21
private final Logger logger = Logger.getLogger(SerializeWriterTest.class.getSimpleName());
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final SerializeWriter writer = new SerializeWriter(new OutputStreamWriter(baos));
@Before
public void setUp() throws Exception {
Reported by PMD.
Line: 23
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final SerializeWriter writer = new SerializeWriter(new OutputStreamWriter(baos));
@Before
public void setUp() throws Exception {
}
Reported by PMD.
Line: 34
}
@Test
public void testWriteLiteBasicStr() throws UnsupportedEncodingException {
String targetStr = new String(IOUtils.DIGITS);
this.doTestWrite(targetStr);
}
private String doTestWrite(String input) throws UnsupportedEncodingException {
Reported by PMD.
Line: 52
}
@Test
public void testWriteLiteSpecilaStr() throws UnsupportedEncodingException {
this.doTestWrite(this.makeSpecialChars());
}
private String makeSpecialChars() {
StringBuilder strBuilder = new StringBuilder(128);
Reported by PMD.
Line: 65
}
@Test
public void testWriteLargeBasicStr() throws UnsupportedEncodingException {
String str = createLargeBasicStr();
this.doTestWrite(str);
}
private String createLargeBasicStr() {
Reported by PMD.
Line: 80
}
@Test
public void testWriteLargeSpecialStr() throws UnsupportedEncodingException {
String tmp = this.makeSpecialChars();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 200; i++) {
builder.append(tmp);
Reported by PMD.
Line: 91
}
@Test
public void test_large() throws Exception {
SerializeWriter writer = new SerializeWriter();
for (int i = 0; i < 1024 * 1024; ++i) {
writer.write(i);
}
Reported by PMD.
Line: 113
//检查bytesLocal大小,如果缓存成功应该大于等于输出的bytes长度
Field bytesBufLocalField = SerializeWriter.class.getDeclaredField("bytesBufLocal");
bytesBufLocalField.setAccessible(true);
ThreadLocal<byte[]> bytesBufLocal = (ThreadLocal<byte[]>) bytesBufLocalField.get(null);
byte[] bytesLocal = bytesBufLocal.get();
Assert.assertNotNull("bytesLocal is null", bytesLocal);
Assert.assertTrue("bytesLocal is smaller than expected", bytesLocal.length >= bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/AbstractSerializeTest2.java
14 issues
Line: 13
public class AbstractSerializeTest2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
}
protected void tearDown() throws Exception {
Reported by PMD.
Line: 14
public class AbstractSerializeTest2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
Reported by PMD.
Line: 15
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
Reported by PMD.
Line: 18
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";
Reported by PMD.
Line: 19
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";
Reported by PMD.
Line: 22
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
}
Reported by PMD.
Line: 29
Assert.assertNotNull(b);
}
public void test_mapping_1() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":123}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(123, b.getId());
Reported by PMD.
Line: 34
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(123, b.getId());
}
public void test_mapping_2() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":234,\"name\":\"abc\"}";
Reported by PMD.
Line: 37
Assert.assertEquals(123, b.getId());
}
public void test_mapping_2() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":234,\"name\":\"abc\"}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(234, b.getId());
Reported by PMD.
Line: 42
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(234, b.getId());
Assert.assertEquals("abc", b.getName());
}
public void test_mapping_group() throws Exception {
String text = "{\"a\":{\"id\":234,\"name\":\"abc\"}}";
Reported by PMD.
src/test/java/com/alibaba/json/test/InnerInnerTest.java
14 issues
Line: 10
import junit.framework.TestCase;
class Outter{
private String name;
private InnerInner ii;
public String getName() {
return name;
Reported by PMD.
Line: 50
public class InnerInnerTest extends TestCase{//深层内部类的序列化反序列化测试
public void testDeserialize(){//
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
Reported by PMD.
Line: 50
public class InnerInnerTest extends TestCase{//深层内部类的序列化反序列化测试
public void testDeserialize(){//
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
Reported by PMD.
Line: 53
public void testDeserialize(){//
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Reported by PMD.
Line: 53
public void testDeserialize(){//
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Reported by PMD.
Line: 54
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Inner i = o.new Inner();
Reported by PMD.
Line: 54
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Inner i = o.new Inner();
Reported by PMD.
Line: 54
String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
Outter o = JSON.parseObject(json, Outter.class);
assertEquals("ocls", o.getName());
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Inner i = o.new Inner();
Reported by PMD.
Line: 57
assertEquals("iicls", o.getIi().getName());
}
public void testSerialize(){
Outter o = new Outter();
Inner i = o.new Inner();
InnerInner ii = i.new InnerInner();
ii.setName("iicls");
o.setIi(ii);
Reported by PMD.
Line: 68
assertEquals("{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}", json);
}
public void testGson(){
Outter o = new Outter();
Inner i = o.new Inner();
InnerInner ii = i.new InnerInner();
ii.setName("iicls");
o.setIi(ii);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/ASMDeserTest.java
14 issues
Line: 67
public static class EntityError extends ArrayList<String> {
public EntityError(){
throw new RuntimeException();
}
}
}
Reported by PMD.
Line: 12
public class ASMDeserTest extends TestCase {
public void test_codec() throws Exception {
String text = JSON.toJSONString(new Entity());
Assert.assertEquals("[]", text);
Entity object = JSON.parseObject(text, Entity.class);
Reported by PMD.
Line: 18
Assert.assertEquals("[]", text);
Entity object = JSON.parseObject(text, Entity.class);
Assert.assertEquals(0, object.size());
}
public void test_codec_1() throws Exception {
String text = JSON.toJSONString(new VO());
Reported by PMD.
Line: 21
Assert.assertEquals(0, object.size());
}
public void test_codec_1() throws Exception {
String text = JSON.toJSONString(new VO());
Assert.assertEquals("{\"value\":[]}", text);
VO object = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 27
Assert.assertEquals("{\"value\":[]}", text);
VO object = JSON.parseObject(text, VO.class);
Assert.assertEquals(0, object.getValue().size());
}
public void test_ArrayList() throws Exception {
ArrayList object = JSON.parseObject("[]", ArrayList.class);
Reported by PMD.
Line: 27
Assert.assertEquals("{\"value\":[]}", text);
VO object = JSON.parseObject(text, VO.class);
Assert.assertEquals(0, object.getValue().size());
}
public void test_ArrayList() throws Exception {
ArrayList object = JSON.parseObject("[]", ArrayList.class);
Reported by PMD.
Line: 30
Assert.assertEquals(0, object.getValue().size());
}
public void test_ArrayList() throws Exception {
ArrayList object = JSON.parseObject("[]", ArrayList.class);
Assert.assertEquals(0, object.size());
}
Reported by PMD.
Line: 32
public void test_ArrayList() throws Exception {
ArrayList object = JSON.parseObject("[]", ArrayList.class);
Assert.assertEquals(0, object.size());
}
public void test_error() throws Exception {
Exception error = null;
Reported by PMD.
Line: 33
public void test_ArrayList() throws Exception {
ArrayList object = JSON.parseObject("[]", ArrayList.class);
Assert.assertEquals(0, object.size());
}
public void test_error() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 36
Assert.assertEquals(0, object.size());
}
public void test_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("[]", EntityError.class);
} catch (Exception ex) {
error = ex;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/ConcurrentHashMapTest4.java
14 issues
Line: 18
public class ConcurrentHashMapTest4 extends TestCase {
public void test_concurrentHashmap() throws Exception {
OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
wrapper.getOffsetTable().put(new MessageQueue(), new AtomicReference<A>(new A(true)));
String text = JSON.toJSONString(wrapper);
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
Reported by PMD.
Line: 25
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
Reported by PMD.
Line: 25
Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 27
OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
Assert.assertEquals(1, wrapper2.getOffsetTable().size());
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 29
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
Reported by PMD.
Line: 30
Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
Assert.assertEquals(0, entry.getKey().getItems().size());
Assert.assertEquals(true, entry.getValue().get().isValue());
}
public static class OffsetSerializeWrapper {
private ConcurrentHashMap<MessageQueue, AtomicReference<A>> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicReference<A>>();
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.