Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-19 10:01:57 +0000
committerAlexander Kurtakov2016-01-19 10:04:22 +0000
commit66a90973834fd0a527a8b4c6d75cab82ec3ca1fb (patch)
treee1366a4be275bb784badd6b02b2662de3f553065 /org.eclipse.ua.tests/help
parent4b213ee9699e2733a4dc81864fda1d5d50f5af86 (diff)
downloadeclipse.platform.ua-66a90973834fd0a527a8b4c6d75cab82ec3ca1fb.tar.gz
eclipse.platform.ua-66a90973834fd0a527a8b4c6d75cab82ec3ca1fb.tar.xz
eclipse.platform.ua-66a90973834fd0a527a8b4c6d75cab82ec3ca1fb.zip
Bug 485918 - Convert org.eclipse.ua.tests to JUnit 4
Migrate AllTocTests. Change-Id: I8c7cda49eea5dd8d055e9679d3bd2546afabcc79 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/help')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java84
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/HelpData.java20
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java25
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconPathTest.java32
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconTest.java21
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java11
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java72
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java45
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java19
9 files changed, 212 insertions, 117 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java
index 7f2408ea7..b582fd3f9 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java
@@ -1,15 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
@@ -19,19 +23,18 @@ import org.eclipse.help.ITopic;
import org.eclipse.help.IUAElement;
import org.eclipse.help.internal.UAElement;
import org.eclipse.help.internal.webapp.data.EnabledTopicUtils;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class EnabledTopicTest {
-public class EnabledTopicTest extends TestCase {
-
private class ETopic implements ITopic {
-
+
private String label;
private boolean isEnabled;
private List<ITopic> children = new ArrayList<ITopic>();
public ETopic(String label, boolean isEnabled) {
- this.label = label;
+ this.label = label;
this.isEnabled = isEnabled;
}
@@ -59,28 +62,28 @@ public class EnabledTopicTest extends TestCase {
@Override
public String getLabel() {
return label;
- }
-
+ }
+
public void addSubTopic(ITopic subTopic) {
children.add(subTopic);
}
}
-
+
private class NoHrefTopic extends ETopic {
-
+
public NoHrefTopic(String label) {
super(label, true);
}
-
+
@Override
public String getHref() {
return null;
}
-
+
}
-
+
private class EIndexEntry extends UAElement implements IIndexEntry {
-
+
private String keyword;
private List<ITopic> topics = new ArrayList<ITopic>();
private List<IIndexEntry> subEntries = new ArrayList<IIndexEntry>();
@@ -98,7 +101,7 @@ public class EnabledTopicTest extends TestCase {
public void addSubEntry(IIndexEntry entry) {
subEntries.add(entry);
}
-
+
public void addTopic(ITopic topic) {
topics.add(topic);
}
@@ -119,19 +122,22 @@ public class EnabledTopicTest extends TestCase {
all.addAll(subEntries);
all.addAll(topics);
return all.toArray(new IUAElement[all.size()]);
- }
+ }
}
-
+
+ @Test
public void testEnabledTopic() {
assertTrue(EnabledTopicUtils.isEnabled(new ETopic("T1", true)));
assertFalse(EnabledTopicUtils.isEnabled(new ETopic("T2", false)));
}
+ @Test
public void testEnabledTopicsEmptyArray() throws Exception {
ITopic[] enabled = EnabledTopicUtils.getEnabled(new ITopic[0]);
assertTrue(enabled.length == 0);
}
-
+
+ @Test
public void testEnabledTopicsAllEnabled() throws Exception {
ITopic[] topics = new ITopic[2];
topics[0] = new ETopic("T1", true);
@@ -142,14 +148,16 @@ public class EnabledTopicTest extends TestCase {
assertTrue(topics[1].getLabel().equals("T2"));
}
- public void testEnabledTopicsAllDisabled() throws Exception {
+ @Test
+ public void testEnabledTopicsAllDisabled() throws Exception {
ITopic[] topics = new ITopic[2];
topics[0] = new ETopic("T1", false);
topics[1] = new ETopic("T2", false);
ITopic[] enabled = EnabledTopicUtils.getEnabled(topics);
assertTrue(enabled.length == 0);
}
-
+
+ @Test
public void testEnabledTopicsMix() throws Exception {
ITopic[] topics = new ITopic[4];
topics[0] = new ETopic("T1", true);
@@ -162,23 +170,27 @@ public class EnabledTopicTest extends TestCase {
assertEquals("T3", enabled[1].getLabel());
}
+ @Test
public void testNoHref() {
ITopic noHref = new NoHrefTopic("N1");
assertFalse(EnabledTopicUtils.isEnabled(noHref));
}
+ @Test
public void testNoHrefValidChild() {
ETopic noHref = new NoHrefTopic("N1");
noHref.addSubTopic(new ETopic("T1", true));
assertTrue(EnabledTopicUtils.isEnabled(noHref));
}
+ @Test
public void testNoHrefInvalidChild() {
ETopic noHref = new NoHrefTopic("N1");
noHref.addSubTopic(new ETopic("T1", false));
assertFalse(EnabledTopicUtils.isEnabled(noHref));
}
-
+
+ @Test
public void testNoHrefMixedChildren() {
ETopic noHref = new NoHrefTopic("N1");
noHref.addSubTopic(new ETopic("T1", false));
@@ -186,6 +198,7 @@ public class EnabledTopicTest extends TestCase {
assertTrue(EnabledTopicUtils.isEnabled(noHref));
}
+ @Test
public void testNoHrefValidGrandchild() {
ETopic noHref = new NoHrefTopic("N1");
ETopic subTopic = new NoHrefTopic("N2");
@@ -193,7 +206,8 @@ public class EnabledTopicTest extends TestCase {
subTopic.addSubTopic(new ETopic("T2", true));
assertTrue(EnabledTopicUtils.isEnabled(noHref));
}
-
+
+ @Test
public void testNoHrefInvalidGrandchild() {
ETopic noHref = new NoHrefTopic("N1");
ETopic subTopic = new NoHrefTopic("N2");
@@ -202,23 +216,27 @@ public class EnabledTopicTest extends TestCase {
assertFalse(EnabledTopicUtils.isEnabled(noHref));
}
+ @Test
public void testEmptyIndexEntry() {
EIndexEntry entry1 = new EIndexEntry("abc");
assertFalse(EnabledTopicUtils.isEnabled(entry1));
}
-
+
+ @Test
public void testEnabledIndexEntry() {
EIndexEntry entry1 = new EIndexEntry("abc");
entry1.addTopic(new ETopic("T1", true));
assertTrue(EnabledTopicUtils.isEnabled(entry1));
}
-
+
+ @Test
public void testDisabledIndexEntry() {
EIndexEntry entry1 = new EIndexEntry("abc");
entry1.addTopic(new ETopic("T1", false));
assertFalse(EnabledTopicUtils.isEnabled(entry1));
}
+ @Test
public void testMixedIndexEntry() {
EIndexEntry entry1 = new EIndexEntry("abc");
entry1.addTopic(new ETopic("T1", true));
@@ -226,6 +244,7 @@ public class EnabledTopicTest extends TestCase {
assertTrue(EnabledTopicUtils.isEnabled(entry1));
}
+ @Test
public void testIndexEntryEnabledChild() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -233,7 +252,8 @@ public class EnabledTopicTest extends TestCase {
entry1.addSubEntry(entry2);
assertTrue(EnabledTopicUtils.isEnabled(entry1));
}
-
+
+ @Test
public void testIndexEntryEnabledGrandChild() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -244,6 +264,7 @@ public class EnabledTopicTest extends TestCase {
assertTrue(EnabledTopicUtils.isEnabled(entry1));
}
+ @Test
public void testIndexEntryDisabledChild() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -251,7 +272,8 @@ public class EnabledTopicTest extends TestCase {
entry1.addSubEntry(entry2);
assertFalse(EnabledTopicUtils.isEnabled(entry1));
}
-
+
+ @Test
public void testIndexEntryMixedChildren() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -263,12 +285,14 @@ public class EnabledTopicTest extends TestCase {
assertTrue(EnabledTopicUtils.isEnabled(entry1));
}
+ @Test
public void testEnabledIndexArrayEmpty() {
IIndexEntry[] entries = new EIndexEntry[0];
IIndexEntry[] filtered =EnabledTopicUtils.getEnabled(entries);
assertEquals(0, filtered.length);
}
+ @Test
public void testEnabledIndexArrayDisabled() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -277,6 +301,7 @@ public class EnabledTopicTest extends TestCase {
assertEquals(0, filtered.length);
}
+ @Test
public void testEnabledIndexArrayEnabled() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -288,7 +313,8 @@ public class EnabledTopicTest extends TestCase {
assertEquals(filtered[0].getKeyword(), "abc");
assertEquals(filtered[1].getKeyword(), "def");
}
-
+
+ @Test
public void testEnabledIndexArrayMixed() {
EIndexEntry entry1 = new EIndexEntry("abc");
EIndexEntry entry2 = new EIndexEntry("def");
@@ -302,5 +328,5 @@ public class EnabledTopicTest extends TestCase {
assertEquals(filtered[0].getKeyword(), "def");
assertEquals(filtered[1].getKeyword(), "jkl");
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/HelpData.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/HelpData.java
index afdf61675..953439546 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/HelpData.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/HelpData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation 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
@@ -10,21 +10,23 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.util.List;
import org.eclipse.help.internal.util.ProductPreferences;
+import org.junit.Test;
-public class HelpData extends TestCase {
-
+public class HelpData {
+ @Test
public void testHelpDataInPlugin() {
List<String> result = ProductPreferences.getTocOrdering("org.eclipse.ua.tests", "data/help/toc/helpData.xml", "");
assertEquals(2, result.size());
assertEquals("/org.eclipse.platform.doc.user/toc.xml", result.get(0));
assertEquals("/org.eclipse.platform.doc.isv/toc.xml", result.get(1));
}
-
+
+ @Test
public void testPluginsRoot() {
List<String> result = ProductPreferences.getTocOrdering("org.eclipse.sdk", "PLUGINS_ROOT/org.eclipse.ua.tests/data/help/toc/helpData.xml", "");
assertEquals(2, result.size());
@@ -32,18 +34,20 @@ public class HelpData extends TestCase {
assertEquals("/org.eclipse.platform.doc.isv/toc.xml", result.get(1));
}
+ @Test
public void testHelpDataOverridesBaseTocs() {
List<String> result = ProductPreferences.getTocOrdering("org.eclipse.ua.tests", "data/help/toc/helpData.xml", "org.eclipse.help");
assertEquals(2, result.size());
assertEquals("/org.eclipse.platform.doc.user/toc.xml", result.get(0));
assertEquals("/org.eclipse.platform.doc.isv/toc.xml", result.get(1));
}
-
+
+ @Test
public void testBaseTocs() {
List<String> result = ProductPreferences.getTocOrdering("", "", "/org.eclipse.help/toc.xml,/org.eclipse.test/toc.xml");
assertEquals(2, result.size());
assertEquals("/org.eclipse.help/toc.xml", result.get(0));
assertEquals("/org.eclipse.test/toc.xml", result.get(1));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
index e15a3dda8..2b772955d 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocAssemblerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 IBM Corporation 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
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -23,17 +27,16 @@ import org.eclipse.help.internal.toc.TocFile;
import org.eclipse.help.internal.toc.TocFileParser;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.XMLUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class TocAssemblerTest extends TestCase {
-
+public class TocAssemblerTest {
+ @Test
public void testAssemble() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution b = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/b.xml", true, "en", null, null));
TocContribution c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/c.xml", true, "en", null, null));
TocContribution result_b_c = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/result_b_c.xml", true, "en", null, null));
-
+
TocAssembler assembler = new TocAssembler();
List<TocContribution> contributions = new ArrayList<TocContribution>(Arrays.asList(b, c));
contributions = assembler.assemble(contributions);
@@ -51,24 +54,26 @@ public class TocAssemblerTest extends TestCase {
contributions = new ArrayList<TocContribution>(Arrays.asList(a, b, c, d));
contributions = assembler.assemble(contributions);
assertEquals(1, contributions.size());
-
+
expected = serialize(result_a_b_c_d);
actual = serialize(contributions.get(0));
XMLUtil.assertXMLEquals("Assembled TOC did not match expected result", expected, actual);
}
-
+
+ @Test
public void testInvalidLinkTo() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution linkTo1 = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/linkTo1.xml", true, "en", null, null));
TocContribution linkTo2 = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/linkTo2.xml", true, "en", null, null));
TocContribution linkTo3 = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/linkTo3.xml", true, "en", null, null));
-
+
TocAssembler assembler = new TocAssembler();
List<TocContribution> contributions = new ArrayList<TocContribution>(Arrays.asList(linkTo1, linkTo2, linkTo3));
contributions = assembler.assemble(contributions);
assertEquals(3, contributions.size());
}
-
+
+ @Test
public void testHrefMap() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution b = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/b.xml", true, "en", null, null));
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconPathTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconPathTest.java
index e8ff9af21..a9bb447dc 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconPathTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconPathTest.java
@@ -1,28 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.help.internal.webapp.data.IconFinder;
+import org.junit.Test;
-public class TocIconPathTest extends TestCase {
-
+public class TocIconPathTest {
+ @Test
public void testNullId() {
assertNull(IconFinder.getIconAltFromId(null));
assertNull(IconFinder.getImagePathFromId(null, IconFinder.TYPEICON_CLOSED));
assertNull(IconFinder.getImagePathFromId(null, IconFinder.TYPEICON_OPEN));
assertNull(IconFinder.getImagePathFromId(null, IconFinder.TYPEICON_LEAF));
}
-
+
+ @Test
public void testBadId() {
assertNull(IconFinder.getIconAltFromId("nosuchid"));
assertNull(IconFinder.getImagePathFromId("nosuchid", IconFinder.TYPEICON_CLOSED));
@@ -30,6 +35,7 @@ public class TocIconPathTest extends TestCase {
assertNull(IconFinder.getImagePathFromId("nosuchid", IconFinder.TYPEICON_LEAF));
}
+ @Test
public void testIconSet() {
String closedPath = IconFinder.getImagePathFromId("org.eclipse.ua.tests.iconSet", IconFinder.TYPEICON_CLOSED);
String openPath = IconFinder.getImagePathFromId("org.eclipse.ua.tests.iconSet", IconFinder.TYPEICON_OPEN);
@@ -40,7 +46,8 @@ public class TocIconPathTest extends TestCase {
assertEquals("org.eclipse.ua.tests/icons/sample2.gif", closedPath);
assertEquals("org.eclipse.ua.tests/icons/sample3.gif", leafPath);
}
-
+
+ @Test
public void testSingleIcon() {
String closedPath = IconFinder.getImagePathFromId("org.eclipse.ua.tests.openOnly", IconFinder.TYPEICON_CLOSED);
String openPath = IconFinder.getImagePathFromId("org.eclipse.ua.tests.openOnly", IconFinder.TYPEICON_OPEN);
@@ -52,24 +59,29 @@ public class TocIconPathTest extends TestCase {
assertEquals("org.eclipse.ua.tests/icons/sample.gif", leafPath);
}
+ @Test
public void testNullIconNotDefined() {
assertFalse(IconFinder.isIconDefined(null));
}
+ @Test
public void testEmptyIconNotDefined() {
assertFalse(IconFinder.isIconDefined(null));
}
-
+
+ @Test
public void testUnknownIconNotDefined() {
assertFalse(IconFinder.isIconDefined("nosuchid"));
}
+ @Test
public void testKnownIconDefined() {
assertTrue(IconFinder.isIconDefined("org.eclipse.ua.tests.iconSet"));
}
-
+
+ @Test
public void testOpenOnlyDefined() {
assertTrue(IconFinder.isIconDefined("org.eclipse.ua.tests.openOnly"));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconTest.java
index c9d306196..15643c20a 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocIconTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation 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
@@ -10,25 +10,31 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.help.ui.internal.HelpUIResources;
import org.eclipse.swt.graphics.Image;
+import org.junit.Test;
-public class TocIconTest extends TestCase {
-
+public class TocIconTest {
+ @Test
public void testNullId() {
assertNull(HelpUIResources.getImageFromId(null, false, false));
assertNull(HelpUIResources.getImageFromId(null, true, false));
assertNull(HelpUIResources.getImageFromId(null, false, true));
}
-
+
+ @Test
public void testBadId() {
assertNull(HelpUIResources.getImageFromId("nosuchid", false, false));
assertNull(HelpUIResources.getImageFromId("nosuchid", true, false));
assertNull(HelpUIResources.getImageFromId("nosuchid", false, true));
}
+ @Test
public void testIconSet() {
Image closedImage = HelpUIResources.getImageFromId("org.eclipse.ua.tests.iconSet", false, false);
Image openImage = HelpUIResources.getImageFromId("org.eclipse.ua.tests.iconSet", true, false);
@@ -40,7 +46,8 @@ public class TocIconTest extends TestCase {
assertFalse(openImage.equals(leafImage));
assertFalse(closedImage.equals(leafImage));
}
-
+
+ @Test
public void testSingleIcon() {
Image closedImage = HelpUIResources.getImageFromId("org.eclipse.ua.tests.openOnly", false, false);
Image openImage = HelpUIResources.getImageFromId("org.eclipse.ua.tests.openOnly", true, false);
@@ -52,5 +59,5 @@ public class TocIconTest extends TestCase {
assertTrue(openImage.equals(leafImage));
assertTrue(closedImage.equals(leafImage));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java
index 9d49f5dda..703d99bac 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocProviderTest.java
@@ -10,17 +10,20 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.eclipse.help.IToc;
import org.eclipse.help.ITopic;
import org.eclipse.help.internal.HelpPlugin;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class TocProviderTest {
-public class TocProviderTest extends TestCase {
-
/**
* Verify that the tocProvider extension in this plug-in contributes a TOC which can be linked to an anchor
*/
+ @Test
public void testTocProvider() throws Exception {
IToc[] tocs = HelpPlugin.getTocManager().getTocs("en");
IToc uaToc = null;
@@ -39,7 +42,7 @@ public class TocProviderTest extends TestCase {
}
}
assertEquals(1, generatedParentTopics);
-
+
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java
index 8604b4587..4497e01fc 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-import junit.framework.TestCase;
+import java.util.List;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.Platform;
@@ -26,9 +27,12 @@ import org.eclipse.help.internal.HelpData;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.toc.TocSorter;
import org.eclipse.help.internal.util.ProductPreferences;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TocSortingTest {
-public class TocSortingTest extends TestCase {
-
private static final String BASE_TOCS = "baseTOCS";
private static final String ORDERED_XML = "PLUGINS_ROOT/org.eclipse.ua.tests/data/help/toc/toc_data/helpDataOrdered.xml";
private static final String EMPTY_XML = "PLUGINS_ROOT/org.eclipse.ua.tests/data/help/toc/toc_data/helpDataEmpty.xml";
@@ -38,9 +42,9 @@ public class TocSortingTest extends TestCase {
private static final String ALPHA_SORT_XML = "PLUGINS_ROOT/org.eclipse.ua.tests/data/help/toc/toc_data/helpDataOrderedAlphaSort.xml";
private String helpDataPreference;
private String baseTocsPreference;
-
+
private class Toc implements IToc {
-
+
private String label;
public Toc(String label) {
@@ -78,19 +82,19 @@ public class TocSortingTest extends TestCase {
}
}
-
+
private class TC implements ITocContribution {
private IToc toc;
private String categoryId;
private String id;
-
+
public TC(String name, String category) {
this.categoryId = category;
this.id = "/" + name + "/toc.xml";
this.toc = new Toc(name);
}
-
+
@Override
public String getCategoryId() {
return categoryId;
@@ -129,11 +133,11 @@ public class TocSortingTest extends TestCase {
@Override
public boolean isPrimary() {
return true;
- }
+ }
}
-
- @Override
- protected void setUp() throws Exception {
+
+ @Before
+ public void setUp() throws Exception {
helpDataPreference = Platform.getPreferencesService().getString
(HelpPlugin.HELP_DATA_KEY, HelpPlugin.HELP_DATA_KEY, "", null);
baseTocsPreference = Platform.getPreferencesService().getString
@@ -143,9 +147,9 @@ public class TocSortingTest extends TestCase {
setHelpData(EMPTY_XML);
setBaseTocs("");
}
-
- @Override
- protected void tearDown() throws Exception {
+
+ @After
+ public void tearDown() throws Exception {
setHelpData(helpDataPreference);
setBaseTocs(baseTocsPreference);
HelpData.clearProductHelpData();
@@ -156,12 +160,12 @@ public class TocSortingTest extends TestCase {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(HelpPlugin.PLUGIN_ID);
prefs.put(HelpPlugin.HELP_DATA_KEY, value);
}
-
+
private void setBaseTocs(String value) {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(HelpPlugin.PLUGIN_ID);
prefs.put(BASE_TOCS, value);
}
-
+
private String toString(ITocContribution[] tocs) {
String result = "";
for (ITocContribution toc : tocs) {
@@ -169,13 +173,15 @@ public class TocSortingTest extends TestCase {
}
return result;
}
-
+
+ @Test
public void testNoTocs() {
TocSorter sorter = new TocSorter();
ITocContribution[] result = sorter.orderTocContributions(new TC[0]);
assertEquals(result.length, 0);
}
+ @Test
public void testNoCategory() {
TocSorter sorter = new TocSorter();
ITocContribution[] tocs = new ITocContribution[] {
@@ -185,6 +191,7 @@ public class TocSortingTest extends TestCase {
assertEquals("358", toString(result));
}
+ @Test
public void testCaseInsensitive() {
TocSorter sorter = new TocSorter();
ITocContribution[] tocs = new ITocContribution[] {
@@ -193,17 +200,19 @@ public class TocSortingTest extends TestCase {
ITocContribution[] result = sorter.orderTocContributions(tocs);
assertEquals("aBcD", toString(result));
}
-
+
+ @Test
public void testCategories() {
TocSorter sorter = new TocSorter();
ITocContribution[] tocs = new ITocContribution[] {
- new TC("4", null), new TC("2", "a"), new TC("5", "b"), new TC("1", null), new TC("8", ""),
+ new TC("4", null), new TC("2", "a"), new TC("5", "b"), new TC("1", null), new TC("8", ""),
new TC("7", "a"), new TC("9", "b"), new TC("3", ""), new TC("6", null)
};
ITocContribution[] result = sorter.orderTocContributions(tocs);
assertEquals("127345968", toString(result));
}
+ @Test
public void testTocOrderPreference() {
setHelpData(ORDERED_XML);
TocSorter sorter = new TocSorter();
@@ -214,6 +223,7 @@ public class TocSortingTest extends TestCase {
assertEquals("dbac", toString(result));
}
+ @Test
public void testTocNoSortOthers() {
setHelpData(NO_SORT_XML);
TocSorter sorter = new TocSorter();
@@ -224,6 +234,7 @@ public class TocSortingTest extends TestCase {
assertEquals("dbeca", toString(result));
}
+ @Test
public void testTocAlphaSortOthers() {
setHelpData(ALPHA_SORT_XML);
TocSorter sorter = new TocSorter();
@@ -234,6 +245,7 @@ public class TocSortingTest extends TestCase {
assertEquals("dbace", toString(result));
}
+ @Test
public void testTocBadHelpDataPlugin() {
setHelpData(BAD_PLUGIN_HELP_DATA_XML);
TocSorter sorter = new TocSorter();
@@ -244,6 +256,7 @@ public class TocSortingTest extends TestCase {
assertEquals("abcde", toString(result));
}
+ @Test
public void testTocBadHelpDataPath() {
setHelpData(NO_SUCH_FILE_XML);
TocSorter sorter = new TocSorter();
@@ -254,6 +267,7 @@ public class TocSortingTest extends TestCase {
assertEquals("abcde", toString(result));
}
+ @Test
public void testNoHelpData() {
setHelpData("");
TocSorter sorter = new TocSorter();
@@ -263,7 +277,8 @@ public class TocSortingTest extends TestCase {
ITocContribution[] result = sorter.orderTocContributions(tocs);
assertEquals("abcde", toString(result));
}
-
+
+ @Test
public void testBaseTocs() {
setHelpData("");
setBaseTocs("/d/toc.xml,/b/toc.xml");
@@ -275,18 +290,21 @@ public class TocSortingTest extends TestCase {
assertEquals("dbace", toString(result));
}
+ @Test
public void testNoProductNoHelpData() {
List<String> ordering = ProductPreferences.getTocOrdering(null, "", "/a/b.xml,/c/d.xml");
assertEquals(2, ordering.size());
assertEquals("/a/b.xml", ordering.get(0));
assertEquals("/c/d.xml", ordering.get(1));
}
-
+
+ @Test
public void testNoProductWithHelpData() {
List<String> ordering = ProductPreferences.getTocOrdering(null, "helpData.xml", "/a/b.xml,/c/d.xml");
assertNull(ordering);
}
-
+
+ @Test
public void testNoProductWithPluginsRoot() {
List<String> ordering = ProductPreferences.getTocOrdering(null, ORDERED_XML, "/a/b.xml,/c/d.xml");
assertEquals(3, ordering.size());
@@ -294,5 +312,5 @@ public class TocSortingTest extends TestCase {
assertEquals("/d/toc.xml", ordering.get(1));
assertEquals("/b/toc.xml", ordering.get(2));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java
index 7c969bfda..d89a057d5 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicFinderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 IBM Corporation 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
@@ -11,6 +11,12 @@
package org.eclipse.ua.tests.help.toc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.help.IToc;
import org.eclipse.help.ITopic;
import org.eclipse.help.internal.HelpPlugin;
@@ -19,31 +25,34 @@ import org.eclipse.help.internal.base.scope.UniversalScope;
import org.eclipse.help.internal.webapp.data.TocData;
import org.eclipse.help.internal.webapp.data.TopicFinder;
import org.eclipse.help.internal.webapp.data.UrlUtil;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class TopicFinderTest {
-public class TopicFinderTest extends TestCase{
-
private IToc[] getTocs() {
return HelpPlugin.getTocManager().getTocs("en");
}
-
+
+ @Test
public void testTocsFound() {
assertTrue(getTocs().length != 0);
}
-
+
+ @Test
public void testNoTocs() {
TopicFinder finder = new TopicFinder("http:", new IToc[0], new UniversalScope());
assertEquals(-1, finder.getSelectedToc());
assertNull(finder.getTopicPath());
}
-
+
+ @Test
public void testNoTopic() {
TopicFinder finder = new TopicFinder(null, getTocs(), new UniversalScope());
assertEquals(-1, finder.getSelectedToc());
assertNull(finder.getTopicPath());
}
+ @Test
public void testTopicInToc() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter.xhtml";
TopicFinder finder = new TopicFinder(topic, getTocs(), new UniversalScope());
@@ -57,7 +66,8 @@ public class TopicFinderTest extends TestCase{
assertEquals("manual", path[0].getLabel());
assertEquals("filter", path[1].getLabel());
}
-
+
+ @Test
public void testTopicInTocWithAnchor() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter.xhtml#ABC";
TopicFinder finder = new TopicFinder(topic, getTocs(), new UniversalScope());
@@ -71,7 +81,8 @@ public class TopicFinderTest extends TestCase{
assertEquals("manual", path[0].getLabel());
assertEquals("filter", path[1].getLabel());
}
-
+
+ @Test
public void testTopicInFilteredToc() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html";
TopicFinder finder = new TopicFinder(topic, getTocs(), new FilterScope());
@@ -86,14 +97,16 @@ public class TopicFinderTest extends TestCase{
assertEquals("The plugin org.eclipse.help is installed", path[1].getLabel());
assertEquals("/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html", path[1].getHref());
}
-
+
+ @Test
public void testTopicNotInToc() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/manual/filter25.xhtml";
TopicFinder finder = new TopicFinder(topic, getTocs(), new UniversalScope());
assertEquals(-1, finder.getSelectedToc());
assertNull(finder.getTopicPath());
}
-
+
+ @Test
public void testLookupFromPath() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html";
IToc[] tocs = getTocs();
@@ -109,6 +122,7 @@ public class TopicFinderTest extends TestCase{
assertEquals("/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html", topics[1].getHref());
}
+ @Test
public void testTocNavURL() {
String topic = "http://localhost:8082/help/topic/org.eclipse.ua.tests/data/help/toc/filteredToc/helpInstalled.html";
IToc[] tocs = getTocs();
@@ -120,14 +134,17 @@ public class TopicFinderTest extends TestCase{
assertEquals(0, finder2.getTopicPath().length);
}
+ @Test
public void testTopic_0_0NavURL() {
checkNavTopic(0, 0);
}
+ @Test
public void testTopic_0_1NavURL() {
checkNavTopic(0, 1);
}
-
+
+ @Test
public void testTopic_1_0NavURL() {
checkNavTopic(1, 0);
}
@@ -137,7 +154,7 @@ public class TopicFinderTest extends TestCase{
IToc[] tocs = getTocs();
TopicFinder finder = new TopicFinder(topic, tocs, new UniversalScope());
int selectedToc = finder.getSelectedToc();
- String navPath = "http://127.0.0.1:1936/help/nav/" + selectedToc +
+ String navPath = "http://127.0.0.1:1936/help/nav/" + selectedToc +
'_' + index1 + '_' + index2;
TopicFinder finder2 = new TopicFinder(navPath, tocs, new UniversalScope());
assertEquals(selectedToc, finder2.getSelectedToc());
@@ -149,5 +166,5 @@ public class TopicFinderTest extends TestCase{
assertEquals(secondLevelTopics[index2], topicPath[1]);
assertEquals("" + index1 + '_' + index2, finder2.getNumericPath());
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java
index 728b9f320..5f5f2823e 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TopicSortingTest.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2016 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.help.ITopic;
import org.eclipse.help.internal.toc.Toc;
@@ -19,9 +19,10 @@ import org.eclipse.help.internal.toc.TocFile;
import org.eclipse.help.internal.toc.TocFileParser;
import org.eclipse.help.internal.toc.TopicSorter;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.junit.Test;
-public class TopicSortingTest extends TestCase {
-
+public class TopicSortingTest {
+ @Test
public void testSortTocChildren() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
@@ -32,8 +33,9 @@ public class TopicSortingTest extends TestCase {
assertEquals("A Topic (sorted)", children[0].getLabel());
assertEquals("B Topic", children[1].getLabel());
assertEquals("C Topic", children[2].getLabel());
- }
+ }
+ @Test
public void testSortNestedTopics() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
@@ -47,7 +49,8 @@ public class TopicSortingTest extends TestCase {
assertEquals("A Child", childrenOfA[0].getLabel());
assertEquals("B Child", childrenOfA[1].getLabel());
}
-
+
+ @Test
public void testUnsortedNestedTopics() throws Exception {
TocFileParser parser = new TocFileParser();
TocContribution contribution = parser.parse(new TocFile(UserAssistanceTestPlugin.getPluginId(), "data/help/toc/assembler/sorted.xml", true, "en", null, null));
@@ -61,5 +64,5 @@ public class TopicSortingTest extends TestCase {
assertEquals("B Child of C", childrenOfC[0].getLabel());
assertEquals("A Child of C", childrenOfC[1].getLabel());
}
-
+
}

Back to the top