EpubWriter { public void write(Book book, OutputStream out) throws IOException { book = processBook(book); ZipOutputStream resultStream = new ZipOutputStream(out); writeMimeType(resultStream); writeContainer(resultStream); initTOCResource(book); writeResources(book, resultStream); writePackageDocument(book, resultStream); resultStream.close(); } EpubWriter();  EpubWriter(BookProcessor bookProcessor); void write(Book book, OutputStream out); BookProcessor getBookProcessor(); void setBookProcessor(BookProcessor bookProcessor);  }
@Test public void testBook1() throws IOException { Book book = createTestBook(); byte[] bookData = writeBookToByteArray(book); FileOutputStream fileOutputStream = new FileOutputStream("foo.zip"); fileOutputStream.write(bookData); fileOutputStream.flush(); fileOutputStream.close(); Assert.assertNotNull(bookData); Assert.assertTrue(bookData.length > 0); Book readBook = new EpubReader().readEpub(new ByteArrayInputStream(bookData)); Assert.assertEquals(book.getMetadata().getTitles(), readBook.getMetadata().getTitles()); Assert.assertEquals(Identifier.Scheme.ISBN, CollectionUtil.first(readBook.getMetadata().getIdentifiers()).getScheme()); Assert.assertEquals(CollectionUtil.first(book.getMetadata().getIdentifiers()).getValue(), CollectionUtil.first(readBook.getMetadata().getIdentifiers()).getValue()); Assert.assertEquals(CollectionUtil.first(book.getMetadata().getAuthors()), CollectionUtil.first(readBook.getMetadata().getAuthors())); Assert.assertEquals(1, readBook.getGuide().getGuideReferencesByType(GuideReference.COVER).size()); Assert.assertEquals(5, readBook.getSpine().size()); Assert.assertNotNull(book.getCoverPage()); Assert.assertNotNull(book.getCoverImage()); Assert.assertEquals(4, readBook.getTableOfContents().size()); }