public void fromJson(JSONObject jsonObject) throws JSONException {
    if (null == jsonObject) {
      return;
    }

    JSONArray subItemArray;

    this.uid = jsonObject.optInt("uid");

    this.sid = jsonObject.optString("sid");

    this.by_id = jsonObject.optInt("by_id");

    this.by_no = jsonObject.optInt("by_no");

    this.count = jsonObject.optInt("count");

    this.sort_by = jsonObject.optInt("sort_by");
    LOCATION location = new LOCATION();
    location.fromJson(jsonObject.optJSONObject("location"));
    this.location = location;

    this.service_type = jsonObject.optInt("service_type");

    this.ver = jsonObject.optInt("ver");
    return;
  }
  @Test
  public void asyncStream302RedirectWithBody() throws Throwable {

    withClient(config().setFollowRedirect(true))
        .run(
            client -> {
              withServer(server)
                  .run(
                      server -> {
                        String originalUrl = server.getHttpUrl() + "/original";
                        String redirectUrl = server.getHttpUrl() + "/redirect";

                        server.enqueueResponse(
                            response -> {
                              response.setStatus(302);
                              response.setHeader(LOCATION.toString(), redirectUrl);
                              response
                                  .getOutputStream()
                                  .println("You are being asked to redirect to " + redirectUrl);
                            });
                        server.enqueueOk();

                        Response response =
                            client.prepareGet(originalUrl).execute().get(20, TimeUnit.SECONDS);

                        assertEquals(response.getStatusCode(), 200);
                        assertTrue(response.getResponseBody().isEmpty());
                      });
            });
  }
Exemple #3
0
  public static void savePA(GiPartner partner) throws WebAppException {

    boolean insert = partner.getBinindex() == null;
    save(partner);
    if (insert) {
      GiLocation headquarters = new GiLocation("Headquarters", partner.getBinindex());
      LOCATION.saveLoc(headquarters);
    }
  }
 public JSONObject toJson() throws JSONException {
   JSONObject localItemObject = new JSONObject();
   JSONArray itemJSONArray = new JSONArray();
   localItemObject.put("uid", uid);
   localItemObject.put("sid", sid);
   localItemObject.put("by_id", by_id);
   localItemObject.put("by_no", by_no);
   localItemObject.put("count", count);
   localItemObject.put("sort_by", sort_by);
   if (null != location) {
     localItemObject.put("location", location.toJson());
   }
   localItemObject.put("service_type", service_type);
   localItemObject.put("ver", ver);
   return localItemObject;
 }