use of org.eclipse.mylyn.docs.epub.core.ValidationMessage in project mylyn.docs by eclipse.
the class TestOPSPublication method test_Bug358671_Illegal_Fallback.
/**
* Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=358671">bug 358671</a>: Add support for
* fallback items
* <p>
* This method tests for the exception that shall be raised when an illegal item has been added with an illegal
* fallback item. Which fallback items that are allowed is specified by the OPS version.
* </p>
*
* @throws Exception
*/
@Test
public final void test_Bug358671_Illegal_Fallback() throws Exception {
epub.add(oebps);
Item item = oebps.addItem(new File("testdata/OPF-Tests/Bug_358671/illegal-type.html"));
item.setFallback("fallback");
oebps.addItem("fallback", null, new File("testdata/OPF-Tests/Bug_358671/illegal-type.html"), null, null, true, true, false);
epub.pack(epubFile);
ValidationMessage msg = oebps.getValidationMessages().get(0);
assertEquals(Severity.WARNING, msg.getSeverity());
assertEquals(true, msg.getMessage().equals("Item \"illegal-type.html\" is not a core media type and specifies a non-core media fallback item."));
}
use of org.eclipse.mylyn.docs.epub.core.ValidationMessage in project mylyn.docs by eclipse.
the class TestOPSPublication method testValidateContents.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#validateContents()} .
* <ul>
* <li>There shall be a warning message</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testValidateContents() throws Exception {
epub.add(oebps);
oebps.addItem(new File("testdata/plain-page_warnings.xhtml"));
epub.pack(epubFile);
assertEquals(1, oebps.getValidationMessages().size());
ValidationMessage msg = oebps.getValidationMessages().get(0);
assertEquals(Severity.WARNING, msg.getSeverity());
assertTrue(msg.getMessage().startsWith("Element \"bad\""));
}
use of org.eclipse.mylyn.docs.epub.core.ValidationMessage in project mylyn.docs by eclipse.
the class TestOPSPublication method test_Bug358671_Legal_Fallback.
/**
* Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=358671">bug 358671</a>: Add support for
* fallback items
* <p>
* This method tests for the warning that shall be issued when an illegal item has been added with a legal fallback
* item.
* </p>
*
* @throws Exception
*/
@Test
public final void test_Bug358671_Legal_Fallback() throws Exception {
epub.add(oebps);
Item item = oebps.addItem(new File("testdata/OPF-Tests/Bug_358671/illegal-type.html"));
item.setFallback("fallback");
oebps.addItem("fallback", null, new File("testdata/plain-page.xhtml"), null, null, true, true, false);
epub.pack(epubFile);
assertEquals(3, oebps.getPackage().getManifest().getItems().size());
assertEquals(1, oebps.getValidationMessages().size());
ValidationMessage msg = oebps.getValidationMessages().get(0);
assertEquals(Severity.WARNING, msg.getSeverity());
assertEquals(true, msg.getMessage().equals("Item \"illegal-type.html\" is not a core media type but a legal fallback item has been specified."));
}
use of org.eclipse.mylyn.docs.epub.core.ValidationMessage in project mylyn.docs by eclipse.
the class ConvertFromMarkupWizard method performFinish.
@Override
public boolean performFinish() {
final MarkupToOPS markupToEPUB = new MarkupToOPS();
markupToEPUB.setMarkupLanguage(markupLanguage);
final MultiStatus ms = new MultiStatus(EPUBUIPlugin.PLUGIN_ID, 0, Messages.ConvertFromMarkupWizard_1, null);
try {
getContainer().run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask(Messages.ConvertFromMarkupWizard_2, 3);
try {
if (epubFile.exists()) {
// Delete the old one
epubFile.delete(true, monitor);
}
// Parse the wiki markup and populate the EPUB
markupFolder = markupToEPUB.parse(oebps, markupFile.getLocation().toFile());
monitor.worked(1);
EPUB publication = new EPUB();
publication.add(oebps);
epubFolder = publication.pack(epubFile.getLocation().toFile());
monitor.worked(1);
epubFile.refreshLocal(IResource.DEPTH_ONE, monitor);
monitor.worked(1);
List<ValidationMessage> messages = oebps.getMessages();
for (ValidationMessage validationMessage : messages) {
ms.add(new Status(IStatus.WARNING, EPUBUIPlugin.PLUGIN_ID, validationMessage.getMessage()));
}
} catch (Exception e) {
e.printStackTrace();
ms.add(new Status(IStatus.ERROR, EPUBUIPlugin.PLUGIN_ID, Messages.ConvertFromMarkupWizard_3, e));
} finally {
deleteFolder(epubFolder);
deleteFolder(markupFolder);
monitor.done();
}
}
});
} catch (Throwable e) {
ms.add(new Status(IStatus.ERROR, EPUBUIPlugin.PLUGIN_ID, Messages.ConvertFromMarkupWizard_4, e));
return false;
}
if (!ms.isOK()) {
StatusManager.getManager().handle(ms, StatusManager.BLOCK);
}
return ms.isOK();
}
use of org.eclipse.mylyn.docs.epub.core.ValidationMessage in project mylyn.docs by eclipse.
the class TestOPSPublication method test_Bug358671_Illegal_Item.
/**
* Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=358671">bug 358671</a>: Add support for
* fallback items
* <p>
* This method tests for the exception that shall be raised when an illegal item has been added.
* </p>
*
* @throws Exception
*/
@Test
public final void test_Bug358671_Illegal_Item() throws Exception {
epub.add(oebps);
oebps.addItem(new File("testdata/OPF-Tests/Bug_358671/illegal-type.html"));
epub.pack(epubFile);
ValidationMessage msg = oebps.getValidationMessages().get(0);
assertEquals(Severity.WARNING, msg.getSeverity());
assertEquals(true, msg.getMessage().equals("Item \"illegal-type.html\" is not a core media type and does not specify a fallback item."));
}
Aggregations