/src/test/java/com/alibaba/json/bvt/bug/Bug_for_rd.java

https://github.com/alibaba/fastjson · Java · 94 lines · 76 code · 18 blank · 0 comment · 0 complexity · 0301ae1c5912956872474d4cf81c86bd MD5 · raw file

  1. package com.alibaba.json.bvt.bug;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import junit.framework.TestCase;
  5. import java.util.concurrent.TimeUnit;
  6. public class Bug_for_rd extends TestCase {
  7. public void test_for_issue() throws Exception {
  8. String json = "{ \"sitePayId\": \"2019071889031100000152604119889\", \"extendInfo\": \"{\\\"saveAsset\\\":\\\"false\\\",\\\"acquirementId\\\":\\\"20190718194010800100177150204979354\\\",\\\"orderTerminalType\\\":\\\"WEB\\\",\\\"acqSiteUserId\\\":\\\"2177220032166157\\\",\\\"siteReqBizId\\\":\\\"111023437\\\",\\\"msisdn\\\":\\\"01966114400\\\",\\\"originalMerchantOrderId\\\":\\\"602109378031994\\\"}\", \"netPayId\": \"2019071819039101720000454701\", \"resultInfo\": { \"resultCode\": \"SUCCESS\", \"resultCodeId\": \"00000000\", \"resultMsg\": \"Success\", \"resultStatus\": \"S\" } }";
  9. PayResponse object = JSON.parseObject(json, PayResponse.class);
  10. String extendInfo = object.getExtendInfo();
  11. assertEquals(object.getExtendInfo(), JSON.parseObject(json).get("extendInfo"));
  12. }
  13. public void test_for_issue_1() throws Exception {
  14. String json = "{\"unit\": \"MINUTES\"}";
  15. V1 v = JSON.parseObject(json, V1.class);
  16. assertEquals(TimeUnit.MINUTES, v.unit);
  17. }
  18. public void test_for_issue_2() throws Exception {
  19. String json = "{\"sitePayId\": \"MINUTES\"}";
  20. V1 v = JSON.parseObject(json, V1.class);
  21. assertEquals("MINUTES", v.sitePayId);
  22. }
  23. public void test_for_issue_3() throws Exception {
  24. String json = "{\"sitePayId\": \"MINUTES\\\"A\"}";
  25. V1 v = JSON.parseObject(json, V1.class);
  26. assertEquals("MINUTES\"A", v.sitePayId);
  27. }
  28. public void test_for_issue_4() throws Exception {
  29. String json = "{ \"sitePayId\": \"MINUTES\\\"A\"}";
  30. V1 v = JSON.parseObject(json, V1.class);
  31. assertEquals("MINUTES\"A", v.sitePayId);
  32. }
  33. public void test_for_issue_5() throws Exception {
  34. String json = "{ \"sitePayId\": \"\\\"A\"}";
  35. V1 v = JSON.parseObject(json, V1.class);
  36. assertEquals("\"A", v.sitePayId);
  37. }
  38. public void test_for_issue_6() throws Exception {
  39. String json = "{ \"sitePayId\": \"S\"}";
  40. V1 v = JSON.parseObject(json, V1.class);
  41. assertEquals("S", v.sitePayId);
  42. }
  43. public static class PayResponse {
  44. private String sitePayId;
  45. private String extendInfo;
  46. private String netPayId;
  47. public String getSitePayId()
  48. {
  49. return sitePayId;
  50. }
  51. public void setSitePayId(String sitePayId)
  52. {
  53. this.sitePayId = sitePayId;
  54. }
  55. public String getExtendInfo()
  56. {
  57. return extendInfo;
  58. }
  59. public void setExtendInfo(String extendInfo)
  60. {
  61. this.extendInfo = extendInfo;
  62. }
  63. public String getNetPayId()
  64. {
  65. return netPayId;
  66. }
  67. public void setNetPayId(String netPayId)
  68. {
  69. this.netPayId = netPayId;
  70. }
  71. }
  72. public static class V1 {
  73. public String sitePayId;
  74. public TimeUnit unit;
  75. }
  76. }