Package org.json.simple

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


 
  public ViewBean(byte[] buffer) throws ParseException {
    JSONParser parser = new JSONParser();
    try {
      JSONObject json = (JSONObject) parser.parse(new String(buffer));
      if(json.containsKey("description")) {
        this.description = (String) json.get("description");
      } else {
        this.description = "";
      }
      this.owner= (String) json.get("owner");
View Full Code Here


  public void certificatesAreEncoded() throws CertificateException, IOException {
    List<Certificate> inputCerts = CryptoDataLoader.certificatesFromFile(new File(TEST_DATA_PATH));
    HttpLogClient client = new HttpLogClient("");

    JSONObject encoded = client.encodeCertificates(inputCerts);
    Assert.assertTrue(encoded.containsKey("chain"));
    JSONArray chain = (JSONArray) encoded.get("chain");
    assertEquals("Expected to have two certificates in the chain", 2, chain.size());
    // Make sure the order is reversed.
    for (int i = 0; i < inputCerts.size(); i++) {
      assertEquals(
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("USER"));
                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("java.version"));
                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(Services.CONF_SERVICE_CLASSES));
                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.INSTR_VARIABLES));
                return null;
            }
        });
    }
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));
                        JSONObject 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.ADMIN_SYSTEM_MODE_PARAM, SYSTEM_MODE.SAFEMODE.toString());
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.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

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.