RtnCodeTools.java 509 Bytes
package com.xkl;

import org.json.JSONObject;
import org.junit.Assert;

/**
 * Created by zhaoyue on 2017/3/11.
 */
public class RtnCodeTools {
    public static boolean verifyCode(String response, int expectCode) {
        try {
            JSONObject res = new JSONObject(response);
            int code = res.getInt("code");
            Assert.assertEquals(code, expectCode);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}