@Test
public void writesCollectionOfObjectsToOutputStream() throws Exception {

    List<Book> books = newArrayList(createJunitBook());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    jsonEntityProvider.writeTo(books, List.class, newParameterizedType(List.class, Book.class), null, APPLICATION_JSON_TYPE, new MultivaluedHashMap<>(), out);
    String outputAsString = out.toString();
    assertTrue(outputAsString.startsWith("["));
    assertTrue(outputAsString.endsWith("]"));
    assertTrue(outputAsString.contains("\"author\":\"Vincent Massol\""));
    assertTrue(outputAsString.contains("\"title\":\"JUnit in Action\""));
    assertTrue(outputAsString.contains("\"pages\":386"));
    assertTrue(outputAsString.contains("\"price\":19.37"));
    assertTrue(outputAsString.contains("\"isdn\":93011099534534"));
}