dev --- 3.8.0.A版本, openProject引用 ; formao-live --- 3.7.0.B 版本, formallProject引用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 line
1.0 KiB

  1. package chanjarster.weixin.bean;
  2. import org.testng.Assert;
  3. import org.testng.annotations.Test;
  4. import chanjarster.weixin.bean.WxError;
  5. @Test
  6. public class WxErrorTest {
  7. public void testFromJson() {
  8. String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
  9. WxError wxError = WxError.fromJson(json);
  10. Assert.assertTrue(wxError.getErrcode() == 40003);
  11. Assert.assertEquals(wxError.getErrmsg(), "invalid openid");
  12. }
  13. public void testFromBadJson1() {
  14. String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
  15. WxError wxError = WxError.fromJson(json);
  16. Assert.assertTrue(wxError.getErrcode() == 40003);
  17. Assert.assertEquals(wxError.getErrmsg(), "invalid openid");
  18. }
  19. public void testFromBadJson2() {
  20. String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
  21. WxError wxError = WxError.fromJson(json);
  22. Assert.assertTrue(wxError.getErrcode() == 0);
  23. Assert.assertEquals(wxError.getErrmsg(), null);
  24. }
  25. }