Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ua.tests/help/org/eclipse/ua/tests/help')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/context/ParserTest.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/producer/DynamicContentTest.java4
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/ParserTest.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializer.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializerTest.java27
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ProducerSerializerTest.java26
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializer.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializerTest.java41
8 files changed, 45 insertions, 61 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/context/ParserTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/context/ParserTest.java
index f6c769f38..0f0dc8f8e 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/context/ParserTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/context/ParserTest.java
@@ -57,7 +57,7 @@ public class ParserTest extends TestCase {
String relativePath = file.getHref();
try {
- String expected = FileUtil.getResultFileContents(bundle, relativePath);
+ String expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath));
String actual = ContextModelSerializer.serialize(contexts);
Assert.assertEquals("Serialized context help model for " + relativePath + " did not match the expected result", expected, actual);
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/producer/DynamicContentTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/producer/DynamicContentTest.java
index ad0a62e83..416e8c2bc 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/producer/DynamicContentTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/producer/DynamicContentTest.java
@@ -22,6 +22,7 @@ import org.eclipse.help.IToc;
import org.eclipse.help.ITopic;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.FileUtil;
+import org.eclipse.ua.tests.util.XHTMLUtil;
import org.osgi.framework.Bundle;
/*
@@ -49,8 +50,9 @@ public class DynamicContentTest extends TestCase {
Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
try {
- String expected = FileUtil.getResultFileContents(bundle, relativePath);
+ String expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath));
String actual = FileUtil.readString(HelpSystem.getHelpContent(href));
+ actual = XHTMLUtil.removeEnvironmentSpecificContent(actual);
Assert.assertEquals("Processed file " + relativePath + " did not match the expected result", expected, actual);
}
catch(IOException e) {
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/ParserTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/ParserTest.java
index 2bdb831fa..d8ede3fcf 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/ParserTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/ParserTest.java
@@ -65,7 +65,7 @@ public class ParserTest extends TestCase {
*/
if (relativePath.startsWith("data/help/toc/")) {
try {
- String expected = FileUtil.getResultFileContents(bundle, relativePath);
+ String expected = FileUtil.getContents(bundle, FileUtil.getResultFile(relativePath));
String actual = TocModelSerializer.serialize(toc);
Assert.assertEquals("Serialized toc model for " + relativePath + " did not match the expected result", expected, actual);
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializer.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializer.java
index 4832afe55..74fc2de92 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializer.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializer.java
@@ -39,7 +39,7 @@ public class ContextModelSerializer {
buf.append(serializeAux(entry, indent + " "));
}
- buf.append(indent + "</contexts>\n");
+ buf.append(indent + "</contexts>");
return buf.toString();
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializerTest.java
index 429af6c4f..d540b15b8 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ContextModelSerializerTest.java
@@ -11,6 +11,7 @@
package org.eclipse.ua.tests.help.util;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,11 +32,11 @@ import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.FileUtil;
/*
- * A utility for regenerating the _serialized.txt files that contain the expected
- * output for the context content when serialized. This reads all the context content
+ * A utility for regenerating the _expected.txt files that contain the expected
+ * result for the context model when serialized. This reads all the context content
* from the plugin manifest (for this test plugin only), constructs the model, then
* serializes the model to a text file, which is stored in the same directory as the
- * intro xml file, as <original_name>_serialized.txt.
+ * intro xml file, as <original_name>_expected.txt.
*
* These files are used by the JUnit tests to compare the result with the expected
* result.
@@ -46,13 +47,6 @@ import org.eclipse.ua.tests.util.FileUtil;
* 2. Right-click in "Package Explorer -> Refresh".
*
* The new files should appear.
- *
- * Note: Some of the files have os, ws, and arch appended, for example
- * <original_name>_serialized_linux_gtk_x86.txt. These are filtering tests that have
- * filters by os/ws/arch so the result is different on each combination. This test will
- * only generate the _serialized file and will be the one for the current platform. You
- * need to make one copy for each combination and edit the files manually to have the
- * correct content (or generate on each platform).
*/
public class ContextModelSerializerTest extends TestCase {
@@ -71,7 +65,7 @@ public class ContextModelSerializerTest extends TestCase {
HelpUIPlugin.getDefault();
}
- public void testRunSerializer() {
+ public void testRunSerializer() throws IOException {
Iterator iter = getContextFiles().iterator();
while (iter.hasNext()) {
ContextsFile file = (ContextsFile)iter.next();
@@ -84,14 +78,9 @@ public class ContextModelSerializerTest extends TestCase {
String absolutePath = pluginRoot + relativePath;
String resultFile = FileUtil.getResultFile(absolutePath);
- try {
- PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
- out.print(ContextModelSerializer.serialize(contexts));
- out.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
+ out.print(ContextModelSerializer.serialize(contexts));
+ out.close();
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ProducerSerializerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ProducerSerializerTest.java
index 98cb05d6e..19e13d9cb 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ProducerSerializerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ProducerSerializerTest.java
@@ -22,13 +22,15 @@ import org.eclipse.help.IToc;
import org.eclipse.help.ITopic;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.FileUtil;
+import org.eclipse.ua.tests.util.XHTMLUtil;
/*
- * A utility for regenerating the _serialized.txt files that contain the expected
- * output for the producer content when serialized. This reads all the TOC content
- * from data/help/producer, passes it through the dynamic content producer, then
- * stores the result in a text file, which is stored in the same directory as the
- * original xhtml file, as <original_name>_serialized.txt.
+ * A utility for regenerating the _expected.txt files that contain the
+ * expected result for the producer content model when serialized.
+ * This reads all the TOC content from data/help/producer, passes it
+ * through the dynamic content producer, then stores the result in a
+ * text file, which is stored in the same directory as the original
+ * xhtml file, as <original_name>_expected.txt.
*
* These files are used by the JUnit tests to compare the result with the expected
* result.
@@ -63,15 +65,11 @@ public class ProducerSerializerTest extends TestCase {
String absolutePath = pluginRoot + relativePath;
String resultFile = FileUtil.getResultFile(absolutePath);
- try {
- PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
- out.print(FileUtil.readString(HelpSystem.getHelpContent(href)));
- out.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
+ PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
+ String output = FileUtil.readString(HelpSystem.getHelpContent(href));
+ output = XHTMLUtil.removeEnvironmentSpecificContent(output);
+ out.print(output);
+ out.close();
}
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializer.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializer.java
index c61e7f157..ad7b4a0c8 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializer.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializer.java
@@ -37,7 +37,7 @@ public class TocModelSerializer {
buf.append(serializeAux(topics[i], indent + " "));
}
- buf.append(indent + "</toc>\n");
+ buf.append(indent + "</toc>");
return buf.toString();
}
return EMPTY_STRING;
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializerTest.java
index 136f68237..4a931a0fb 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/TocModelSerializerTest.java
@@ -11,6 +11,7 @@
package org.eclipse.ua.tests.help.util;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,11 +34,11 @@ import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.FileUtil;
/*
- * A utility for regenerating the _serialized.txt files that contain the expected
- * output for the TOC content when serialized. This reads all the TOC content from
+ * A utility for regenerating the _expected.txt files that contain the expected
+ * result for the TOC model when serialized. This reads all the TOC content from
* the plugin manifest (for this test plugin only), constructs the model, then
* serializes the model to a text file, which is stored in the same directory as the
- * intro xml file, as <original_name>_serialized.txt.
+ * TOC xml file, as <original_name>_expected.txt.
*
* These files are used by the JUnit tests to compare the result with the expected
* result.
@@ -48,13 +49,6 @@ import org.eclipse.ua.tests.util.FileUtil;
* 2. Right-click in "Package Explorer -> Refresh".
*
* The new files should appear.
- *
- * Note: Some of the files have os, ws, and arch appended, for example
- * <original_name>_serialized_linux_gtk_x86.txt. These are filtering tests that have
- * filters by os/ws/arch so the result is different on each combination. This test will
- * only generate the _serialized file and will be the one for the current platform. You
- * need to make one copy for each combination and edit the files manually to have the
- * correct content (or generate on each platform).
*/
public class TocModelSerializerTest extends TestCase {
@@ -73,7 +67,7 @@ public class TocModelSerializerTest extends TestCase {
HelpUIPlugin.getDefault();
}
- public void testRunSerializer() {
+ public void testRunSerializer() throws IOException {
Collection tocFiles = getTocFiles();
TocBuilder builder = new TocBuilder();
builder.build(tocFiles);
@@ -89,17 +83,15 @@ public class TocModelSerializerTest extends TestCase {
String absolutePath = pluginRoot + relativePath;
String resultFile = FileUtil.getResultFile(absolutePath);
- try {
- PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
- out.print(TocModelSerializer.serialize(toc));
- out.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ PrintWriter out = new PrintWriter(new FileOutputStream(resultFile));
+ out.print(TocModelSerializer.serialize(toc));
+ out.close();
}
}
+ /**
+ * Find all the TOC files to use for this test.
+ */
public static Collection getTocFiles() {
Collection tocFiles = new ArrayList();
IExtensionPoint xpt = Platform.getExtensionRegistry().getExtensionPoint(HelpPlugin.PLUGIN_ID, "toc");
@@ -110,11 +102,14 @@ public class TocModelSerializerTest extends TestCase {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j=0;j<configElements.length;j++) {
if (configElements[j].getName().equals("toc")) {
+ // only get files in data/help/toc/
String href = configElements[j].getAttribute("file"); //$NON-NLS-1$
- boolean isPrimary = "true".equals(configElements[j].getAttribute("primary")); //$NON-NLS-1$
- String extraDir = configElements[j].getAttribute("extradir"); //$NON-NLS-1$
- String categoryId = configElements[j].getAttribute("category"); //$NON-NLS-1$
- tocFiles.add(new TocFile(pluginId, href, isPrimary, Platform.getNL(), extraDir, categoryId));
+ if (href.startsWith("data/help/toc/")) {
+ boolean isPrimary = "true".equals(configElements[j].getAttribute("primary")); //$NON-NLS-1$
+ String extraDir = configElements[j].getAttribute("extradir"); //$NON-NLS-1$
+ String categoryId = configElements[j].getAttribute("category"); //$NON-NLS-1$
+ tocFiles.add(new TocFile(pluginId, href, isPrimary, Platform.getNL(), extraDir, categoryId));
+ }
}
}
}

Back to the top