use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testPackFileFileExists.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#pack(java.io.File, java.io.File)} .
* <ul>
* <li>Exception shall be thrown if working folder already exist.</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testPackFileFileExists() throws Exception {
File workingFolder = File.createTempFile("epub_", null);
EPUB epub = new EPUB();
Publication oebps = new OPSPublication();
epub.add(oebps);
try {
epub.pack(epubFile, workingFolder);
fail();
} catch (Exception e) {
}
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testPackFileFile.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#pack(java.io.File, java.io.File)} .
* <ul>
* <li>Work folder shall exist when job is done.</li>
* <li>Work folder shall contain EPUB artifacts.</li>
* <li>Exception shall be thrown if working folder already exist.</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testPackFileFile() 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);
// Make sure all required files are present
File metaFolder = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF");
assertEquals(true, metaFolder.exists());
assertEquals(true, metaFolder.isDirectory());
File containerFile = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF" + File.separator + "container.xml");
assertEquals(true, containerFile.exists());
assertEquals(false, containerFile.isDirectory());
File oebpsFolder = new File(epubFolder.getAbsolutePath() + File.separator + "OEBPS");
assertEquals(true, oebpsFolder.exists());
assertEquals(true, oebpsFolder.isDirectory());
}
use of org.eclipse.mylyn.docs.epub.core.Publication 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);
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testPackFile.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#pack(java.io.File)}.
* <ul>
* <li>Temporary folder shall not exist when job is done.</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testPackFile() throws Exception {
EPUB epub = new EPUB();
Publication oebps = new OPSPublication();
oebps.addItem(new File("testdata/plain-page.xhtml"));
epub.add(oebps);
File drawing = new File("testdata/drawing.svg");
epub.add(drawing, "image/svg+xml");
File tempFolder = epub.pack(epubFile);
assertEquals(false, tempFolder.exists());
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testUnpackFileFile.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#unpack(java.io.File, java.io.File)} .
*
* @throws Exception
*/
@Test
public final void testUnpackFileFile() throws Exception {
// First pack the EPUB
EPUB epub = new EPUB();
Publication oebps = new OPSPublication();
oebps.addItem(new File("testdata/plain-page.xhtml"));
epub.add(oebps);
epub.pack(epubFile, epubFolder);
deleteFolder(epubFolder);
// Then check for some contents when unpacked
EPUB epub2 = new EPUB();
epub2.unpack(epubFile, epubFolder);
// Make sure all required files are present
File metaFolder = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF");
assertEquals(true, metaFolder.exists());
assertEquals(true, metaFolder.isDirectory());
File containerFile = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF" + File.separator + "container.xml");
assertEquals(true, containerFile.exists());
assertEquals(false, containerFile.isDirectory());
File oebpsFolder = new File(epubFolder.getAbsolutePath() + File.separator + "OEBPS");
assertEquals(true, oebpsFolder.exists());
assertEquals(true, oebpsFolder.isDirectory());
}
Aggregations