Exemplo n.º 1
0
  private void regression(int index, boolean array) throws IOException {
    Json.Value sample =
        Json.read(
            new BufferedReader(
                new InputStreamReader(
                    JsonTest.class.getResourceAsStream(
                        format("/com/twolattes/json/testdata/sample%s.json", index)))));
    Json.Value samplePretty =
        Json.read(
            new BufferedReader(
                new InputStreamReader(
                    JsonTest.class.getResourceAsStream(
                        format("/com/twolattes/json/testdata/sample%s_pretty.json", index)))));

    System.out.println(sample);
    System.out.println(samplePretty);
    assertEquals(sample, samplePretty);

    Object sampleOrgJson;
    if (array) {
      sampleOrgJson = new JSONArray(sample.toString());
    } else {
      sampleOrgJson = new JSONObject(sample.toString());
    }

    assertJsonEquals(sample, sampleOrgJson);
    assertJsonEquals(samplePretty, sampleOrgJson);
  }
Exemplo n.º 2
0
 private void testNotEquals(Json.Value v1, Json.Value v2) {
   assertFalse(v1.equals(v2));
   assertFalse(v2.equals(v1));
 }
Exemplo n.º 3
0
 private void testEqualsAndHashCode(Json.Value v1, Json.Value v2) {
   assertEquals(v1, v2);
   assertEquals(v2, v1);
   assertEquals(v1.hashCode(), v2.hashCode());
 }