Search in sources :

Example 1 with Container

use of org.eclipse.mylyn.docs.epub.ocf.Container in project mylyn.docs by eclipse.

the class TestEPUB method testPackFail.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#pack(java.io.File)}.
 * <ul>
 * <li>Shall throw exception when unknown publication type is added.</li>
 * </ul>
 *
 * @throws Exception
 */
@Test
public final void testPackFail() throws Exception {
    EPUB epub = new EPUB();
    File drawing = new File("testdata/drawing.svg");
    epub.add(drawing, "image/svg+xml");
    Container container = epub.getContainer();
    RootFiles rootfiles = container.getRootfiles();
    EList<RootFile> files = rootfiles.getRootfiles();
    files.get(0).setPublication(null);
    try {
        epub.pack(epubFile);
        fail();
    } catch (Exception e) {
    }
}
Also used : Container(org.eclipse.mylyn.docs.epub.ocf.Container) EPUB(org.eclipse.mylyn.docs.epub.core.EPUB) RootFiles(org.eclipse.mylyn.docs.epub.ocf.RootFiles) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) File(java.io.File) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with Container

use of org.eclipse.mylyn.docs.epub.ocf.Container in project mylyn.docs by eclipse.

the class TestEPUB method testAddOPSPublication.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#add(org.eclipse.mylyn.docs.epub.core.Publication)} .
 * <ul>
 * <li>Container shall hold more than one OPS publication</li>
 * <li>OPS structures shall follow naming conventions.</li>
 * <li>OPS MIME-type shall be correct</li>
 * <li>Rootfile object shall be correct.</li>
 * </ul>
 *
 * @throws Exception
 */
@Test
public final void testAddOPSPublication() throws Exception {
    EPUB epub = new EPUB();
    Publication oebps1 = new OPSPublication();
    Publication oebps2 = new OPSPublication();
    epub.add(oebps1);
    epub.add(oebps2);
    Container container = epub.getContainer();
    RootFiles rootfiles = container.getRootfiles();
    EList<RootFile> files = rootfiles.getRootfiles();
    assertEquals(true, files.get(0).getFullPath().equals("OEBPS/content.opf"));
    assertEquals(true, files.get(1).getFullPath().equals("OEBPS_1/content.opf"));
    assertEquals(true, files.get(0).getMediaType().equals("application/oebps-package+xml"));
    assertEquals(true, files.get(1).getMediaType().equals("application/oebps-package+xml"));
    assertEquals(true, files.get(0).getPublication() == oebps1);
    assertEquals(true, files.get(1).getPublication() == oebps2);
}
Also used : Container(org.eclipse.mylyn.docs.epub.ocf.Container) EPUB(org.eclipse.mylyn.docs.epub.core.EPUB) Publication(org.eclipse.mylyn.docs.epub.core.Publication) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) RootFiles(org.eclipse.mylyn.docs.epub.ocf.RootFiles) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) Test(org.junit.Test)

Example 3 with Container

use of org.eclipse.mylyn.docs.epub.ocf.Container in project mylyn.docs by eclipse.

the class TestEPUB method testAddFileString.

/**
 * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#add(java.io.File, java.lang.String)} .
 * <ul>
 * <li>Publication MIME-type shall be correct</li>
 * <li>Rootfile path shall be correct</li>
 * <li>Rootfile object shall be correct.</li>
 * </ul>
 *
 * @throws Exception
 */
@Test
public final void testAddFileString() throws Exception {
    EPUB epub = new EPUB();
    File drawing = new File("testdata/drawing.svg");
    epub.add(drawing, "image/svg+xml");
    Container container = epub.getContainer();
    RootFiles rootfiles = container.getRootfiles();
    EList<RootFile> files = rootfiles.getRootfiles();
    assertEquals(true, files.get(0).getFullPath().equals("SVG+XML/drawing.svg"));
    assertEquals(true, files.get(0).getMediaType().equals("image/svg+xml"));
    assertEquals(true, files.get(0).getPublication() == drawing);
}
Also used : Container(org.eclipse.mylyn.docs.epub.ocf.Container) EPUB(org.eclipse.mylyn.docs.epub.core.EPUB) RootFiles(org.eclipse.mylyn.docs.epub.ocf.RootFiles) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) RootFile(org.eclipse.mylyn.docs.epub.ocf.RootFile) File(java.io.File) Test(org.junit.Test)

Aggregations

EPUB (org.eclipse.mylyn.docs.epub.core.EPUB)3 Container (org.eclipse.mylyn.docs.epub.ocf.Container)3 RootFile (org.eclipse.mylyn.docs.epub.ocf.RootFile)3 RootFiles (org.eclipse.mylyn.docs.epub.ocf.RootFiles)3 Test (org.junit.Test)3 File (java.io.File)2 IOException (java.io.IOException)1 OPSPublication (org.eclipse.mylyn.docs.epub.core.OPSPublication)1 Publication (org.eclipse.mylyn.docs.epub.core.Publication)1