Package org.json.simple

Examples of org.json.simple.JSONObject.containsKey()


                        conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestMethod("GET");
                        assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
                        assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
                        json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
                        assertTrue(json.containsKey(JsonTags.OOZIE_SYSTEM_MODE));
                        assertEquals(SYSTEM_MODE.SAFEMODE.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE));

                        MockDagEngineService.reset();
                        params = new HashMap<String, String>();
                        params.put(RestConstants.ACTION_PARAM, RestConstants.JOB_ACTION_START);
View Full Code Here


                        conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestMethod("GET");
                        assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
                        assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
                        json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
                        assertTrue(json.containsKey(JsonTags.OOZIE_SYSTEM_MODE));
                        assertEquals(SYSTEM_MODE.NORMAL.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE));

                        MockDagEngineService.reset();
                        params = new HashMap<String, String>();
                        params.put(RestConstants.ACTION_PARAM, RestConstants.JOB_ACTION_START);
View Full Code Here

                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestMethod("GET");
                assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
                assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
                JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
                assertTrue(json.containsKey(JsonTags.QUEUE_DUMP));
                return null;
            }
        });

    }
View Full Code Here

                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestMethod("GET");
                assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
                assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
                JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
                assertTrue(json.containsKey(JsonTags.AVAILABLE_TIME_ZONES));
                JSONArray array = (JSONArray) json.get(JsonTags.AVAILABLE_TIME_ZONES);
                assertFalse(array.isEmpty());
                return null;
            }
        });
View Full Code Here

    public void createScript() {
        Response response = doCreateScript();
        Assert.assertEquals(201, response.getStatus());

        JSONObject obj = (JSONObject)response.getEntity();
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertNotNull(((PigScript) obj.get("script")).getId());
        Assert.assertFalse(((PigScript) obj.get("script")).getId().isEmpty());
    }

    @Test
View Full Code Here

    public void createScriptAutoCreate() {
        Response response = doCreateScript("Test", null);
        Assert.assertEquals(201, response.getStatus());

        JSONObject obj = (JSONObject)response.getEntity();
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertNotNull(((PigScript) obj.get("script")).getId());
        Assert.assertFalse(((PigScript) obj.get("script")).getId().isEmpty());
        Assert.assertFalse(((PigScript) obj.get("script")).getPigScript().isEmpty());
    }
View Full Code Here

        Response response2 = scriptService.getScript(createdScriptId);
        Assert.assertEquals(200, response2.getStatus());

        JSONObject obj = ((JSONObject) response2.getEntity());
        Assert.assertTrue(obj.containsKey("script"));
        Assert.assertEquals(((PigScript) obj.get("script")).getTitle(), request.script.getTitle());
    }

    @Test
    public void deleteScript() {
View Full Code Here

        Response response = scriptService.getScriptList();
        Assert.assertEquals(200, response.getStatus());

        JSONObject obj = (JSONObject) response.getEntity();
        Assert.assertTrue(obj.containsKey("scripts"));
        List<PigScript> scripts = (List<PigScript>) obj.get("scripts");
        boolean containsTitle = false;
        for(PigScript script : scripts)
            containsTitle = containsTitle || script.getTitle().compareTo("Title 1") == 0;
        Assert.assertTrue(containsTitle);
View Full Code Here

    Response response2 = fileService.getFile(filePath, 0L);
    Assert.assertEquals(200, response2.getStatus());

    JSONObject obj = ((JSONObject) response2.getEntity());
    Assert.assertTrue(obj.containsKey("file"));
    Assert.assertEquals("1234", ((FileResource) obj.get("file")).getFileContent());
  }

  @Test
  public void testPagination() throws Exception {
View Full Code Here

    Response response = fileService.getFile(filePath, 0L);
    Assert.assertEquals(200, response.getStatus());

    JSONObject obj = ((JSONObject) response.getEntity());
    Assert.assertTrue(obj.containsKey("file"));
    Assert.assertEquals("1234", ((FileResource) obj.get("file")).getFileContent());
    Assert.assertEquals(3, ((FileResource) obj.get("file")).getPageCount());
    Assert.assertEquals(0, ((FileResource) obj.get("file")).getPage());
    Assert.assertTrue(((FileResource) obj.get("file")).isHasNext());
    Assert.assertEquals(filePath, ((FileResource) obj.get("file")).getFilePath());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.