The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Bug_for_42283905.java
13 issues
Line: 46
text = JSON.toJSONString(groups);
}
System.out.println(text);
List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
});
Group g0 = groups.get(0);
Group g1 = groups.get(1);
Reported by PMD.
Line: 53
Group g0 = groups.get(0);
Group g1 = groups.get(1);
System.out.println(JSON.toJSONString(groups));
}
public static class Group {
private String name;
Reported by PMD.
Line: 13
public class Bug_for_42283905 extends TestCase {
public void test_0() throws Exception {
String text;
{
List<Group> groups = new ArrayList<Group>();
Reported by PMD.
Line: 13
public class Bug_for_42283905 extends TestCase {
public void test_0() throws Exception {
String text;
{
List<Group> groups = new ArrayList<Group>();
Reported by PMD.
Line: 28
{
Group group = new Group("g0");
group.getBattleCommandList().add(c0);
groups.add(group);
}
{
Group group = new Group("g1");
Reported by PMD.
Line: 34
{
Group group = new Group("g1");
group.getBattleCommandList().add(c1);
groups.add(group);
}
{
Group group = new Group("g2");
Reported by PMD.
Line: 40
{
Group group = new Group("g2");
group.getBattleCommandList().add(c2);
groups.add(group);
}
text = JSON.toJSONString(groups);
}
Reported by PMD.
Line: 50
List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
});
Group g0 = groups.get(0);
Group g1 = groups.get(1);
System.out.println(JSON.toJSONString(groups));
}
Reported by PMD.
Line: 51
List<Group> groups = JSON.parseObject(text, new TypeReference<List<Group>>() {
});
Group g0 = groups.get(0);
Group g1 = groups.get(1);
System.out.println(JSON.toJSONString(groups));
}
public static class Group {
Reported by PMD.
Line: 56
System.out.println(JSON.toJSONString(groups));
}
public static class Group {
private String name;
private List<Command> battleCommandList = new ArrayList<Command>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/StrictAutoTypeTest_0.java
13 issues
Line: 10
import junit.framework.TestCase;
public class StrictAutoTypeTest_0 extends TestCase {
private ParserConfig config = new ParserConfig();
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class StrictAutoTypeTest_0 extends TestCase {
private ParserConfig config = new ParserConfig();
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
Reported by PMD.
Line: 12
public class StrictAutoTypeTest_0 extends TestCase {
private ParserConfig config = new ParserConfig();
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 12
public class StrictAutoTypeTest_0 extends TestCase {
private ParserConfig config = new ParserConfig();
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config);
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 17
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_1() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_2() throws Exception {
{
Reported by PMD.
Line: 17
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.JSONObject\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_1() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_2() throws Exception {
{
Reported by PMD.
Line: 21
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_2() throws Exception {
{
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);
} catch (JSONException ex) {
Reported by PMD.
Line: 21
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$VO\"}", Object.class, config, Feature.SupportAutoType);
}
public void test_2() throws Exception {
{
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);
} catch (JSONException ex) {
Reported by PMD.
Line: 29
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
{
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.writeClassName.StrictAutoTypeTest_0$V1\"}", Object.class, config);
Reported by PMD.
Line: 38
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
}
public void test_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE | Feature.SupportAutoType.mask;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_long.java
13 issues
Line: 15
public class NameFilterTest_long extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 31
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 40
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 55
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 65
Assert.assertEquals("{\"ID\":0}", text);
}
public static class Bean {
private long id;
private String name;
public long getId() {
Reported by PMD.
Line: 16
public class NameFilterTest_long extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Map.java
13 issues
Line: 17
public class WriteClassNameTest_Map extends TestCase {
public void test_list() throws Exception {
Model model = new Model();
Map tables = new LinkedHashMap();
tables.put("1001", new ExtTable(1001));
tables.put("1002", new Table());
model.setTables(tables);
Reported by PMD.
Line: 17
public class WriteClassNameTest_Map extends TestCase {
public void test_list() throws Exception {
Model model = new Model();
Map tables = new LinkedHashMap();
tables.put("1001", new ExtTable(1001));
tables.put("1002", new Table());
model.setTables(tables);
Reported by PMD.
Line: 25
model.setTables(tables);
String json = JSON.toJSONString(model);
assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
Reported by PMD.
Line: 28
assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
Reported by PMD.
Line: 28
assertEquals("{\"tables\":{\"1001\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Map$ExtTable\",\"id\":1001},\"1002\":{}}}", json);
JSONObject jsonObject = JSON.parseObject(json, Feature.IgnoreAutoType);
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
Reported by PMD.
Line: 31
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private Map<String, ? extends Table> tables;
Reported by PMD.
Line: 31
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private Map<String, ? extends Table> tables;
Reported by PMD.
Line: 31
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private Map<String, ? extends Table> tables;
Reported by PMD.
Line: 31
assertEquals("{\"tables\":{\"1002\":{},\"1001\":{\"id\":1001}}}", jsonObject.toJSONString());
Model model2 = JSON.parseObject(json, Model.class);
assertEquals(ExtTable.class, model2.getTables().get("1001").getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
private Map<String, ? extends Table> tables;
Reported by PMD.
Line: 52
}
public static class ExtTable extends Table {
public int id;
public ExtTable() {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_float.java
13 issues
Line: 15
public class NameFilterTest_float extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 30
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 39
Assert.assertEquals("{\"ID\":0.0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 54
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 64
Assert.assertEquals("{\"ID\":0}", text);
}
public static class Bean {
private float id;
private String name;
public float getId() {
Reported by PMD.
Line: 16
public class NameFilterTest_float extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/array/BeanToArrayAutoTypeTest3.java
13 issues
Line: 12
public class BeanToArrayAutoTypeTest3
extends TestCase {
public void test_beanToArray() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Reported by PMD.
Line: 14
extends TestCase {
public void test_beanToArray() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
Reported by PMD.
Line: 14
extends TestCase {
public void test_beanToArray() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
Reported by PMD.
Line: 14
extends TestCase {
public void test_beanToArray() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\"]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
Reported by PMD.
Line: 17
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
Reported by PMD.
Line: 17
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
}
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
Reported by PMD.
Line: 19
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
@JSONType(typeName = "Log")
public static class LogSourceMeta extends MapTaskMeta {
Reported by PMD.
Line: 19
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
@JSONType(typeName = "Log")
public static class LogSourceMeta extends MapTaskMeta {
Reported by PMD.
Line: 19
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
@JSONType(typeName = "Log")
public static class LogSourceMeta extends MapTaskMeta {
Reported by PMD.
Line: 20
public void test_beanToArray1() throws Exception {
Topology topology = JSON.parseObject("{\"maps\":[[\"@type\":\"Log\",123]]}", Topology.class);
assertEquals(LogSourceMeta.class, topology.maps.get(0).getClass());
assertEquals(123, ((LogSourceMeta) topology.maps.get(0)).id);
}
@JSONType(typeName = "Log")
public static class LogSourceMeta extends MapTaskMeta {
public int id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_short_field.java
13 issues
Line: 72
public static class Bean {
public short id;
public String name;
}
}
Reported by PMD.
Line: 16
public class NameFilterTest_short_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (value != null) {
Assert.assertTrue(value instanceof Short);
Reported by PMD.
Line: 24
Assert.assertTrue(value instanceof Short);
}
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 24
Assert.assertTrue(value instanceof Short);
}
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 35
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 44
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Short);
Reported by PMD.
Line: 48
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Short);
return "ID";
}
return name;
Reported by PMD.
Line: 48
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Short);
return "ID";
}
return name;
Reported by PMD.
Line: 60
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", (short) 0);
serializer.write(map);
Reported by PMD.
Line: 17
public class NameFilterTest_short_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (value != null) {
Assert.assertTrue(value instanceof Short);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_int.java
13 issues
Line: 15
public class NameFilterTest_int extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
}
return name;
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
}
return name;
Reported by PMD.
Line: 31
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 40
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 55
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 65
Assert.assertEquals("{\"ID\":0}", text);
}
public static class Bean {
private int id;
private String name;
public int getId() {
Reported by PMD.
Line: 16
public class NameFilterTest_int extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_wangran.java
13 issues
Line: 17
public class Bug_for_wangran extends TestCase {
public void test_for_wangran() throws Exception {
String resource = "json/wangran.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));
Reported by PMD.
Line: 19
public void test_for_wangran() throws Exception {
String resource = "json/wangran.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));
QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
Reported by PMD.
Line: 19
public void test_for_wangran() throws Exception {
String resource = "json/wangran.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));
QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
Reported by PMD.
Line: 19
public void test_for_wangran() throws Exception {
String resource = "json/wangran.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
String text = IOUtils.toString(new InputStreamReader(is,"UTF-8"));
QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
Reported by PMD.
Line: 26
QueueEntity qe = JSON.parseObject(text, QueueEntity.class);
Assert.assertNotNull(qe);
Assert.assertNotNull(qe.getPhysicalQueueMap());
Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
q.getInRate();
Assert.assertEquals(qe, q.getQueue());
Reported by PMD.
Line: 27
Assert.assertNotNull(qe);
Assert.assertNotNull(qe.getPhysicalQueueMap());
Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
q.getInRate();
Assert.assertEquals(qe, q.getQueue());
}
Reported by PMD.
Line: 27
Assert.assertNotNull(qe);
Assert.assertNotNull(qe.getPhysicalQueueMap());
Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
q.getInRate();
Assert.assertEquals(qe, q.getQueue());
}
Reported by PMD.
Line: 29
Assert.assertNotNull(qe.getPhysicalQueueMap());
Assert.assertEquals(4, qe.getPhysicalQueueMap().size());
for (PhysicalQueue q : qe.getPhysicalQueueMap().values()) {
q.getInRate();
Assert.assertEquals(qe, q.getQueue());
}
Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());
Reported by PMD.
Line: 34
Assert.assertEquals(qe, q.getQueue());
}
Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());
Assert.assertEquals(true, qe.getPhysicalQueueMap() == qe.getPqMap());
Assert.assertEquals("amq", qe.getDescription());
}
}
Reported by PMD.
Line: 34
Assert.assertEquals(qe, q.getQueue());
}
Assert.assertEquals(qe.getPhysicalQueueMap(), qe.getPqMap());
Assert.assertEquals(true, qe.getPhysicalQueueMap() == qe.getPqMap());
Assert.assertEquals("amq", qe.getDescription());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_char.java
13 issues
Line: 15
public class NameFilterTest_char extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Reported by PMD.
Line: 20
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Character);
return "ID";
}
return name;
Reported by PMD.
Line: 20
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Character);
return "ID";
}
return name;
Reported by PMD.
Line: 32
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 41
Assert.assertEquals("{\"ID\":\"0\"}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 45
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 45
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 56
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", '0');
serializer.write(map);
Reported by PMD.
Line: 66
Assert.assertEquals("{\"ID\":\"0\"}", text);
}
public static class Bean {
private char id = '0';
private String name;
public char getId() {
Reported by PMD.
Line: 16
public class NameFilterTest_char extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Character);
Reported by PMD.