Exemplo n.º 1
0
  @Test
  public void testEmptyArray() throws IOException {
    String inputJson = "[]";
    StringReader inputReader = new StringReader(inputJson);
    JsonFilterReader filterReader = new TestJsonFilterReader(inputReader, null);
    String outputJson = new String(IOUtils.toCharArray(filterReader));

    assertThat(outputJson, is("[]"));
  }
Exemplo n.º 2
0
  @Test
  public void testRootArray() throws Exception {
    String inputJson = "[\"test-value-1\",\"test-value-2\",\"test-value-3\"]";
    StringReader inputReader = new StringReader(inputJson);
    JsonFilterReader filterReader = new TestJsonFilterReader(inputReader, null);
    String outputJson = new String(IOUtils.toCharArray(filterReader));
    // System.out.println( "JSON=" + outputJson );
    JsonAssert.with(outputJson).assertThat("$.[0]", is("value:null<test-value-1>"));
    JsonAssert.with(outputJson).assertThat("$.[1]", is("value:null<test-value-2>"));
    JsonAssert.with(outputJson).assertThat("$.[2]", is("value:null<test-value-3>"));

    inputJson = "[777,42]";
    inputReader = new StringReader(inputJson);
    filterReader = new TestJsonFilterReader(inputReader, null);
    outputJson = new String(IOUtils.toCharArray(filterReader));
    // System.out.println( "JSON=" + outputJson );
    JsonAssert.with(outputJson).assertThat("$.[0]", is(777));
    JsonAssert.with(outputJson).assertThat("$.[1]", is(42));
  }
Exemplo n.º 3
0
  @Test
  public void testSimple() throws IOException {
    String inputJson = "{ \"test-name\" : \"test-value\" }";
    StringReader inputReader = new StringReader(inputJson);
    JsonFilterReader filterReader = new TestJsonFilterReader(inputReader, null);
    String outputJson = new String(IOUtils.toCharArray(filterReader));
    // System.out.println( "JSON=" + outputJson );

    JsonAssert.with(outputJson).assertThat("name<test-name>", is("value:null<test-value>"));
  }