[eclipse-mylyn] Add mylyn-tests package.
swagiaal
swagiaal at fedoraproject.org
Thu Jul 10 20:02:18 UTC 2014
commit 86986455cd39b4c8c1ce0302b65eca1076486471
Author: Sami Wagiaalla <swagiaal at redhat.com>
Date: Thu Jul 10 11:43:48 2014 -0400
Add mylyn-tests package.
.gitignore | 1 +
eclipse-mylyn-remove-epubcheck-tests.patch | 2018 ++++++++++++++++++++++++++++
eclipse-mylyn.spec | 46 +-
sources | 3 +-
4 files changed, 2064 insertions(+), 4 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e6a5ae9..a270d63 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,4 @@ eclipse-mylyn-R_3_8_1-fetched-src.tar.bz2
/eclipse-mylyn-c94b24d5c1bfda43bf5782ce142ecf3e890beda8-incubator-fetched-src.tar.xz
/eclipse-mylyn-8c077e351de3d0857512e7c4e48ad0f0a56e96ca-fetched-src.tar.xz
/eclipse-mylyn-a1a4646ea6d027e89f828a9c45bd8fa79721a90c-incubator-fetched-src.tar.xz
+/eclipse-mylyn-R_3_12_0-fetched-src.tar.xz
diff --git a/eclipse-mylyn-remove-epubcheck-tests.patch b/eclipse-mylyn-remove-epubcheck-tests.patch
new file mode 100644
index 0000000..e0524da
--- /dev/null
+++ b/eclipse-mylyn-remove-epubcheck-tests.patch
@@ -0,0 +1,2018 @@
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/META-INF/MANIFEST.MF
+index 9af8305..284c624 100644
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/META-INF/MANIFEST.MF
++++ b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/META-INF/MANIFEST.MF
+@@ -10,16 +10,6 @@ Require-Bundle: org.junit,
+ org.apache.ant.source;bundle-version="1.8.0",
+ org.eclipse.emf.ecore;bundle-version="2.5.0",
+ org.eclipse.mylyn.docs.epub.core;bundle-version="1.0.0"
+-Bundle-ClassPath: .,
+- epubcheck/epubcheck-3.0-RC-1.jar,
+- epubcheck/lib/commons-compress-1.4.1.jar,
+- epubcheck/lib/jing-20120724.0.0.jar,
+- epubcheck/lib/phloc-commons-3.8.4.jar,
+- epubcheck/lib/phloc-css-3.2.1.jar,
+- epubcheck/lib/sac-1.3.jar,
+- epubcheck/lib/saxon-9.1.0.8.jar,
+- epubcheck/lib/slf4j-api-1.7.2.jar,
+- epubcheck/lib/slf4j-nop-1.7.2.jar
+ Import-Package: org.junit
+ Export-Package: org.eclipse.mylyn.docs.epub.tests;x-internal:=true,
+ org.eclipse.mylyn.docs.epub.tests.ant;x-internal:=true,
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/build.properties b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/build.properties
+index a4231cf..106d4c3 100644
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/build.properties
++++ b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/build.properties
+@@ -15,14 +15,5 @@ bin.includes = META-INF/,\
+ OSGI-INF/l10n/bundle.properties,\
+ OSGI-INF/,\
+ testdata/,\
+- about.html,\
+- epubcheck/epubcheck-3.0-RC-1.jar,\
+- epubcheck/lib/commons-compress-1.4.1.jar,\
+- epubcheck/lib/jing-20120724.0.0.jar,\
+- epubcheck/lib/phloc-commons-3.8.4.jar,\
+- epubcheck/lib/phloc-css-3.2.1.jar,\
+- epubcheck/lib/sac-1.3.jar,\
+- epubcheck/lib/saxon-9.1.0.8.jar,\
+- epubcheck/lib/slf4j-api-1.7.2.jar,\
+- epubcheck/lib/slf4j-nop-1.7.2.jar
++ about.html
+ src.includes = about.html
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/AllTests.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/AllTests.java
+index b956e62..91031f7 100644
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/AllTests.java
++++ b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/AllTests.java
+@@ -14,9 +14,6 @@ package org.eclipse.mylyn.docs.epub.tests;
+ import junit.framework.Test;
+ import junit.framework.TestSuite;
+
+-import org.eclipse.mylyn.docs.epub.tests.api.TestEPUB;
+-import org.eclipse.mylyn.docs.epub.tests.api.TestOPS2Publication;
+-import org.eclipse.mylyn.docs.epub.tests.api.TestOPSPublication;
+ import org.eclipse.mylyn.docs.epub.tests.core.TestEPUBFileUtil;
+ import org.eclipse.mylyn.docs.epub.tests.core.TestOPSValidator;
+ import org.eclipse.mylyn.docs.epub.tests.core.TestTOCGenerator;
+@@ -30,9 +27,6 @@ public class AllTests {
+ public static Test suite(boolean defaultOnly) {
+ TestSuite suite = new TestSuite("Tests for org.eclipse.mylyn.docs.epub");
+ // API tests
+- suite.addTestSuite(TestEPUB.class);
+- suite.addTestSuite(TestOPS2Publication.class);
+- suite.addTestSuite(TestOPSPublication.class);
+ // Core tests
+ suite.addTestSuite(TestEPUBFileUtil.class);
+ suite.addTestSuite(TestOPSValidator.class);
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ValidationReport.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ValidationReport.java
+deleted file mode 100644
+index 40b0a54..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ValidationReport.java
++++ /dev/null
+@@ -1,80 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2012 Torkild U. Resheim and others.
+- * All rights reserved. This program and the accompanying materials
+- * are made available under the terms of the Eclipse Public License v1.0
+- * which accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-
+-package org.eclipse.mylyn.docs.epub.tests;
+-
+-import java.util.ArrayList;
+-
+-import com.adobe.epubcheck.api.Report;
+-import com.adobe.epubcheck.util.FeatureEnum;
+-
+-public class ValidationReport implements Report {
+-
+- private final ArrayList<String> errors;
+-
+- private final ArrayList<String> warnings;
+-
+- private final String ePubName;
+-
+- public ValidationReport(String ePubName) {
+- this.ePubName = ePubName;
+- errors = new ArrayList<String>();
+- warnings = new ArrayList<String>();
+- }
+-
+- @SuppressWarnings("nls")
+- public void error(String resource, int line, int column, String message) {
+- String log = "ERROR: " + ePubName + (resource == null ? "" : "/" + resource)
+- + (line <= 0 ? "" : "(" + line + ")") + ": " + message;
+- errors.add(log);
+- }
+-
+- public String getErrors() {
+- StringBuilder sb = new StringBuilder();
+- for (String error : errors) {
+- sb.append("\n"); //$NON-NLS-1$
+- sb.append(error);
+- }
+- return sb.toString();
+- }
+-
+- public void exception(String arg0, Exception arg1) {
+- // ignore
+- }
+-
+- @SuppressWarnings("nls")
+- public void warning(String resource, int line, String message) {
+- System.err.println("WARNING: " + ePubName + (resource == null ? "" : "/" + resource)
+- + (line <= 0 ? "" : "(" + line + ")") + ": " + message);
+- }
+-
+- public int getErrorCount() {
+- return errors.size();
+- }
+-
+- public int getExceptionCount() {
+- return 0;
+- }
+-
+- public int getWarningCount() {
+- return warnings.size();
+- }
+-
+- public void info(String arg0, FeatureEnum arg1, String arg2) {
+- // ignore
+-
+- }
+-
+- public void warning(String arg0, int arg1, int arg2, String arg3) {
+- // ignore
+-
+- }
+-}
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ant/TestAntTask.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ant/TestAntTask.java
+deleted file mode 100644
+index 3afc45e..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/ant/TestAntTask.java
++++ /dev/null
+@@ -1,67 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2011,2012 Torkild U. Resheim.
+- *
+- * All rights reserved. This program and the accompanying materials are made
+- * available under the terms of the Eclipse Public License v1.0 which
+- * accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-package org.eclipse.mylyn.docs.epub.tests.ant;
+-
+-import java.io.File;
+-import java.io.PrintWriter;
+-import java.io.StringWriter;
+-
+-import org.apache.tools.ant.BuildFileTest;
+-
+-import com.adobe.epubcheck.api.EpubCheck;
+-
+-/**
+- * Tests for the <b>epub</b> ANT task.
+- *
+- * @author Torkild U. Resheim
+- */
+- at SuppressWarnings("nls")
+-public class TestAntTask extends BuildFileTest {
+-
+- static ClassLoader classLoader;
+-
+- private static final String SIMPLE_FILE_PATH = "test/ant/simple.epub";
+-
+- public TestAntTask(String s) {
+- super(s);
+- classLoader = getClass().getClassLoader();
+- }
+-
+- private void assertEpub(String file) {
+- File f = getFile(file);
+- assertTrue("Missing publication " + file, f.exists());
+- StringWriter sw = new StringWriter();
+- PrintWriter pw = new PrintWriter(sw);
+- EpubCheck checker = new EpubCheck(f, pw);
+- assertTrue(sw.getBuffer().toString().trim(), checker.validate());
+- }
+-
+- private File getFile(String file) {
+- return new File(getProjectDir().getAbsolutePath() + File.separator + file);
+- }
+-
+- @Override
+- public void setUp() {
+- configureProject("ant-test.xml");
+- project.setCoreLoader(this.getClass().getClassLoader());
+- }
+-
+- /**
+- * Creates a simple book using the Ant task and tests it using the epub validator.
+- */
+- public void testSimplePublication() {
+- executeTarget("init");
+- executeTarget("test.publication");
+- assertEpub(SIMPLE_FILE_PATH);
+- }
+-
+-}
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/AbstractTest.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/AbstractTest.java
+deleted file mode 100644
+index 5e00306..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/AbstractTest.java
++++ /dev/null
+@@ -1,167 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2011,2012 Torkild U. Resheim.
+- *
+- * All rights reserved. This program and the accompanying materials are made
+- * available under the terms of the Eclipse Public License v1.0 which
+- * accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-package org.eclipse.mylyn.docs.epub.tests.api;
+-
+-import java.io.File;
+-
+-import junit.framework.TestCase;
+-
+-import org.eclipse.emf.ecore.EStructuralFeature;
+-import org.eclipse.emf.ecore.util.FeatureMap;
+-import org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList;
+-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+-import org.eclipse.mylyn.docs.epub.core.EPUB;
+-import org.eclipse.mylyn.docs.epub.core.ILogger;
+-import org.eclipse.mylyn.docs.epub.core.OPSPublication;
+-import org.eclipse.mylyn.docs.epub.core.Publication;
+-import org.eclipse.mylyn.docs.epub.dc.DCType;
+-import org.eclipse.mylyn.docs.epub.dc.Identifier;
+-import org.eclipse.mylyn.docs.epub.tests.ValidationReport;
+-import org.junit.After;
+-import org.junit.Before;
+-
+-import com.adobe.epubcheck.api.EpubCheck;
+-
+- at SuppressWarnings("nls")
+-public abstract class AbstractTest extends TestCase {
+-
+- private static final boolean DEBUGGING = false;;
+-
+- private boolean errorExpected;
+-
+- private class StdOutLogger implements ILogger {
+-
+- public void log(String message) {
+- log(message, Severity.INFO);
+- }
+-
+- public void log(String message, Severity severity) {
+- if (DEBUGGING) {
+- switch (severity) {
+- case ERROR:
+- System.out.print("[ERROR] ");
+- break;
+- case DEBUG:
+- System.out.print("[DEBUG] ");
+- break;
+- case INFO:
+- System.out.print("[INFO ] ");
+- break;
+- case VERBOSE:
+- System.out.print("[VERBO] ");
+- break;
+- case WARNING:
+- System.out.print("[WARN ] ");
+- break;
+- default:
+- break;
+- }
+- System.out.println(message);
+- }
+- }
+- }
+-
+- protected static final EStructuralFeature TEXT = XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text();
+-
+- protected EPUB epub;
+-
+- protected final File epubFile = new File("test" + File.separator + "test.epub");
+-
+- protected final File epubFolder = new File("test" + File.separator + "epub");
+-
+- protected final StdOutLogger logger = new StdOutLogger();
+-
+- protected Publication oebps;
+-
+- protected boolean deleteFolder(File folder) {
+- if (folder.isDirectory()) {
+- String[] children = folder.list();
+- for (String element : children) {
+- boolean ok = deleteFolder(new File(folder, element));
+- if (!ok) {
+- return false;
+- }
+- }
+- }
+- return folder.delete();
+- }
+-
+- @SuppressWarnings("rawtypes")
+- public String getText(DCType identifier) {
+- FeatureMap fm = identifier.getMixed();
+- Object o = fm.get(TEXT, false);
+- if (o instanceof FeatureEList) {
+- if (((FeatureEList) o).size() > 0) {
+- return ((FeatureEList) o).get(0).toString();
+- }
+- }
+- return null;
+- }
+-
+- @SuppressWarnings("rawtypes")
+- public String getText(Identifier element) {
+- FeatureMap fm = element.getMixed();
+- Object o = fm.get(TEXT, false);
+- if (o instanceof FeatureEList) {
+- if (((FeatureEList) o).size() > 0) {
+- return ((FeatureEList) o).get(0).toString();
+- }
+- }
+- return null;
+- }
+-
+- /**
+- * @throws java.lang.Exception
+- */
+- @Override
+- @Before
+- public void setUp() throws Exception {
+- errorExpected = false;
+- if (epubFile.exists()) {
+- epubFile.delete();
+- }
+- if (epubFolder.exists()) {
+- deleteFolder(epubFolder);
+- }
+- epubFolder.mkdirs();
+- epub = new EPUB(logger);
+- oebps = new OPSPublication(logger);
+- }
+-
+- /**
+- * Call this method in a test when an EPUB validation error is expected.
+- */
+- protected void setErrorExpected() {
+- errorExpected = true;
+- }
+-
+- /**
+- * @throws java.lang.Exception
+- */
+- @Override
+- @After
+- public void tearDown() throws Exception {
+- if (epubFolder.exists()) {
+- deleteFolder(epubFolder);
+- }
+- if (epubFile.exists()) {
+- ValidationReport report = new ValidationReport(epubFile.toString());
+- EpubCheck checker = new EpubCheck(epubFile, report);
+- checker.validate();
+- final String logMessage = report.getErrors();
+- epubFile.delete();
+- if (!errorExpected && report.getErrorCount() > 0) {
+- fail(logMessage);
+- }
+- }
+- }
+-}
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestEPUB.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestEPUB.java
+deleted file mode 100644
+index 89bf6a6..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestEPUB.java
++++ /dev/null
+@@ -1,395 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2011,2012 Torkild U. Resheim.
+- *
+- * All rights reserved. This program and the accompanying materials are made
+- * available under the terms of the Eclipse Public License v1.0 which
+- * accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-package org.eclipse.mylyn.docs.epub.tests.api;
+-
+-import java.io.BufferedReader;
+-import java.io.File;
+-import java.io.FileReader;
+-import java.io.IOException;
+-
+-import org.eclipse.emf.common.util.EList;
+-import org.eclipse.mylyn.docs.epub.core.EPUB;
+-import org.eclipse.mylyn.docs.epub.core.OPSPublication;
+-import org.eclipse.mylyn.docs.epub.core.Publication;
+-import org.eclipse.mylyn.docs.epub.ocf.Container;
+-import org.eclipse.mylyn.docs.epub.ocf.RootFile;
+-import org.eclipse.mylyn.docs.epub.ocf.RootFiles;
+-import org.junit.Test;
+-
+-/**
+- * @author Torkild U. Resheim
+- */
+- at SuppressWarnings("nls")
+-public class TestEPUB extends AbstractTest {
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#EPUB()}.
+- * <p>
+- * It must be possible to obtain the publication list which must be empty.
+- * </p>
+- */
+- @Test
+- public final void testEPUB() {
+- EPUB epub = new EPUB();
+- assertEquals(true, epub.getOPSPublications().isEmpty());
+-
+- }
+-
+- /**
+- * 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);
+- }
+-
+- /**
+- * 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) {
+- }
+- }
+-
+- /**
+- * 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);
+- }
+-
+- /**
+- * 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());
+- }
+-
+- /**
+- * 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());
+- }
+-
+- /**
+- * 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());
+- }
+-
+- /**
+- * 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) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#pack(java.io.File)} .
+- * <ul>
+- * <li>Exception shall be thrown if the EPUB is empty.</li>
+- * </ul>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testPackMissingPublication() throws Exception {
+- try {
+- epub.pack(epubFile);
+- fail();
+- } catch (Exception e) {
+- }
+- }
+-
+- /**
+- * 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());
+- }
+-
+- /**
+- * 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());
+- }
+-
+- private class EPUB_OCF_Test extends EPUB {
+- public void testReadOCF(File workingFolder) throws IOException {
+- readOCF(workingFolder);
+- }
+- }
+-
+- /**
+- * See if the OCF file generated by this tooling can be read. As of bug 378800 elements are no longer prefixed with
+- * "ocf", however both are allowed and tested for.
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testReadOCF_Dogfood() throws Exception {
+- EPUB_OCF_Test epub = new EPUB_OCF_Test();
+-
+- File workingFolder = new File("testdata/OCF-Tests/Dogfood");
+- epub.testReadOCF(workingFolder);
+-
+- workingFolder = new File("testdata/OCF-Tests/Bug_378800");
+- epub.testReadOCF(workingFolder);
+- }
+-
+- /**
+- * This case was discovered when testing an EPUB file generated by DocBook Reading the OCF fails with a
+- * java.net.SocketException: Unexpected end of file from server. On closer inspection we can see that the file is
+- * declared as XHTML (which it of course is not). This is probably due to an issue in DocBook XSL 1.76.1
+- *
+- * @see http://sourceforge.net/tracker/index.php?func=detail&aid=3353537 &group_id=21935&atid=373747.
+- * @throws Exception
+- */
+- @Test
+- public final void testReadOCF_SocketException() throws Exception {
+- File workingFolder = new File("testdata/OCF-Tests/SocketException");
+- EPUB_OCF_Test epub = new EPUB_OCF_Test();
+- epub.testReadOCF(workingFolder);
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377705">bug 377705</a>: [epub] Fail
+- * gracefully when opening an unsupported file
+- * <p>
+- * When attempting to open a file that is not an EPUB the tooling shall reply by throwing an
+- * {@link IllegalArgumentException}.
+- * </p>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug377705() throws Exception {
+- EPUB epub = new EPUB();
+- File drawing = new File("testdata/drawing.svg");
+- File epub_2 = new File("testdata/epub/basic_2.epub");
+- assertEquals(false, epub.isEPUB(drawing));
+- assertEquals(true, epub.isEPUB(epub_2));
+- try {
+- epub.unpack(drawing);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- try {
+- epub.unpack(epub_2);
+- } catch (Exception e) {
+- fail();
+- }
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=378214">bug 378214</a>: [epub] Problem
+- * when opening an EPUB3 file
+- * <p>
+- * There must be no OPS publications in the EPUB as there are none that are supported when reading an EPUB 3 file.
+- * Also there must be no exceptions thrown.
+- * </p>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug378214() throws Exception {
+- EPUB epub = new EPUB();
+- File epub_3 = new File("testdata/epub/basic_3.epub");
+- assertEquals(true, epub.isEPUB(epub_3));
+- epub.unpack(epub_3);
+- assertEquals(0, epub.getOPSPublications().size());
+- }
+-
+- /**
+- * 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);
+- File metaFolder = new File(epubFolder.getAbsolutePath() + File.separator + "META-INF"); //$NON-NLS-1$
+- File containerFile = new File(metaFolder.getAbsolutePath() + File.separator + "container.xml"); //$NON-NLS-1$
+- 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);
+- }
+-}
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPS2Publication.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPS2Publication.java
+deleted file mode 100644
+index db60fb7..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPS2Publication.java
++++ /dev/null
+@@ -1,323 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2011,2012 Torkild U. Resheim.
+- *
+- * All rights reserved. This program and the accompanying materials are made
+- * available under the terms of the Eclipse Public License v1.0 which
+- * accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-package org.eclipse.mylyn.docs.epub.tests.api;
+-
+-import java.io.File;
+-import java.io.IOException;
+-
+-import org.eclipse.emf.ecore.EStructuralFeature;
+-import org.eclipse.emf.ecore.util.FeatureMap;
+-import org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList;
+-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+-import org.eclipse.mylyn.docs.epub.core.EPUB;
+-import org.eclipse.mylyn.docs.epub.core.OPSPublication;
+-import org.eclipse.mylyn.docs.epub.core.Publication;
+-import org.eclipse.mylyn.docs.epub.core.ValidationMessage;
+-import org.eclipse.mylyn.docs.epub.core.ValidationMessage.Severity;
+-import org.eclipse.mylyn.docs.epub.ncx.Meta;
+-import org.eclipse.mylyn.docs.epub.ncx.NavPoint;
+-import org.eclipse.mylyn.docs.epub.ncx.Ncx;
+-import org.eclipse.mylyn.docs.epub.opf.Item;
+-import org.junit.Test;
+-
+-/**
+- * Tests features and regressions specific to the OPS 2.0.1 supporting implementation {@link OPSPublication}.
+- *
+- * @author Torkild U. Resheim
+- */
+- at SuppressWarnings("nls")
+-public class TestOPS2Publication extends AbstractTest {
+-
+- private static final EStructuralFeature TEXT = XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text();
+-
+- private final static String TOCFILE_ID = "3063f615-672e-4083-911a-65c5ff245e75";
+-
+- @SuppressWarnings("rawtypes")
+- public String getText(Object element) {
+- if (element instanceof NavPoint) {
+- FeatureMap fm = ((NavPoint) element).getNavLabels().get(0).getText().getMixed();
+- Object o = fm.get(TEXT, false);
+- if (o instanceof FeatureEList) {
+- if (((FeatureEList) o).size() > 0) {
+- return ((FeatureEList) o).get(0).toString();
+- }
+- }
+- }
+- if (element instanceof Meta) {
+- Object o = ((Meta) element).getContent();
+- return o.toString();
+- }
+- return "null";
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#generateTableOfContents()} .
+- * <ul>
+- * <li>Table of contents shall be generated from content per default.</li>
+- * </ul>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testGenerateTableOfContents() throws Exception {
+- epub.add(oebps);
+- oebps.addItem(new File("testdata/plain-page.xhtml"));
+- epub.pack(epubFile);
+- assertTrue(oebps.getTableOfContents() != null);
+- assertTrue(oebps.getTableOfContents() instanceof Ncx);
+- Ncx ncx = (Ncx) oebps.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));
+- epubFile.delete();
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#generateTableOfContents()} .
+- * <ul>
+- * <li>Table of contents shall exist but be empty if not otherwise specified.</li>
+- * </ul>
+- *
+- * @throws Exception
+- */
+- public final void testGenerateEmptyTableOfContents() throws Exception {
+- setErrorExpected();
+- epub.add(oebps);
+- oebps.addItem(new File("testdata/plain-page.xhtml"));
+- oebps.setGenerateToc(false);
+- epub.pack(epubFile);
+- assertTrue(oebps.getTableOfContents() != null);
+- assertTrue(oebps.getTableOfContents() instanceof Ncx);
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#getTableOfContents()} .
+- * <ul>
+- * <li>There shall be a table of contents, even if empty.</li>
+- * </ul>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testGetTableOfContents() throws Exception {
+- epub.add(oebps);
+- assertTrue(oebps.getTableOfContents() != null);
+- assertTrue(oebps.getTableOfContents() instanceof Ncx);
+- }
+-
+- /**
+- * 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));
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#setTableOfContents(java.io.File)} .
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testSetTableOfContents() throws Exception {
+- oebps.setTableOfContents(new File("testdata/toc.ncx"));
+- 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));
+- Meta meta = ncx.getHead().getMetas().get(0);
+- String id = getText(meta);
+- // The UUID for the NCX file should be different if it comes from
+- // another NCX than the one specified.
+- assertTrue(TOCFILE_ID.equals(id));
+-
+- }
+-
+- /**
+- * 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 {
+- setErrorExpected();
+- 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\""));
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=379052">bug 379052</a>: OPS validator
+- * should handle all XHTML in the manifest
+- * <p>
+- * The test will add one XHTML file that links to another XHTML file that should be validated and one that should
+- * not
+- * </p>
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug379052() throws Exception {
+- oebps.setIncludeReferencedResources(true);
+- epub.add(oebps);
+- oebps.addItem(new File("testdata/OPF-Tests/Bug_379052/chapter-1.xhtml"));
+- epub.pack(epubFile);
+- // Two XHTML files, one with a warning. One CSS file and the NCX.
+- assertEquals(4, oebps.getPackage().getManifest().getItems().size());
+- // Should be exactly two warning.
+- assertEquals(1, oebps.getValidationMessages().size());
+- epubFile.delete();
+- }
+-
+- /**
+- * 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 {
+- setErrorExpected();
+- 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."));
+- }
+-
+- /**
+- * 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 {
+- setErrorExpected();
+- 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."));
+- }
+-
+- /**
+- * 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."));
+- }
+-
+- private class EPUB_NCX_Test extends OPSPublication {
+- public void testReadOCF(File tocFile) throws IOException {
+- readTableOfContents(tocFile);
+- }
+- }
+-
+- /**
+- * See if the NCX file generated by this tooling can be read.
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testReadNCX_Dogfood() throws Exception {
+- File workingFolder = new File("testdata/NCX-Tests/Dogfood/toc.ncx");
+- EPUB_NCX_Test epub = new EPUB_NCX_Test();
+- epub.testReadOCF(workingFolder);
+- }
+-
+- /**
+- * This case was discovered when testing an EPUB file generated by DocBook Reading the NCX fails with a
+- * java.net.SocketException: Unexpected end of file from server. On closer inspection we can see that the file is
+- * declared as XHTML (which it of course is not). This is probably due to an issue in DocBook XSL 1.76.1
+- *
+- * @see http://sourceforge.net/tracker/index.php?func=detail&aid=3353537&group_id=21935&atid=373747.
+- * @throws Exception
+- */
+- @Test
+- public final void testReadNCX_SocketException() throws Exception {
+- File workingFolder = new File("testdata/NCX-Tests/SocketException/toc.ncx");
+- EPUB_NCX_Test epub = new EPUB_NCX_Test();
+- epub.testReadOCF(workingFolder);
+- }
+-
+-}
+diff --git a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPSPublication.java b/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPSPublication.java
+deleted file mode 100644
+index bee8100..0000000
+--- a/org.eclipse.mylyn.docs/org.eclipse.mylyn.docs.epub.tests/src/org/eclipse/mylyn/docs/epub/tests/api/TestOPSPublication.java
++++ /dev/null
+@@ -1,885 +0,0 @@
+-/*******************************************************************************
+- * Copyright (c) 2011-2014 Torkild U. Resheim.
+- *
+- * All rights reserved. This program and the accompanying materials are made
+- * available under the terms of the Eclipse Public License v1.0 which
+- * accompanies this distribution, and is available at
+- * http://www.eclipse.org/legal/epl-v10.html
+- *
+- * Contributors:
+- * Torkild U. Resheim - initial API and implementation
+- *******************************************************************************/
+-package org.eclipse.mylyn.docs.epub.tests.api;
+-
+-import java.io.File;
+-import java.io.FileWriter;
+-import java.io.IOException;
+-import java.util.List;
+-import java.util.Locale;
+-
+-import org.eclipse.emf.common.util.Diagnostic;
+-import org.eclipse.emf.common.util.EList;
+-import org.eclipse.mylyn.docs.epub.core.EPUB;
+-import org.eclipse.mylyn.docs.epub.core.OPSPublication;
+-import org.eclipse.mylyn.docs.epub.core.Publication;
+-import org.eclipse.mylyn.docs.epub.core.ValidationException;
+-import org.eclipse.mylyn.docs.epub.dc.Contributor;
+-import org.eclipse.mylyn.docs.epub.dc.Coverage;
+-import org.eclipse.mylyn.docs.epub.dc.Date;
+-import org.eclipse.mylyn.docs.epub.dc.Description;
+-import org.eclipse.mylyn.docs.epub.dc.Identifier;
+-import org.eclipse.mylyn.docs.epub.dc.Publisher;
+-import org.eclipse.mylyn.docs.epub.dc.Relation;
+-import org.eclipse.mylyn.docs.epub.dc.Rights;
+-import org.eclipse.mylyn.docs.epub.dc.Source;
+-import org.eclipse.mylyn.docs.epub.dc.Subject;
+-import org.eclipse.mylyn.docs.epub.dc.Title;
+-import org.eclipse.mylyn.docs.epub.opf.Item;
+-import org.eclipse.mylyn.docs.epub.opf.Role;
+-import org.junit.Assert;
+-import org.junit.Test;
+-
+-import com.adobe.epubcheck.api.EpubCheck;
+-import com.adobe.epubcheck.api.Report;
+-import com.adobe.epubcheck.util.DefaultReportImpl;
+-
+-/**
+- * Tests features and regressions for all versions of the OPS supporting implementation {@link Publication}.
+- *
+- * @author Torkild U. Resheim
+- */
+- at SuppressWarnings("nls")
+-public class TestOPSPublication extends AbstractTest {
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addContributor(java.lang.String, java.util.Locale, java.lang.String, org.eclipse.mylyn.docs.epub.opf.Role, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddContributor() {
+- Contributor contributor = oebps.addContributor("Nomen Nescio");
+- contributor.setRole(Role.AUTHOR);
+-
+- oebps.addContributor(null, null, "Nomen Nescio", Role.AUTHOR, null);
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addCoverage(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddCoverage() {
+- oebps.addCoverage("Coverage", Locale.CANADA_FRENCH, "My Coverage");
+- oebps.addCoverage(null, Locale.CANADA_FRENCH, "My Coverage");
+- oebps.addCoverage(null, null, "My Coverage");
+- EList<Coverage> Coverages = oebps.getPackage().getMetadata().getCoverages();
+- Assert.assertEquals("Coverage", Coverages.get(0).getId());
+- Assert.assertEquals("fr_CA", Coverages.get(0).getLang());
+- Assert.assertEquals("My Coverage", getText(Coverages.get(0)));
+- Assert.assertEquals(null, Coverages.get(1).getId());
+- Assert.assertEquals("fr_CA", Coverages.get(1).getLang());
+- Assert.assertEquals("My Coverage", getText(Coverages.get(1)));
+- Assert.assertEquals(null, Coverages.get(2).getId());
+- Assert.assertEquals(null, Coverages.get(2).getLang());
+- Assert.assertEquals("My Coverage", getText(Coverages.get(2)));
+- try {
+- oebps.addCoverage(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addCreator(java.lang.String, java.util.Locale, java.lang.String, org.eclipse.mylyn.docs.epub.opf.Role, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddCreator() {
+- // TODO
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addDate(java.lang.String, java.util.Date, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddDateStringDateString() {
+- // TODO
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addDate(java.lang.String, java.lang.String, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddDateStringStringString() {
+- oebps.addDate(null, "1969", null);
+- oebps.addDate(null, "1969-03", null);
+- oebps.addDate(null, "1969-03-14", null);
+- oebps.addDate(null, "1969-03-14", "event");
+- EList<Date> dates = oebps.getPackage().getMetadata().getDates();
+- assertEquals("1969", getText(dates.get(0)));
+- assertEquals("1969-03", getText(dates.get(1)));
+- assertEquals("1969-03-14", getText(dates.get(2)));
+- assertEquals("event", dates.get(3).getEvent());
+- try {
+- oebps.addDate(null, (String) null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addDescription(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddDescription() {
+- oebps.addDescription("Description", Locale.CANADA_FRENCH, "My Description");
+- oebps.addDescription(null, Locale.CANADA_FRENCH, "My Description");
+- oebps.addDescription(null, null, "My Description");
+- EList<Description> Descriptions = oebps.getPackage().getMetadata().getDescriptions();
+- Assert.assertEquals("Description", Descriptions.get(0).getId());
+- Assert.assertEquals("fr_CA", Descriptions.get(0).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(0)));
+- Assert.assertEquals(null, Descriptions.get(1).getId());
+- Assert.assertEquals("fr_CA", Descriptions.get(1).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(1)));
+- Assert.assertEquals(null, Descriptions.get(2).getId());
+- Assert.assertEquals(null, Descriptions.get(2).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(2)));
+- try {
+- oebps.addDescription(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addFormat(java.lang.String, java.lang.String)} .
+- */
+- @Test
+- public final void testAddFormat() {
+- oebps.addDescription("Description", Locale.CANADA_FRENCH, "My Description");
+- oebps.addDescription(null, Locale.CANADA_FRENCH, "My Description");
+- oebps.addDescription(null, null, "My Description");
+- EList<Description> Descriptions = oebps.getPackage().getMetadata().getDescriptions();
+- Assert.assertEquals("Description", Descriptions.get(0).getId());
+- Assert.assertEquals("fr_CA", Descriptions.get(0).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(0)));
+- Assert.assertEquals(null, Descriptions.get(1).getId());
+- Assert.assertEquals("fr_CA", Descriptions.get(1).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(1)));
+- Assert.assertEquals(null, Descriptions.get(2).getId());
+- Assert.assertEquals(null, Descriptions.get(2).getLang());
+- Assert.assertEquals("My Description", getText(Descriptions.get(2)));
+- try {
+- oebps.addDescription(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addIdentifier(java.lang.String, java.lang.String, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddIdentifier() {
+- oebps.addIdentifier("Identifier", "ID", "My Identifier");
+- oebps.addIdentifier(null, "ID", "My Identifier");
+- oebps.addIdentifier(null, null, "My Identifier");
+- EList<Identifier> Identifiers = oebps.getPackage().getMetadata().getIdentifiers();
+- Assert.assertEquals("Identifier", Identifiers.get(0).getId());
+- Assert.assertEquals("ID", Identifiers.get(0).getScheme());
+- Assert.assertEquals("My Identifier", getText(Identifiers.get(0)));
+- Assert.assertEquals(null, Identifiers.get(1).getId());
+- Assert.assertEquals("ID", Identifiers.get(1).getScheme());
+- Assert.assertEquals("My Identifier", getText(Identifiers.get(1)));
+- Assert.assertEquals(null, Identifiers.get(2).getId());
+- Assert.assertEquals(null, Identifiers.get(2).getScheme());
+- Assert.assertEquals("My Identifier", getText(Identifiers.get(2)));
+- try {
+- oebps.addIdentifier(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#addItem(java.io.File)} .
+- */
+- @Test
+- public final void testAddItemFile() {
+- // TODO
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addItem(java.lang.String, java.util.Locale, java.io.File, java.lang.String, java.lang.String, boolean, boolean, boolean)}
+- * .
+- */
+- @Test
+- public final void testAddItemStringLocaleFileStringStringBooleanBooleanBoolean() {
+- // TODO
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addLanguage(java.lang.String, java.lang.String)} .
+- */
+- @Test
+- public final void testAddLanguage() {
+- oebps.addLanguage(null, "no");
+- oebps.addLanguage("id", "no");
+- Assert.assertEquals("no", getText(oebps.getPackage().getMetadata().getLanguages().get(0)));
+- Assert.assertEquals("id", oebps.getPackage().getMetadata().getLanguages().get(1).getId());
+- try {
+- oebps.addLanguage(null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#addMeta(java.lang.String, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddMeta() {
+- oebps.addMeta("name", "value");
+- assertEquals("name", oebps.getPackage().getMetadata().getMetas().get(0).getName());
+- assertEquals("value", oebps.getPackage().getMetadata().getMetas().get(0).getContent());
+- try {
+- oebps.addMeta(null, "value");
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- try {
+- oebps.addMeta("name", null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addPublisher(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddPublisher() {
+- oebps.addPublisher("Publisher", Locale.CANADA_FRENCH, "My Publisher");
+- oebps.addPublisher(null, Locale.CANADA_FRENCH, "My Publisher");
+- oebps.addPublisher(null, null, "My Publisher");
+- EList<Publisher> Publishers = oebps.getPackage().getMetadata().getPublishers();
+- Assert.assertEquals("Publisher", Publishers.get(0).getId());
+- Assert.assertEquals("fr_CA", Publishers.get(0).getLang());
+- Assert.assertEquals("My Publisher", getText(Publishers.get(0)));
+- Assert.assertEquals(null, Publishers.get(1).getId());
+- Assert.assertEquals("fr_CA", Publishers.get(1).getLang());
+- Assert.assertEquals("My Publisher", getText(Publishers.get(1)));
+- Assert.assertEquals(null, Publishers.get(2).getId());
+- Assert.assertEquals(null, Publishers.get(2).getLang());
+- Assert.assertEquals("My Publisher", getText(Publishers.get(2)));
+- try {
+- oebps.addPublisher(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addReference(java.lang.String, java.lang.String, org.eclipse.mylyn.docs.epub.opf.Type)}
+- * .
+- */
+- @Test
+- public final void testAddReference() {
+- // TODO
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addRelation(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddRelation() {
+- oebps.addRelation("Relation", Locale.CANADA_FRENCH, "My Relation");
+- oebps.addRelation(null, Locale.CANADA_FRENCH, "My Relation");
+- oebps.addRelation(null, null, "My Relation");
+- EList<Relation> Relations = oebps.getPackage().getMetadata().getRelations();
+- Assert.assertEquals("Relation", Relations.get(0).getId());
+- Assert.assertEquals("fr_CA", Relations.get(0).getLang());
+- Assert.assertEquals("My Relation", getText(Relations.get(0)));
+- Assert.assertEquals(null, Relations.get(1).getId());
+- Assert.assertEquals("fr_CA", Relations.get(1).getLang());
+- Assert.assertEquals("My Relation", getText(Relations.get(1)));
+- Assert.assertEquals(null, Relations.get(2).getId());
+- Assert.assertEquals(null, Relations.get(2).getLang());
+- Assert.assertEquals("My Relation", getText(Relations.get(2)));
+- try {
+- oebps.addRelation(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addRights(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddRights() {
+- oebps.addRights("Rights", Locale.CANADA_FRENCH, "My Rights");
+- oebps.addRights(null, Locale.CANADA_FRENCH, "My Rights");
+- oebps.addRights(null, null, "My Rights");
+- EList<Rights> Rightss = oebps.getPackage().getMetadata().getRights();
+- Assert.assertEquals("Rights", Rightss.get(0).getId());
+- Assert.assertEquals("fr_CA", Rightss.get(0).getLang());
+- Assert.assertEquals("My Rights", getText(Rightss.get(0)));
+- Assert.assertEquals(null, Rightss.get(1).getId());
+- Assert.assertEquals("fr_CA", Rightss.get(1).getLang());
+- Assert.assertEquals("My Rights", getText(Rightss.get(1)));
+- Assert.assertEquals(null, Rightss.get(2).getId());
+- Assert.assertEquals(null, Rightss.get(2).getLang());
+- Assert.assertEquals("My Rights", getText(Rightss.get(2)));
+- try {
+- oebps.addRights(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addSource(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddSource() {
+- oebps.addSource("Source", Locale.CANADA_FRENCH, "My Source");
+- oebps.addSource(null, Locale.CANADA_FRENCH, "My Source");
+- oebps.addSource(null, null, "My Source");
+- EList<Source> Sources = oebps.getPackage().getMetadata().getSources();
+- Assert.assertEquals("Source", Sources.get(0).getId());
+- Assert.assertEquals("fr_CA", Sources.get(0).getLang());
+- Assert.assertEquals("My Source", getText(Sources.get(0)));
+- Assert.assertEquals(null, Sources.get(1).getId());
+- Assert.assertEquals("fr_CA", Sources.get(1).getLang());
+- Assert.assertEquals("My Source", getText(Sources.get(1)));
+- Assert.assertEquals(null, Sources.get(2).getId());
+- Assert.assertEquals(null, Sources.get(2).getLang());
+- Assert.assertEquals("My Source", getText(Sources.get(2)));
+- // An IllegalArgumentException is expected
+- try {
+- oebps.addSource(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addSubject(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddSubject() {
+- oebps.addSubject("Subject", Locale.CANADA_FRENCH, "My Subject");
+- oebps.addSubject(null, Locale.CANADA_FRENCH, "My Subject");
+- oebps.addSubject(null, null, "My Subject");
+- EList<Subject> subjects = oebps.getPackage().getMetadata().getSubjects();
+- Assert.assertEquals("Subject", subjects.get(0).getId());
+- Assert.assertEquals("fr_CA", subjects.get(0).getLang());
+- Assert.assertEquals("My Subject", getText(subjects.get(0)));
+- Assert.assertEquals(null, subjects.get(1).getId());
+- Assert.assertEquals("fr_CA", subjects.get(1).getLang());
+- Assert.assertEquals("My Subject", getText(subjects.get(1)));
+- Assert.assertEquals(null, subjects.get(2).getId());
+- Assert.assertEquals(null, subjects.get(2).getLang());
+- Assert.assertEquals("My Subject", getText(subjects.get(2)));
+- try {
+- oebps.addSubject(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for
+- * {@link org.eclipse.mylyn.docs.epub.core.Publication#addTitle(java.lang.String, java.util.Locale, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddTitle() {
+- oebps.addTitle("Title", Locale.CANADA_FRENCH, "My Title");
+- oebps.addTitle(null, Locale.CANADA_FRENCH, "My Title");
+- oebps.addTitle(null, null, "My Title");
+- EList<Title> titles = oebps.getPackage().getMetadata().getTitles();
+- Assert.assertEquals("Title", titles.get(0).getId());
+- Assert.assertEquals("fr_CA", titles.get(0).getLang());
+- Assert.assertEquals("My Title", getText(titles.get(0)));
+- Assert.assertEquals(null, titles.get(1).getId());
+- Assert.assertEquals("fr_CA", titles.get(1).getLang());
+- Assert.assertEquals("My Title", getText(titles.get(1)));
+- Assert.assertEquals(null, titles.get(2).getId());
+- Assert.assertEquals(null, titles.get(2).getLang());
+- Assert.assertEquals("My Title", getText(titles.get(2)));
+- try {
+- oebps.addTitle(null, null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#addType(java.lang.String, java.lang.String)}
+- * .
+- */
+- @Test
+- public final void testAddType() {
+- oebps.addType("Type", "My Type");
+- oebps.addType(null, "My Type");
+- EList<org.eclipse.mylyn.docs.epub.dc.Type> Types = oebps.getPackage().getMetadata().getTypes();
+- Assert.assertEquals("Type", Types.get(0).getId());
+- Assert.assertEquals("My Type", getText(Types.get(0)));
+- Assert.assertEquals(null, Types.get(1).getId());
+- Assert.assertEquals("My Type", getText(Types.get(1)));
+- try {
+- oebps.addType(null, null);
+- fail();
+- } catch (IllegalArgumentException e) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#generateTableOfContents()} .
+- */
+- @Test
+- public final void testGenerateTableOfContents() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getIdentifier()}.
+- */
+- @Test
+- public final void testGetIdentifier() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getItemById(java.lang.String)} .
+- */
+- @Test
+- public final void testGetItemById() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getItemsByMIMEType(java.lang.String)} .
+- */
+- @Test
+- public final void testGetItemsByMIMEType() {
+- Item i_in_1 = oebps.addItem(new File("testdata/images/subfolder-drawing.svg"));
+- Item i_in_2 = oebps.addItem(new File("testdata/plain-page.xhtml"));
+- List<Item> i_out_1 = oebps.getItemsByMIMEType("image/svg+xml");
+- assertEquals(1, i_out_1.size());
+- assertEquals(i_in_1, i_out_1.get(0));
+- List<Item> i_out_2 = oebps.getItemsByMIMEType("application/xhtml+xml");
+- assertEquals(1, i_out_2.size());
+- assertEquals(i_in_2, i_out_2.get(0));
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getPackage()}.
+- */
+- @Test
+- public final void testGetOpfPackage() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getRootFolder()}.
+- */
+- @Test
+- public final void testGetRootFolder() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getSpine()}.
+- */
+- @Test
+- public final void testGetSpine() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getTableOfContents()} .
+- */
+- @Test
+- public final void testGetTableOfContents() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#getValidationMessages()} .
+- */
+- @Test
+- public final void testGetValidationMessages() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#pack(java.io.File)}. An EPUB where only a
+- * single page has been added shall be packed without issues
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testPack_EPUB2() throws Exception {
+- oebps.addItem(new File("testdata/plain-page.xhtml"));
+- epub.add(oebps);
+- epub.pack(epubFile);
+- oebps.validateMetadata();
+- Report report = new DefaultReportImpl(epubFile.toString());
+- EpubCheck checker = new EpubCheck(epubFile, report);
+- System.out.println("Validating plain EPUB 2.0.1 file");
+- System.out.println("Using version " + EpubCheck.VERSION + " of EpubCheck.");
+- Assert.assertTrue(checker.validate());
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#pack(java.io.File)}. An EPUB with no content
+- * shall fail when packed.
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testPack_Empty() throws Exception {
+- epub.add(new OPSPublication());
+- try {
+- epubFile.delete();
+- epub.pack(epubFile);
+- fail();
+- } catch (ValidationException e) {
+- }
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#readTableOfContents(java.io.File)} .
+- */
+- @Test
+- public final void testReadTableOfContents() {
+- // TODO
+- }
+-
+- /**
+- * 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);
+- 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());
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setGenerateToc(boolean)} .
+- */
+- @Test
+- public final void testSetGenerateToc() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setIdentifierId(java.lang.String)} .
+- */
+- @Test
+- public final void testSetIdentifierId() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setIncludeReferencedResources(boolean)}. This
+- * is determining whether or not the referenced resources has been picked up and included in the resulting EPUB.
+- * Also handles <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=375795">bug 375795</a>: [epub][patch]
+- * Automatic inclusion of referenced resources fail on anchor references
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testSetIncludeReferencedResources() throws Exception {
+- oebps.setIncludeReferencedResources(true);
+- oebps.addItem(new File("testdata/plain-page_link.xhtml"));
+- epub.add(oebps);
+- // Included resources will only be added when we pack
+- epub.pack(epubFile);
+-
+- EPUB epub2 = new EPUB();
+- epub2.unpack(epubFile, epubFolder);
+- 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.xhtml");
+- Assert.assertTrue(html.exists());
+- File html2 = new File(root.getAbsolutePath() + File.separator + "plain-page.xhtml");
+- Assert.assertTrue(html2.exists());
+- // The manifest shall only contain the items we have linked to in addition to the toc.ncx and the file that we
+- // started from -- a total of six files.
+- Assert.assertEquals(6, oebps.getPackage().getManifest().getItems().size());
+-
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380016">bug 380016</a>: Reference scanner
+- * should also include referenced CSS style sheets
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug380016() throws Exception {
+- setErrorExpected();
+- oebps.setIncludeReferencedResources(true);
+- oebps.addItem(new File("testdata/OPF-Tests/Bug_380016/chapter.xhtml"));
+- epub.add(oebps);
+- epub.pack(epubFile);
+- EPUB epub2 = new EPUB();
+- epub2.unpack(epubFile, epubFolder);
+- oebps = epub2.getOPSPublications().get(0);
+- File root = oebps.getRootFolder();
+- File svg = new File(root.getAbsolutePath() + File.separator + "style.css");
+- Assert.assertTrue(svg.exists());
+- }
+-
+- /**
+- * 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 {
+- setErrorExpected();
+- 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);
+- 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());
+-
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=373052">bug 373052</a>: [epub] Reference
+- * scanner does not handle absolute paths
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug373052() throws Exception {
+- setErrorExpected();
+- // We need to link to a absolute file so we create a temporary HTML file
+- // in which we have the link.m
+- File htmlFile = File.createTempFile("temp", ".xhtml");
+- File svgFile = new File("testdata/drawing.svg");
+-
+- FileWriter fw = new FileWriter(htmlFile);
+- // A proper declaration must be added or the file type cannot be
+- // correctly detected.
+- fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+- fw.write("<!DOCTYPE html\n"
+- + " PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
+- fw.write("<html xmlns=\"http://www.w3.org/1999/xhtml\"><body>");
+- fw.write("<img src=\"" + svgFile.getAbsolutePath() + "\"/>");
+- fw.write("</body></html>");
+- fw.close();
+-
+- oebps.setIncludeReferencedResources(true);
+- oebps.addItem(htmlFile);
+- epub.add(oebps);
+- epub.pack(epubFile);
+-
+- htmlFile.delete();
+-
+- EPUB epub2 = new EPUB();
+- epub2.unpack(epubFile, epubFolder);
+- oebps = epub2.getOPSPublications().get(0);
+- File root = oebps.getRootFolder();
+- File svg = new File(root.getAbsolutePath() + File.separator + "drawing.svg");
+- Assert.assertTrue(svg.exists());
+-
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=376312">bug 376312</a>: [epub] Automatic
+- * inclusion of detected resources may add the same resource twice or more
+- * <p>
+- * File A references file C as do file B. File C references file A. Before the fix there would be two instances of
+- * file C.
+- * </p>
+- *
+- * @throws Exception
+- */
+- public final void test_Bug376312() throws Exception {
+- setErrorExpected();
+- oebps.setIncludeReferencedResources(true);
+- oebps.addItem(new File("testdata/circular/file-a.xhtml"));
+- oebps.addItem(new File("testdata/circular/file-b.xhtml"));
+- epub.add(oebps);
+- epub.pack(epubFile);
+- EList<Item> items = oebps.getPackage().getManifest().getItems();
+- // File A, B, C and the NCX
+- assertEquals(4, items.size());
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setTableOfContents(java.io.File)} .
+- *
+- * @see TestOPS2Publication#testSetTableOfContents()
+- */
+- @Test
+- public final void testSetTableOfContents() {
+- // Handled by subclass test.
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#unpack(java.io.File)} .
+- */
+- @Test
+- public final void testUnpack() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#validateContents()} .
+- */
+- @Test
+- public final void testValidateContents() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#validateMetadata()} .
+- */
+- @Test
+- public final void testValidateMetadata() {
+- // TODO
+- }
+-
+- /**
+- * Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#writeTableOfContents(java.io.File)} .
+- */
+- @Test
+- public final void testWriteTableOfContents() {
+- // TODO
+- }
+-
+- private class EPUB_OPF_Test extends OPSPublication {
+- public void testReadOPF(File rootFile) throws IOException {
+- readOPF(rootFile);
+- }
+- }
+-
+- /**
+- * See if the OPF file generated by this tooling can be read.
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void testReadOCF_Dogfood() throws Exception {
+- File rootFile = new File("testdata/OPF-Tests/Dogfood/content.opf");
+- EPUB_OPF_Test epub = new EPUB_OPF_Test();
+- epub.testReadOPF(rootFile);
+- }
+-
+- /**
+- * This case was discovered when testing an EPUB file generated by DocBook Reading the OPF fails with a
+- * java.net.SocketException: Unexpected end of file from server. On closer inspection we can see that the file is
+- * declared as XHTML (which it of course is not). This is probably due to an issue in DocBook XSL 1.76.1
+- *
+- * @see http://sourceforge.net/tracker/index.php?func=detail&aid=3353537 &group_id=21935&atid=373747.
+- * @throws Exception
+- */
+- @Test
+- public final void testReadOCF_SocketException() throws Exception {
+- File rootFile = new File("testdata/OPF-Tests/SocketException/content.opf");
+- EPUB_OPF_Test oebps = new EPUB_OPF_Test();
+- oebps.testReadOPF(rootFile);
+- }
+-
+- /**
+- * Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380729">bug 380729</a>: Allow reference
+- * elements to have "other." types
+- *
+- * @throws Exception
+- */
+- @Test
+- public final void test_Bug380729() throws Exception {
+- // Validation is normally not performed when loading content. However
+- // the previous implementation of the reference type was an
+- // enumeration so it would fail when attempting to set it and there
+- // was no matching item. Hence this code should now pass as the OPF
+- // contains previously invalid values.
+- File rootFile = new File("testdata/OPF-Tests/Bug_380729/content.opf");
+- EPUB_OPF_Test oebps = new EPUB_OPF_Test();
+- oebps.testReadOPF(rootFile);
+-
+- // This is required for validation
+- oebps.addSubject(null, null, "Required subject");
+-
+- // Validate that "cover" and "other.ms-coverpage" already read from
+- // the OPF file is OK.
+- List<Diagnostic> problems = oebps.validateMetadata();
+- assertEquals(problems.size(), 0);
+-
+- // Add illegal reference type and see that we get an error
+- oebps.addReference("cover-page.xhtml", "cover", "invalid");
+- problems = oebps.validateMetadata();
+- assertEquals(problems.size(), 1);
+- }
+-}
diff --git a/eclipse-mylyn.spec b/eclipse-mylyn.spec
index fcc0ff9..a882490 100644
--- a/eclipse-mylyn.spec
+++ b/eclipse-mylyn.spec
@@ -11,7 +11,7 @@
Name: %{?scl_prefix}eclipse-mylyn
Summary: Eclipse Mylyn main feature.
Version: 3.12.0
-Release: 0.6.git20140509%{?dist}
+Release: 0.7.1.git20140509%{?dist}
License: EPL
URL: http://www.eclipse.org/mylyn
@@ -31,6 +31,7 @@ Patch3: %{pkg_name}-disable-online-tests.patch
Patch4: %{pkg_name}-merge-incubator.patch
Patch5: %{pkg_name}-bug-419133.patch
Patch6: lucene4.patch
+Patch7: %{pkg_name}-remove-epubcheck-tests.patch
BuildArch: noarch
@@ -53,6 +54,7 @@ BuildRequires: apache-commons-io >= 2.3
BuildRequires: ws-commons-util >= 1.0.1-21
BuildRequires: xmlrpc-client >= 3.1.3
BuildRequires: xmlrpc-common >= 3.1.3
+BuildRequires: xmlrpc-server >= 3.1.3
BuildRequires: rome >= 0.9-9
BuildRequires: httpcomponents-client >= 4.1.3-2
BuildRequires: httpcomponents-core >= 4.1.4
@@ -76,6 +78,7 @@ Requires: apache-commons-io >= 2.3
Requires: ws-commons-util >= 1.0.1-21
Requires: xmlrpc-client >= 3.1.3
Requires: xmlrpc-common >= 3.1.3
+Requires: xmlrpc-server >= 3.1.3
Requires: rome >= 0.9-9
Requires: xml-commons-apis
Requires: httpcomponents-client >= 4.1.3-2
@@ -269,6 +272,11 @@ Group: Development/Tools
%description sdk
Sources for all Mylyn bundles
+%package tests
+Summary: Mylyn test bundles
+%description tests
+All the test bundles for mylyn packages.
+
%prep
%setup -q -n eclipse-mylyn-%{tag}-fetched-src
tar xaf %{SOURCE7} -C org.eclipse.mylyn.tasks --strip-components=1
@@ -282,6 +290,7 @@ tar xaf %{SOURCE7} -C org.eclipse.mylyn.tasks --strip-components=1
pushd org.eclipse.mylyn.tasks
%patch6 -b .sav
popd
+%patch7 -p1
#Disable plugins we can live without and for some reason are redundant (unpackaged or causing build failures).
#There must be empty line after each %%pom_* macro invocation.
@@ -303,7 +312,19 @@ grep -l -r --include="pom.xml" maven-pmd-plugin . | ( while read pom_path; do %p
#Disable all tests (except one that was easier to build than patch dependent bundles.
# grep -v org.eclipse.mylyn.doc
-grep -l -r --include="pom.xml" "tests" . | ( while read pom_path; do echo `%pom_xpath_remove "*[local-name() = 'module' and contains(text(),'tests') and not(contains(text(),'tests.'))]" $pom_path` ; done ) ;
+#grep -l -r --include="pom.xml" "tests" . | ( while read pom_path; do echo `%pom_xpath_remove "*[local-name() = 'module' and contains(text(),'tests') and not(contains(text(),'tests.'))]" $pom_path` ; done ) ;
+# Disable tests for which the required bundles are not included in the update site
+%pom_disable_module org.eclipse.mylyn.wikitext.creole.tests org.eclipse.mylyn.docs
+%pom_disable_module org.eclipse.mylyn.tasks.activity.tests org.eclipse.mylyn.tasks
+%pom_disable_module org.eclipse.mylyn.bugzilla.rest.tests org.eclipse.mylyn.tasks/connector-bugzilla-rest
+
+#Correct hamcrest and mockito names
+sed -i -e "s/org.hamcrest;/org.hamcrest.core;/g" `find . -name MANIFEST.MF`
+sed -i -e "s/org.mockito;/org.mockito.mockito-core;/g" `find . -name MANIFEST.MF`
+sed -i -e "s/org.eclipse.core.runtime.compatibility.auth/org.eclipse.core.runtime.compatibility/g" `find . -name MANIFEST.MF`
+sed -i -e "s/org.apache.ant.source;/org.apache.ant;/g" `find . -name MANIFEST.MF`
+sed -i -e "s/org.apache.xmlrpc/org.apache.xmlrpc,org.apache.xmlrpc.common,org.apache.xmlrpc.server/g" org.eclipse.mylyn.commons/org.eclipse.mylyn.commons.tests/META-INF/MANIFEST.MF
+sed -i -e "s/org.apache.xmlrpc;bundle-version=\"3.0.0\"/org.apache.xmlrpc,org.apache.xmlrpc.common/g" org.eclipse.mylyn.tasks/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
#Remove all architectures that do not match current build architecture.
%pom_xpath_remove "*[local-name() = 'environment' and
@@ -374,6 +395,7 @@ pushd %{buildroot}%{install_loc}/mylyn/eclipse/plugins/
rm org.apache.xmlrpc_*.jar
ln -s %{_non_scl_javadir}/xmlrpc-client.jar
ln -s %{_non_scl_javadir}/xmlrpc-common.jar
+ ln -s %{_non_scl_javadir}/xmlrpc-server.jar
rm org.jdom_*.jar
ln -s %{_non_scl_javadir}/jdom.jar
@@ -404,6 +426,19 @@ done
install %{SOURCE6} %{buildroot}%{install_loc}/mylyn/eclipse/redhat-bugzilla-custom-transitions.txt
+# Collect and install test jars
+mkdir -p %{buildroot}%{_javadir}/mylyn-tests/plugins
+set +e
+for pom in `find . -name pom.xml`; do
+ grep -q '<packaging>eclipse-test-plugin</packaging>' ${pom}
+ if [ $? -eq 0 ]; then
+ ls ${pom/pom.xml/}'target/'
+ testjar=`ls ${pom/pom.xml/}'target/'*.jar | grep -v sources`
+ mv ${testjar} %{buildroot}%{_javadir}/mylyn-tests/plugins
+ fi
+done
+set -e
+
%files
%dir %{install_loc}/mylyn
%dir %{install_loc}/mylyn/eclipse
@@ -456,6 +491,7 @@ install %{SOURCE6} %{buildroot}%{install_loc}/mylyn/eclipse/redhat-bugzilla-cust
%{install_loc}/mylyn/eclipse/plugins/rome*.jar
%{install_loc}/mylyn/eclipse/plugins/xmlrpc-client.jar
%{install_loc}/mylyn/eclipse/plugins/xmlrpc-common.jar
+%{install_loc}/mylyn/eclipse/plugins/xmlrpc-server.jar
%{install_loc}/mylyn/eclipse/plugins/commons-httpclient.jar
%{install_loc}/mylyn/eclipse/plugins/ws-commons-util.jar
%{install_loc}/mylyn/eclipse/plugins/jaxp.jar
@@ -628,7 +664,13 @@ install %{SOURCE6} %{buildroot}%{install_loc}/mylyn/eclipse/redhat-bugzilla-cust
%doc org.eclipse.mylyn.commons/org.eclipse.mylyn.commons.sdk-feature/epl-v10.html
%doc org.eclipse.mylyn.commons/org.eclipse.mylyn.commons.sdk-feature/license.html
+%files tests
+%{_javadir}/mylyn-tests
+
%changelog
+* Thu Jul 10 2014 Sami Wagiaalla <swagiaal at redhat.com> - 3.12.0-0.7.git20140509
+- Add mylyn-tests package.
+
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.12.0-0.6.git20140509
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
diff --git a/sources b/sources
index a241edb..b42cb10 100644
--- a/sources
+++ b/sources
@@ -1,2 +1 @@
-f175e3f92b4092b3954088e681c21366 eclipse-mylyn-8c077e351de3d0857512e7c4e48ad0f0a56e96ca-fetched-src.tar.xz
-a06ec876be77aec8b4f9037acb77bf96 eclipse-mylyn-a1a4646ea6d027e89f828a9c45bd8fa79721a90c-incubator-fetched-src.tar.xz
+14fc49bfca8ba2db5c04598125989fdb eclipse-mylyn-R_3_12_0-fetched-src.tar.xz
More information about the scm-commits
mailing list