Search in sources :

Example 6 with Publication

use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.

the class TestEPUB method testUnpackFile.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#unpack(java.io.File)}.
 * <ul>
 * <li>Unpacked EPUB shall have the same contents as the packed one.</li>
 * </ul>
 *
 * @throws Exception
 */
@Test
public final void testUnpackFile() throws Exception {
    EPUB epub = new EPUB();
    Publication oebps = new OPSPublication();
    oebps.addItem(new File("testdata/plain-page.xhtml"));
    epub.add(oebps);
    epub.pack(epubFile, epubFolder);
    EPUB epub2 = new EPUB();
    epub2.unpack(epubFile);
    assertEquals(1, epub2.getOPSPublications().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) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) File(java.io.File) Test(org.junit.Test)

Example 7 with Publication

use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.

the class TestOPSPublication method testSetCover.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setCover(java.io.File, java.lang.String)} .
 * <ul>
 * <li>Cover page SVG shall exist in the unpacked folder</li>
 * <li>Cover page HTML shall exist in the unpacked folder</li>
 * </ul>
 *
 * @throws Exception
 */
@Test
public final void testSetCover() throws Exception {
    oebps.setCover(new File("testdata/drawing.svg"), "Title");
    oebps.addItem(new File("testdata/plain-page.xhtml"));
    epub.add(oebps);
    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 html = new File(root.getAbsolutePath() + File.separator + "cover-page.xhtml");
    Assert.assertTrue(html.exists());
}
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)

Example 8 with Publication

use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.

the class TestOPSPublication method testReadTableOfContents.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#readTableOfContents(java.io.File)} .
 *
 * @throws Exception
 */
@Test
public final void testReadTableOfContents() throws Exception {
    epub.add(oebps);
    oebps.addItem(new File("testdata/plain-page.xhtml"));
    epub.pack(epubFile);
    EPUB epub_in = new EPUB();
    epub_in.unpack(epubFile, epubFolder);
    Publication oebps_in = epub_in.getOPSPublications().get(0);
    assertTrue(oebps_in.getTableOfContents() != null);
    assertTrue(oebps_in.getTableOfContents() instanceof Ncx);
    Ncx ncx = (Ncx) oebps_in.getTableOfContents();
    NavPoint h1_1 = ncx.getNavMap().getNavPoints().get(0);
    NavPoint h1_2 = ncx.getNavMap().getNavPoints().get(1);
    assertEquals("First item", getText(h1_1));
    assertEquals("Second item", getText(h1_2));
}
Also used : Ncx(org.eclipse.mylyn.docs.epub.ncx.Ncx) NavPoint(org.eclipse.mylyn.docs.epub.ncx.NavPoint) 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)

Example 9 with Publication

use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.

the class TestPublication method test_Bug360701.

/**
 * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=360701">bug 360701</a>: [epub] Automatic
 * inclusion of referenced resources don't work for WikiText generated HTML.
 *
 * @throws Exception
 */
@Test
public final void test_Bug360701() throws Exception {
    oebps.setIncludeReferencedResources(true);
    // This page is similar to what WikiText would generate
    oebps.addItem(new File("testdata/plain-page_link.html"));
    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.html");
    Assert.assertTrue(html.exists());
}
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)

Example 10 with Publication

use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.

the class TestEPUB method testGetOPSPublications.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#getOPSPublications()}.
 * <p>
 * One OPS-publication and one SVG drawing are added. Only the OPS-publication shall be returned.
 * </p>
 *
 * @throws Exception
 */
@Test
public final void testGetOPSPublications() throws Exception {
    EPUB epub = new EPUB();
    Publication oebps = new OPSPublication();
    epub.add(oebps);
    File drawing = new File("testdata/drawing.svg");
    epub.add(drawing, "image/svg+xml");
    assertEquals(1, epub.getOPSPublications().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) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) 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