Skip to content

Commit 0563ed2

Browse files
committed
add test
1 parent e2bf1d6 commit 0563ed2

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.alibaba.json.bvt;
2+
3+
import junit.framework.Assert;
4+
import junit.framework.TestCase;
5+
6+
import com.alibaba.fastjson.JSON;
7+
import com.alibaba.fastjson.annotation.JSONField;
8+
9+
public class AnnotationTest3 extends TestCase {
10+
11+
public void test_supperField() throws Exception {
12+
C c = new C();
13+
c.setId(123);
14+
c.setName("jobs");
15+
16+
String str = JSON.toJSONString(c);
17+
Assert.assertEquals("{\"ID\":123,\"name\":\"jobs\"}", str);
18+
}
19+
20+
public static class S {
21+
22+
@JSONField(name = "ID")
23+
private int id;
24+
25+
public int getId() {
26+
return id;
27+
}
28+
29+
public void setId(int id) {
30+
this.id = id;
31+
}
32+
33+
}
34+
35+
public static class C extends S {
36+
37+
private String name;
38+
39+
public String getName() {
40+
return name;
41+
}
42+
43+
public void setName(String name) {
44+
this.name = name;
45+
}
46+
47+
}
48+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.alibaba.json.bvt.bug;
2+
3+
import junit.framework.TestCase;
4+
5+
import com.alibaba.fastjson.JSON;
6+
import com.alibaba.fastjson.serializer.SerializerFeature;
7+
8+
public class Bug_for_qqdwll2012 extends TestCase {
9+
10+
public void test_for_x() throws Exception {
11+
VO vo = new VO();
12+
vo.setValue("<a href=\"http://www.baidu.com\"> 问题链接 </a> |");
13+
14+
String text = JSON.toJSONString(vo, SerializerFeature.WriteSlashAsSpecial);
15+
System.out.println(text);
16+
}
17+
18+
public static class VO {
19+
20+
private String value;
21+
22+
public String getValue() {
23+
return value;
24+
}
25+
26+
public void setValue(String value) {
27+
this.value = value;
28+
}
29+
30+
}
31+
}

0 commit comments

Comments
 (0)