Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONArray


    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    assertEquals("incorrect number of elements", 2, nodeArray.length());
    for (int i = 0; i < nodeArray.length(); ++i) {
      JSONObject info = nodeArray.getJSONObject(i);
      String host = info.get("id").toString().split(":")[0];
      RMNode rmNode = rm.getRMContext().getInactiveRMNodes().get(host);
      WebServicesTestUtils.checkStringMatch("nodeHTTPAddress", "",
          info.getString("nodeHTTPAddress"));
      WebServicesTestUtils.checkStringMatch("state", rmNode.getState()
View Full Code Here


    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    assertEquals("incorrect number of elements", 1, nodeArray.length());
  }
View Full Code Here

    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    assertEquals("incorrect number of elements", 2, nodeArray.length());
    JSONObject info = nodeArray.getJSONObject(0);
    String id = info.get("id").toString();

    if (id.matches("h1:1234")) {
      verifyNodeInfo(info, nm1);
      verifyNodeInfo(nodeArray.getJSONObject(1), nm2);
    } else {
      verifyNodeInfo(info, nm2);
      verifyNodeInfo(nodeArray.getJSONObject(1), nm1);
    }
  }
View Full Code Here

    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    assertEquals("incorrect number of elements", 3, nodeArray.length());
  }
View Full Code Here

    assertEquals(200, response.getStatus()); // 200 = OK

    String json = response.getEntity(String.class);
    JSONObject results = new JSONObject(json);
    JSONObject jo = (JSONObject) results.get("Results");
    JSONArray states = (JSONArray) jo.get("state");
    Assert.assertFalse(states.isNull(0));
    JSONObject state = (JSONObject) states.get(0);

    assertEquals("36", state.get("geoid"));
    assertEquals("New York", state.get("name"));
    assertEquals("NY", state.get("stusps"));
  }
View Full Code Here

    assertEquals(200, response.getStatus()); // 200 = OK

    String json = response.getEntity(String.class);
    JSONObject results = new JSONObject(json);
    JSONObject jo = (JSONObject) results.get("Results");
    JSONArray counties = (JSONArray) jo.get("county");
    Assert.assertFalse(counties.isNull(0));
    JSONObject county = (JSONObject) counties.get(0);

    assertEquals("36065", county.get("geoid"));
    assertEquals("Oneida", county.get("name"));
    assertEquals("36", county.get("statefp10"));
  }
View Full Code Here

    assertEquals(200, response.getStatus()); // 200 = OK

    String json = response.getEntity(String.class);
    JSONObject results = new JSONObject(json);
    JSONObject jo = (JSONObject) results.get("Results");
    JSONArray blocks = (JSONArray) jo.get("block");
    Assert.assertFalse(blocks.isNull(0));
    JSONObject block = (JSONObject) blocks.get(0);

    assertEquals("360010021002003", block.get("geoid"));
    assertEquals("36", block.get("statefp"));
    assertEquals("001", block.get("countyfp"));
View Full Code Here

    WebResource r = c.resource("http://192.168.1.33:8080/BattleShip/rest/gameserver/games/1");
      
    String result = r.accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
   
    JSONObject gamesJSON = new JSONObject(result);
    JSONArray games = gamesJSON.getJSONArray("game");
    for (int i=0 ; i< games.length();i++) {
      JSONObject game = (JSONObject)games.get(i);
      System.out.println(game.get("id")+ " " +game.get("status"));
    }
 
   
   
View Full Code Here

    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    // Just 2 nodes, leaving behind the unhealthy node.
    assertEquals("incorrect number of elements", 2, nodeArray.length());
  }
View Full Code Here

    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject nodes = json.getJSONObject("nodes");
    assertEquals("incorrect number of elements", 1, nodes.length());
    JSONArray nodeArray = nodes.getJSONArray("node");
    assertEquals("incorrect number of elements", 1, nodeArray.length());
    JSONObject info = nodeArray.getJSONObject(0);

    verifyNodeInfo(info, nm1);
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.