Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONObject


    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("slider").path("mgmt").path("app")
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 4, json.length());
    assertEquals("wrong href",
                 "http://localhost:9998/slideram/ws/v1/slider/mgmt/app",
                 json.getString("href"));
    assertNotNull("no resources", json.getJSONObject("resources"));
    assertNotNull("no internal", json.getJSONObject("internal"));
    assertNotNull("no appConf", json.getJSONObject("appConf"));
  }
View Full Code Here


        r.path("ws").path("v1").path("slider").path("mgmt").path("app").path("configurations").path(
            "internal")
            .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 4, json.length());
    assertEquals("wrong href",
                 "http://localhost:9998/slideram/ws/v1/slider/mgmt/app/configurations/internal",
                 json.getString("href"));
    assertEquals("wrong description",
                 "Internal configuration DO NOT EDIT",
                 json.getJSONObject("metadata").getString("description"));
  }
View Full Code Here

            "resources")
            .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

    assertEquals(200, response.getStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 4, json.length());
    assertEquals("wrong href",
                 "http://localhost:9998/slideram/ws/v1/slider/mgmt/app/configurations/resources",
                 json.getString("href"));
    json = json.getJSONObject("components");
    assertNotNull("no components", json);
    assertEquals("incorrect number of components", 2, json.length());
    assertNotNull("wrong component", json.getJSONObject("worker"));
  }
View Full Code Here

        r.path("ws").path("v1").path("slider").path("mgmt").path("app").path("configurations").path(
            "appConf")
            .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(200, response.getStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 4, json.length());
    assertEquals("wrong href",
                 "http://localhost:9998/slideram/ws/v1/slider/mgmt/app/configurations/appConf",
                 json.getString("href"));
    json = json.getJSONObject("components");
    assertNotNull("no components", json);
    assertEquals("incorrect number of components", 2, json.length());
    assertNotNull("wrong component", json.getJSONObject("worker"));
  }
View Full Code Here

    register.setHostname("dummyHost");
    return register;
  }

  private JSONObject createDummyHeartBeat() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("responseId", -1);
    json.put("timestamp", System.currentTimeMillis());
    json.put("hostname", "dummyHost");
    return json;
  }
View Full Code Here

            String jsonContent = getStringFromInputStream(get.getResponseBodyAsStream());
            String expected = getStringFromInputStream(
                  getClass().getResourceAsStream(resourcePath));
            expected = expected.replaceAll("9080", PORT);
           
            JSONObject obj1 = new JSONObject(jsonContent);
            JSONObject obj2 = new JSONObject(expected);
           
            assertEquals("Atom entry should've been formatted as json",
                         obj1.toString(), obj2.toString());
        } finally {
            get.releaseConnection();
        }
    }
View Full Code Here

        connection.setDoOutput(true);
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
        String body = getResponseFor(connection);

        JSONObject objFromResponse = new JSONObject(body);
        JSONObject expected = new JSONObject(
                                             "{\"dna%3arepository\":{\"repository\":{\"name\":\"dna%3arepository\",\"resources\":{\"workspaces\":\"/resources/dna%3arepository\"}}}}");

        assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
        assertThat(objFromResponse.toString(), is(expected.toString()));
        connection.disconnect();
    }
View Full Code Here

        connection.setDoOutput(true);
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
        String body = getResponseFor(connection);

        JSONObject objFromResponse = new JSONObject(body);
        JSONObject expected = new JSONObject(
                                             "{\"default\":{\"workspace\":{\"name\":\"default\",\"resources\":{\"items\":\"/resources/dna%3arepository/default/items\"}}}}");

        assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
        assertThat(objFromResponse.toString(), is(expected.toString()));
        connection.disconnect();
    }
View Full Code Here

        connection.setDoOutput(true);
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);

        JSONObject body = new JSONObject(getResponseFor(connection));
        assertThat(body.length(), is(2));

        JSONObject properties = body.getJSONObject("properties");
        assertThat(properties, is(notNullValue()));
        assertThat(properties.length(), is(2));
        assertThat(properties.getString("jcr:primaryType"), is("dna:root"));
        assertThat(properties.get("jcr:uuid"), is(notNullValue()));

        JSONArray children = body.getJSONArray("children");
        assertThat(children.length(), is(1));
        assertThat(children.getString(0), is("jcr:system"));
View Full Code Here

        HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();

        connection.setDoOutput(true);
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
        JSONObject body = new JSONObject(getResponseFor(connection));
        assertThat(body.length(), is(2));

        JSONObject properties = body.getJSONObject("properties");
        assertThat(properties, is(notNullValue()));
        assertThat(properties.length(), is(2));
        assertThat(properties.getString("jcr:primaryType"), is("dna:root"));
        assertThat(properties.get("jcr:uuid"), is(notNullValue()));

        JSONObject children = body.getJSONObject("children");
        assertThat(children.length(), is(1));

        JSONObject system = children.getJSONObject("jcr:system");
        assertThat(system.length(), is(2));

        properties = system.getJSONObject("properties");
        assertThat(properties.length(), is(1));
        assertThat(properties.getString("jcr:primaryType"), is("dna:system"));

        JSONArray namespaces = system.getJSONArray("children");
        assertThat(namespaces.length(), is(1));
        assertThat(namespaces.getString(0), is("dna:namespaces"));

        assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
        connection.disconnect();
View Full Code Here

TOP

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

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.