Search in sources :

Example 6 with ErrorEntity

use of com.guhanjie.weixin.model.ErrorEntity in project weixin-boot by guhanjie.

the class TestWeixinModel method testErrorEntity.

@Test
public void testErrorEntity() {
    // String response = "{\"errcode\":40013,\"errmsg\":\"invalid appid hint: [.n0.QA0680ken1]\"}";
    // String response = "{\"access_token\":\"8gPGuN0Lzs7c8MRTKfMznUYARZWpR1u3FLVesB611r5scDuZT1C5w3htEXCCjGN1RJG2GYZjSxXkIOdbqcwgY9rTXLwpN9Ru8KSCaukj-weYgN9E7sr7Nq2zZ4mtYTDWQDJfAIAUHN\",\"expires_in\":7200}";
    String response = "<xml><body>JSAPI支付测试</body></xml>";
    System.out.println(response);
    ErrorEntity e = JSON.parseObject(response, ErrorEntity.class);
    System.out.println("object=" + e);
    System.out.println(e.getErrcode() + "\n" + e.getErrmsg());
    Object obj = JSON.toJSON(e);
    if (obj instanceof JSONObject) {
        JSONObject bbb = (JSONObject) obj;
        if (bbb.isEmpty()) {
            System.out.println("xxxxxxxxx");
        }
    }
    assertNotNull(e);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ErrorEntity(com.guhanjie.weixin.model.ErrorEntity) JSONObject(com.alibaba.fastjson.JSONObject) Test(org.junit.Test)

Aggregations

ErrorEntity (com.guhanjie.weixin.model.ErrorEntity)6 HttpEntity (org.apache.http.HttpEntity)4 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)4 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)4 HttpGet (org.apache.http.client.methods.HttpGet)3 IOException (java.io.IOException)2 JSONObject (com.alibaba.fastjson.JSONObject)1 WeixinHttpCallback (com.guhanjie.weixin.WeixinHttpUtil.WeixinHttpCallback)1 AccessToken (com.guhanjie.weixin.model.AccessToken)1 HttpPost (org.apache.http.client.methods.HttpPost)1 StringEntity (org.apache.http.entity.StringEntity)1 Test (org.junit.Test)1