Search in sources :

Example 6 with OPSPublication

use of org.eclipse.mylyn.docs.epub.core.OPSPublication 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 OPSPublication

use of org.eclipse.mylyn.docs.epub.core.OPSPublication 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)

Example 8 with OPSPublication

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

the class TestEPUB method test_Bug378800.

/**
 * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=378800">bug 378800</a>: [epub] Remove
 * "ocf" prefix from elements in container.xml
 *
 * @throws Exception
 */
@Test
public final void test_Bug378800() 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);
    // $NON-NLS-1$
    File metaFolder = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF");
    // $NON-NLS-1$
    File containerFile = new File(metaFolder.getAbsolutePath() + File.separator + "container.xml");
    BufferedReader br = new BufferedReader(new FileReader(containerFile));
    String in = null;
    boolean ok = false;
    while ((in = br.readLine()) != null) {
        // as opposed to "<ocf:container "
        if (in.startsWith("<container ")) {
            ok = true;
        }
    }
    br.close();
    assertEquals(true, ok);
}
Also used : EPUB(org.eclipse.mylyn.docs.epub.core.EPUB) BufferedReader(java.io.BufferedReader) Publication(org.eclipse.mylyn.docs.epub.core.Publication) OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) FileReader(java.io.FileReader) 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 9 with OPSPublication

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

the class TestOPSPublication method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    oebps = new OPSPublication(logger);
}
Also used : OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) Before(org.junit.Before)

Example 10 with OPSPublication

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

the class TestPublication method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    oebps = new OPSPublication(logger);
}
Also used : OPSPublication(org.eclipse.mylyn.docs.epub.core.OPSPublication) Before(org.junit.Before)

Aggregations

OPSPublication (org.eclipse.mylyn.docs.epub.core.OPSPublication)12 Test (org.junit.Test)9 EPUB (org.eclipse.mylyn.docs.epub.core.EPUB)8 Publication (org.eclipse.mylyn.docs.epub.core.Publication)8 RootFile (org.eclipse.mylyn.docs.epub.ocf.RootFile)8 File (java.io.File)7 Before (org.junit.Before)3 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ValidationException (org.eclipse.mylyn.docs.epub.core.ValidationException)1 Container (org.eclipse.mylyn.docs.epub.ocf.Container)1 RootFiles (org.eclipse.mylyn.docs.epub.ocf.RootFiles)1