The following issues were found
src/test/java/com/alibaba/json/bvt/parser/deser/list/ListStringFieldTest_stream_TreeSet.java
21 issues
Line: 17
public class ListStringFieldTest_stream_TreeSet extends TestCase {
public void test_list() throws Exception {
String text = "{\"values\":[\"a\",\"b\",\"ab\\\\c\"]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Reported by PMD.
Line: 23
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(3, model.values.size());
Assert.assertTrue(model.values.contains("a"));
Assert.assertTrue(model.values.contains("b"));
}
public void test_null() throws Exception {
Reported by PMD.
Line: 24
Model model = reader.readObject(Model.class);
Assert.assertEquals(3, model.values.size());
Assert.assertTrue(model.values.contains("a"));
Assert.assertTrue(model.values.contains("b"));
}
public void test_null() throws Exception {
String text = "{\"values\":null}";
Reported by PMD.
Line: 25
Assert.assertEquals(3, model.values.size());
Assert.assertTrue(model.values.contains("a"));
Assert.assertTrue(model.values.contains("b"));
}
public void test_null() throws Exception {
String text = "{\"values\":null}";
JSONReader reader = new JSONReader(new StringReader(text));
Reported by PMD.
Line: 28
Assert.assertTrue(model.values.contains("b"));
}
public void test_null() throws Exception {
String text = "{\"values\":null}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertNull(model.values);
}
Reported by PMD.
Line: 35
Assert.assertNull(model.values);
}
public void test_empty() throws Exception {
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(0, model.values.size());
}
Reported by PMD.
Line: 39
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(0, model.values.size());
}
public void test_map_empty() throws Exception {
String text = "{\"model\":{\"values\":[]}}";
JSONReader reader = new JSONReader(new StringReader(text));
Reported by PMD.
Line: 42
Assert.assertEquals(0, model.values.size());
}
public void test_map_empty() throws Exception {
String text = "{\"model\":{\"values\":[]}}";
JSONReader reader = new JSONReader(new StringReader(text));
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Model model = (Model) map.get("model");
Reported by PMD.
Line: 48
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Model model = (Model) map.get("model");
Assert.assertEquals(0, model.values.size());
}
public void test_notMatch() throws Exception {
String text = "{\"value\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
Reported by PMD.
Line: 51
Assert.assertEquals(0, model.values.size());
}
public void test_notMatch() throws Exception {
String text = "{\"value\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertNull(model.values);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1570.java
20 issues
Line: 10
import java.util.List;
public class Issue1570 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
Reported by PMD.
Line: 10
import java.util.List;
public class Issue1570 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
Reported by PMD.
Line: 12
public class Issue1570 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
Reported by PMD.
Line: 16
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 16
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 18
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
Reported by PMD.
Line: 19
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
Reported by PMD.
Line: 22
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 22
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/jaxrs/FastJsonProvider.java
20 issues
Line: 36
@Provider
@Consumes({MediaType.WILDCARD})
@Produces({MediaType.WILDCARD})
public class FastJsonProvider //
implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
/**
* These are classes that we never use for reading
* (never try to deserialize instances of these types).
Reported by PMD.
Line: 75
* serialization.
*/
@Context
protected Providers providers;
/**
* with fastJson config
*/
private FastJsonConfig fastJsonConfig = new FastJsonConfig();
Reported by PMD.
Line: 85
/**
* allow serialize/deserialize types in clazzes
*/
private Class<?>[] clazzes = null;
/**
* whether set PrettyFormat while exec WriteTo()
*/
private boolean pretty;
Reported by PMD.
Line: 85
/**
* allow serialize/deserialize types in clazzes
*/
private Class<?>[] clazzes = null;
/**
* whether set PrettyFormat while exec WriteTo()
*/
private boolean pretty;
Reported by PMD.
Line: 90
/**
* whether set PrettyFormat while exec WriteTo()
*/
private boolean pretty;
/**
* @return the fastJsonConfig.
* @since 1.2.11
Reported by PMD.
Line: 119
/**
* Only serialize/deserialize all types in clazzes.
*/
public FastJsonProvider(Class<?>[] clazzes) {
this.clazzes = clazzes;
}
/**
* Set pretty format
Reported by PMD.
Line: 296
String subtype = mediaType.getSubtype();
return (("json".equalsIgnoreCase(subtype)) //
|| (subtype.endsWith("+json")) //
|| ("javascript".equals(subtype)) //
|| ("x-javascript".equals(subtype)) //
|| ("x-json".equals(subtype)) //
|| ("x-www-form-urlencoded".equalsIgnoreCase(subtype)) //
|| (subtype.endsWith("x-www-form-urlencoded")));
Reported by PMD.
Line: 301
|| ("x-javascript".equals(subtype)) //
|| ("x-json".equals(subtype)) //
|| ("x-www-form-urlencoded".equalsIgnoreCase(subtype)) //
|| (subtype.endsWith("x-www-form-urlencoded")));
}
return true;
}
/**
Reported by PMD.
Line: 350
FastJsonConfig fastJsonConfig = locateConfigProvider(type, mediaType);
SerializerFeature[] serializerFeatures = fastJsonConfig.getSerializerFeatures();
if (pretty) {
if (serializerFeatures == null)
serializerFeatures = new SerializerFeature[]{SerializerFeature.PrettyFormat};
else {
Reported by PMD.
Line: 414
FastJsonConfig fastJsonConfig = locateConfigProvider(type, mediaType);
return JSON.parseObject(entityStream,
fastJsonConfig.getCharset(),
genericType,
fastJsonConfig.getParserConfig(),
fastJsonConfig.getParseProcess(),
JSON.DEFAULT_PARSER_FEATURE,
fastJsonConfig.getFeatures());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1570_private.java
20 issues
Line: 10
import java.util.List;
public class Issue1570_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
Reported by PMD.
Line: 10
import java.util.List;
public class Issue1570_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
Reported by PMD.
Line: 12
public class Issue1570_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
Model model = new Model();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
Reported by PMD.
Line: 16
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 16
assertEquals("{\"value\":\"\"}", JSON.toJSONString(model, SerializerFeature.WriteNullStringAsEmpty));
}
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 18
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
Reported by PMD.
Line: 19
public void test_for_issue_int() throws Exception {
ModelInt model = new ModelInt();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
Reported by PMD.
Line: 22
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
Line: 22
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
public void test_for_issue_long() throws Exception {
ModelLong model = new ModelLong();
assertEquals("{}", JSON.toJSONString(model, SerializerFeature.WriteNullBooleanAsFalse));
assertEquals("{\"value\":0}", JSON.toJSONString(model, SerializerFeature.WriteNullNumberAsZero));
}
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/Jackson2Codec.java
20 issues
Line: 28
try {
return mapper.readValue(text, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
Reported by PMD.
Line: 37
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
try {
Reported by PMD.
Line: 46
return (Collection<T>) mapper.readValue(text, new TypeReference<T>() {
});
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public final Object decodeObject(String text) {
try {
Reported by PMD.
Line: 54
try {
return (ObjectNode) mapper.readTree(text);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public Object decode(String text) {
try {
Reported by PMD.
Line: 62
try {
return mapper.readTree(text);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public String encode(Object object) throws Exception {
return mapper.writeValueAsString(object);
Reported by PMD.
Line: 18
public class Jackson2Codec implements Codec {
private ObjectMapper mapper = new ObjectMapper();
public String getName() {
return "jackson2";
}
Reported by PMD.
Line: 18
public class Jackson2Codec implements Codec {
private ObjectMapper mapper = new ObjectMapper();
public String getName() {
return "jackson2";
}
Reported by PMD.
Line: 27
public final <T> T decodeObject(String text, Class<T> clazz) {
try {
return mapper.readValue(text, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
Reported by PMD.
Line: 33
}
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
Reported by PMD.
Line: 36
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
try {
return mapper.readValue(input, clazz);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue998_private.java
20 issues
Line: 14
* Created by wenshao on 16/01/2017.
*/
public class Issue998_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
Reported by PMD.
Line: 14
* Created by wenshao on 16/01/2017.
*/
public class Issue998_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
Reported by PMD.
Line: 16
public class Issue998_private extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
Reported by PMD.
Line: 18
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
Reported by PMD.
Line: 18
Model model = JSON.parseObject("{\"items\":[{\"id\":123}]}", Model.class);
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
Reported by PMD.
Line: 19
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
Reported by PMD.
Line: 19
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
Reported by PMD.
Line: 19
assertNotNull(model);
assertNotNull(model.items);
assertEquals(1, model.items.size());
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
Reported by PMD.
Line: 22
assertEquals(123, model.items.get(0).getId());
String json = JSON.toJSONString(model, SerializerFeature.NotWriteRootClassName, SerializerFeature.WriteClassName);
assertEquals("{\"items\":[{\"id\":123}]}", json);
}
public void test_for_issue_1() throws Exception {
Field field = Model.class.getField("items");
List<Item> items = (List<Item> ) JSON.parseObject("[{\"id\":123}]", field.getGenericType());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_8.java
20 issues
Line: 15
public class SerializeWriterTest_8 extends TestCase {
public void test_BrowserCompatible() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 15
public class SerializeWriterTest_8 extends TestCase {
public void test_BrowserCompatible() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 20
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
}
public void test_writer() throws Exception {
Reported by PMD.
Line: 20
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
}
public void test_writer() throws Exception {
Reported by PMD.
Line: 21
buf.append('a');
}
buf.append("中国");
buf.append("\0");
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
}
public void test_writer() throws Exception {
StringBuilder buf = new StringBuilder();
Reported by PMD.
Line: 25
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
}
public void test_writer() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 25
JSON.toJSONString(buf.toString(), SerializerFeature.BrowserCompatible);
}
public void test_writer() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
Reported by PMD.
Line: 30
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
}
Reported by PMD.
Line: 30
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
}
Reported by PMD.
Line: 31
buf.append('a');
}
buf.append("中国");
buf.append("\0");
StringWriter out = new StringWriter();
JSON.writeJSONStringTo(buf.toString(), out, SerializerFeature.BrowserCompatible);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/NotWriteDefaultValueTest_NoneASM.java
20 issues
Line: 80
private static class VO_Short {
private short f0;
private short f1;
public short getF0() {
return f0;
}
Reported by PMD.
Line: 81
private static class VO_Short {
private short f0;
private short f1;
public short getF0() {
return f0;
}
Reported by PMD.
Line: 83
private short f0;
private short f1;
public short getF0() {
return f0;
}
public void setF0(short f0) {
this.f0 = f0;
Reported by PMD.
Line: 87
return f0;
}
public void setF0(short f0) {
this.f0 = f0;
}
public short getF1() {
return f1;
Reported by PMD.
Line: 91
this.f0 = f0;
}
public short getF1() {
return f1;
}
public void setF1(short f1) {
this.f1 = f1;
Reported by PMD.
Line: 95
return f1;
}
public void setF1(short f1) {
this.f1 = f1;
}
}
Reported by PMD.
Line: 12
public class NotWriteDefaultValueTest_NoneASM extends TestCase {
public void test_for_byte() throws Exception {
VO_Byte vo = new VO_Byte();
String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
Assert.assertEquals("{}", text);
}
Reported by PMD.
Line: 18
Assert.assertEquals("{}", text);
}
public void test_for_short() throws Exception {
VO_Short vo = new VO_Short();
String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
Assert.assertEquals("{}", text);
}
Reported by PMD.
Line: 24
Assert.assertEquals("{}", text);
}
public void test_for_int() throws Exception {
VO_Int vo = new VO_Int();
String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
Assert.assertEquals("{}", text);
}
Reported by PMD.
Line: 30
Assert.assertEquals("{}", text);
}
public void test_for_long() throws Exception {
VO_Long vo = new VO_Long();
String text = JSON.toJSONString(vo, SerializerFeature.NotWriteDefaultValue);
Assert.assertEquals("{}", text);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultJSONParserTest2.java
20 issues
Line: 15
public class DefaultJSONParserTest2 extends TestCase {
public void test_empty() throws Exception {
String text = "";
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
Reported by PMD.
Line: 15
public class DefaultJSONParserTest2 extends TestCase {
public void test_empty() throws Exception {
String text = "";
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
Reported by PMD.
Line: 17
public void test_empty() throws Exception {
String text = "";
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
assertNull(JSON.parseObject(text, Entity.class));
}
Reported by PMD.
Line: 18
public void test_empty() throws Exception {
String text = "";
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
assertNull(JSON.parseObject(text, Entity.class));
}
Reported by PMD.
Line: 19
String text = "";
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
assertNull(JSON.parseObject(text, Entity.class));
}
public static class Entity {
Reported by PMD.
Line: 20
assertNull(JSON.parse(text));
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
assertNull(JSON.parseObject(text, Entity.class));
}
public static class Entity {
Reported by PMD.
Line: 21
assertNull(JSON.parseObject(text));
assertNull(JSON.parseObject(text, Object.class));
assertNull(JSON.parseObject(text, Map.class));
assertNull(JSON.parseObject(text, Entity.class));
}
public static class Entity {
}
Reported by PMD.
Line: 28
}
public void test_0() throws Exception {
String text = "{}";
Map map = (Map) JSON.parse(text);
Assert.assertEquals(0, map.size());
}
Reported by PMD.
Line: 31
public void test_0() throws Exception {
String text = "{}";
Map map = (Map) JSON.parse(text);
Assert.assertEquals(0, map.size());
}
public void test_1() throws Exception {
JSONException error = null;
try {
Reported by PMD.
Line: 34
Assert.assertEquals(0, map.size());
}
public void test_1() throws Exception {
JSONException error = null;
try {
String text = "{}a";
Map map = (Map) JSON.parse(text);
Assert.assertEquals(0, map.size());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONReaderTest_object_int_unquote.java
20 issues
Line: 15
public class JSONReaderTest_object_int_unquote extends TestCase {
String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
"f5:5,f6:6,f7:7,f8:8,f9:9}";
public void test_read() throws Exception {
JSONReader reader = new JSONReader(new StringReader(text));
Reported by PMD.
Line: 18
String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
"f5:5,f6:6,f7:7,f8:8,f9:9}";
public void test_read() throws Exception {
JSONReader reader = new JSONReader(new StringReader(text));
reader.startObject();
int count = 0;
Reported by PMD.
Line: 25
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Assert.assertEquals(10, count);
Reported by PMD.
Line: 26
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Assert.assertEquals(10, count);
reader.endObject();
Reported by PMD.
Line: 35
reader.close();
}
public void test_read_1() throws Exception {
JSONReader reader = new JSONReader(new JSONScanner(text));
reader.startObject();
int count = 0;
while (reader.hasNext()) {
Reported by PMD.
Line: 41
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Assert.assertEquals(10, count);
Reported by PMD.
Line: 42
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Assert.assertEquals(10, count);
reader.endObject();
Reported by PMD.
Line: 10
import org.junit.Assert;
import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.JSONScanner;
public class JSONReaderTest_object_int_unquote extends TestCase {
String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
Reported by PMD.
Line: 23
JSONReader reader = new JSONReader(new StringReader(text));
reader.startObject();
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Reported by PMD.
Line: 25
int count = 0;
while (reader.hasNext()) {
String key = (String) reader.readObject();
Integer value = reader.readInteger();
count++;
}
Assert.assertEquals(10, count);
Reported by PMD.