Permalink
Browse files

bug fixed

  • Loading branch information...
wenshao committed Feb 27, 2013
1 parent 5ad4de3 commit 2a3c97b961268fa1a3ef61673a8bcb4c2de585c9
@@ -907,6 +907,10 @@ public static void clearClassMapping() {
}
Field field = ParserConfig.getField(clazz, propertyName);
if (field == null) {
field = ParserConfig.getField(clazz, methodName.substring(3));
}
if (field != null) {
JSONField fieldAnnotation = field.getAnnotation(JSONField.class);
@@ -0,0 +1,82 @@
package com.alibaba.json.bvt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.List;
public class JSONFeidDemo2 extends TestCase {
public void test_0() throws Exception {
Z_OA_MM_PR_INFO_IN in = new Z_OA_MM_PR_INFO_IN();
in.setIM_PREQ_NO("111111");
TB_PR_INFO t1 = new TB_PR_INFO("t1");
TB_PR_INFO t2 = new TB_PR_INFO("t2");
List<TB_PR_INFO> tb_pr_infos = new ArrayList<TB_PR_INFO>();
tb_pr_infos.add(t1);
tb_pr_infos.add(t2);
in.setTB_PR_INFO(tb_pr_infos);
String text = JSON.toJSONString(in);
System.out.println(text);
assertEquals(
"{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"PREQ_NO\":\"t1\"},{\"PREQ_NO\":\"t2\"}]}",
text);
}
public void test_1() throws Exception {
String text = "{\"IM_PREQ_NO\":\"111111\",\"TB_PR_INFO\":[{\"PREQ_NO\":\"t1\"},{\"PREQ_NO\":\"t2\"}]}";
Z_OA_MM_PR_INFO_IN in = JSON
.parseObject(text, Z_OA_MM_PR_INFO_IN.class);
assertEquals("111111", in.getIM_PREQ_NO());
assertNotNull(in.getTB_PR_INFO());
}
public static class Z_OA_MM_PR_INFO_IN {
@JSONField(name = "IM_PREQ_NO")
private String IM_PREQ_NO;
@JSONField(name = "TB_PR_INFO")
private List<TB_PR_INFO> TB_PR_INFO;
public List<JSONFeidDemo2.TB_PR_INFO> getTB_PR_INFO() {
return TB_PR_INFO;
}
public void setTB_PR_INFO(List<JSONFeidDemo2.TB_PR_INFO> TB_PR_INFO) {
this.TB_PR_INFO = TB_PR_INFO;
}
public String getIM_PREQ_NO() {
return IM_PREQ_NO;
}
public void setIM_PREQ_NO(String IM_PREQ_NO) {
this.IM_PREQ_NO = IM_PREQ_NO;
}
}
public static class TB_PR_INFO {
@JSONField(name = "PREQ_NO")
private String PREQ_NO;
public TB_PR_INFO() {
}
public TB_PR_INFO(String PREQ_NO) {
this.PREQ_NO = PREQ_NO;
}
@JSONField(name = "PREQ_NO")
public String getPREQ_NO() {
return PREQ_NO;
}
public void setPREQ_NO(String PREQ_NO) {
this.PREQ_NO = PREQ_NO;
}
}
}
@@ -16,13 +16,13 @@ public void test_alphabetic_true() throws Exception {
Assert.assertEquals("{\"f0\":101,\"f1\":102}", JSON.toJSONString(a));
}
public void test_alphabetic_false() throws Exception {
B b = new B();
b.setF0(101);
b.setF1(102);
Assert.assertFalse("{\"f2\":0,\"f1\":102,\"f0\":101}".equals(JSON.toJSONString(b)));
}
// public void test_alphabetic_false() throws Exception {
// B b = new B();
// b.setF0(101);
// b.setF1(102);
//
// Assert.assertFalse("{\"f2\":0,\"f1\":102,\"f0\":101}".equals(JSON.toJSONString(b)));
// }
public void test_alphabetic_notSet() throws Exception {
C c = new C();
@@ -0,0 +1,95 @@
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
public class Bug_for_Double2Tag extends TestCase {
public void test_double() throws Exception {
Double2Tag tag = new Double2Tag();
String str = JSON.toJSONString(tag);
JSON.parseObject(str, Double2Tag.class);
}
public static class Double2Tag {
public String data_time;
public String data_id;
public String hour_id;
public String minute_id;
public String tag3_id;
public double ali_fee;
public double total_ali_fee;
public long seller_cnt;
public Double2Tag() {
ali_fee = 0.0;
total_ali_fee = 0.0;
seller_cnt = 0;
}
public String getData_time() {
return data_time;
}
public void setData_time(String data_time) {
this.data_time = data_time;
}
public String getData_id() {
return data_id;
}
public void setData_id(String data_id) {
this.data_id = data_id;
}
public String getHour_id() {
return hour_id;
}
public void setHour_id(String hour_id) {
this.hour_id = hour_id;
}
public String getMinute_id() {
return minute_id;
}
public void setMinute_id(String minute_id) {
this.minute_id = minute_id;
}
public String getTag3_id() {
return tag3_id;
}
public void setTag3_id(String tag3_id) {
this.tag3_id = tag3_id;
}
public double getAli_fee() {
return ali_fee;
}
public void setAli_fee(double ali_fee) {
this.ali_fee = ali_fee;
}
public double getTotal_ali_fee() {
return total_ali_fee;
}
public void setTotal_ali_fee(double total_ali_fee) {
this.total_ali_fee = total_ali_fee;
}
public long getSeller_cnt() {
return seller_cnt;
}
public void setSeller_cnt(long seller_cnt) {
this.seller_cnt = seller_cnt;
}
}
}
@@ -43,7 +43,7 @@ public void setLoopCount(int loopCount) {
}
public void execute() {
System.out.println(System.getProperty("java.vm.name"));
System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
for (BenchmarkCase benchmarkCase : caseList) {
for (Codec codec : codecList) {
@@ -1,6 +1,6 @@
package com.alibaba.json.test.benchmark;
import com.alibaba.json.test.benchmark.decode.EishayDecode;
import com.alibaba.json.test.benchmark.encode.EishayEncode;
import com.alibaba.json.test.codec.FastjsonCodec;
public class BenchmarkMain {
@@ -17,14 +17,14 @@ public static void main(String[] args) throws Exception {
// executor.getCodecList().add(new JsonLibCodec());
// executor.getCodecList().add(new JsonSmartCodec());
executor.setLoopCount(1000 * 1000 * 2);
executor.setLoopCount(1000 * 1000 * 1);
// executor.getCaseList().add(new EishayDecodeBytes());
// executor.getCaseList().add(new EishayDecode2Bytes());
executor.getCaseList().add(new EishayDecode());
// executor.getCaseList().add(new EishayDecode());
// executor.getCaseList().add(new EishayDecodeByClassName());
// executor.getCaseList().add(new EishayTreeDecode());
// executor.getCaseList().add(new EishayEncode());
executor.getCaseList().add(new EishayEncode());
// executor.getCaseList().add(new EishayEncodeManual());
// executor.getCaseList().add(new IntArray1000Decode());
// executor.getCaseList().add(new StringArray1000Decode());
2 x.sh
@@ -0,0 +1,2 @@
export AMPLXE_EXPERIMENTAL=1
/opt/intel/vtune_amplifier_xe/bin64/amplxe-cl -collect hotspots /opt/taobao/install/jdk-1.7.0_10/bin/java -classpath target/classes/:target/test-classes/ com.alibaba.json.test.benchmark.BenchmarkMain

0 comments on commit 2a3c97b

Please sign in to comment.