Search in sources :

Example 16 with Publication

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());
}
Also used : EPUB(org.eclipse.mylyn.docs.epub.core.EPUB) Publication(org.eclipse.mylyn.docs.epub.core.Publication) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) File(java.io.File) Test(org.junit.Test)

Aggregations

OPSPublication (org.eclipse.mylyn.docs.epub.core.OPSPublication)16 Publication (org.eclipse.mylyn.docs.epub.core.Publication)16 Test (org.junit.Test)16 File (java.io.File)15 EPUB (org.eclipse.mylyn.docs.epub.core.EPUB)15 RootFile (org.eclipse.mylyn.docs.epub.ocf.RootFile)9 NavPoint (org.eclipse.mylyn.docs.epub.ncx.NavPoint)2 Ncx (org.eclipse.mylyn.docs.epub.ncx.Ncx)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Meta (org.eclipse.mylyn.docs.epub.ncx.Meta)1 Container (org.eclipse.mylyn.docs.epub.ocf.Container)1 RootFiles (org.eclipse.mylyn.docs.epub.ocf.RootFiles)1