public class EpubWriterTest {
@Test
public void testBook1() throws IOException {
// create test book
Book book = createTestBook();
// write book to byte[]
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);
// read book from byte[]
Book readBook = new EpubReader().readEpub(new ByteArrayInputStream(bookData));
// assert book values are correct
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());
}