public void testXmlDeserializingMatching() {
    prepareStub("application/xml", firstBookSerializedAsXml);
    final Requestor requestory = getRequestor();

    final boolean[] callbackCalled = new boolean[3];

    requestory
        .request(Void.class, Book.class)
        .path(uri)
        .get(
            new AsyncCallback<Book>() {
              @Override
              public void onFailure(Throwable caught) {
                callbackCalled[0] = true;
              }

              @Override
              public void onSuccess(Book result) {
                callbackCalled[1] = true;
                assertEquals(firstBook, result);
              }
            });

    assertFalse(callbackCalled[0]);
    assertTrue(callbackCalled[1]);
  }
  public void testJsonArrayDeserializingMatching() {
    prepareStub("application/json", bookArraySerializedAsJson);
    final Requestor requestory = getRequestor();

    final boolean[] callbackCalled = new boolean[3];

    requestory
        .request(Void.class, Book.class)
        .path(uri)
        .get(
            new ListAsyncCallback<Book>() {
              @Override
              public void onFailure(Throwable caught) {
                callbackCalled[0] = true;
              }

              @Override
              public void onSuccess(List<Book> result) {
                callbackCalled[1] = true;
                assertEquals(bookList, result);
              }
            });

    assertFalse(callbackCalled[0]);
    assertTrue(callbackCalled[1]);
  }
  public void testJsonArraySerializingMatching() {
    prepareStub("text/plain", "response ignored");
    final Requestor requestory = getRequestor();

    requestory
        .request(Book.class, Void.class)
        .path(uri)
        .contentType("application/json")
        .post(bookList);

    assertEquals(bookArraySerializedAsJson, ServerStub.getRequestData(uri).getData());
  }
  public void testXmlSerializingMatching() {
    prepareStub("text/plain", "response ignored");
    final Requestor requestory = getRequestor();

    requestory
        .request(Book.class, Void.class)
        .path(uri)
        .contentType("application/xml")
        .post(firstBook);

    assertEquals(firstBookSerializedAsXml, ServerStub.getRequestData(uri).getData());
  }