use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestPublication method testSetIncludeReferencedResources.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setIncludeReferencedResources(boolean)}. This
* is determining whether or not the referenced resources has been picked up and included in the resulting EPUB.
* Also handles <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375795">bug 375795</a>: [epub][patch]
* Automatic inclusion of referenced resources fail on anchor references
*
* @throws Exception
*/
@Test
public final void testSetIncludeReferencedResources() throws Exception {
oebps.setIncludeReferencedResources(true);
oebps.addItem(new File("testdata/plain-page_link.xhtml"));
epub.add(oebps);
// Included resources will only be added when we pack
epub.pack(epubFile);
EPUB epub2 = new EPUB();
epub2.unpack(epubFile, epubFolder);
Publication oebps = epub2.getOPSPublications().get(0);
File root = oebps.getRootFolder();
File svg = new File(root.getAbsolutePath() + File.separator + "drawing.svg");
Assert.assertTrue(svg.exists());
File svg2 = new File(root.getAbsolutePath() + File.separator + "images" + File.separator + "subfolder-drawing.svg");
Assert.assertTrue(svg2.exists());
File html = new File(root.getAbsolutePath() + File.separator + "plain-page_no-header.xhtml");
Assert.assertTrue(html.exists());
File html2 = new File(root.getAbsolutePath() + File.separator + "plain-page.xhtml");
Assert.assertTrue(html2.exists());
// The manifest shall only contain the items we have linked to in addition to the toc.ncx and the file that we
// started from -- a total of six files.
Assert.assertEquals(6, oebps.getPackage().getManifest().getItems().size());
}
Aggregations