Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-01-18 17:49:57 +0000
committerAlexander Kurtakov2016-01-18 17:49:57 +0000
commit68f19e45b8263268d7fd1e439d1eb7ad6ac3d4ac (patch)
treebab8ca6281941603a43527aa6d6e6e92b0561f74 /org.eclipse.ua.tests/help
parent676f2102b0670602884d3f3ad4371cbbb49e68dd (diff)
downloadeclipse.platform.ua-68f19e45b8263268d7fd1e439d1eb7ad6ac3d4ac.tar.gz
eclipse.platform.ua-68f19e45b8263268d7fd1e439d1eb7ad6ac3d4ac.tar.xz
eclipse.platform.ua-68f19e45b8263268d7fd1e439d1eb7ad6ac3d4ac.zip
Bug 485918 - Convert org.eclipse.ua.tests to JUnit 4
Migrate AllCriteriaTests suite. Change-Id: I736731622f592ca34a0dddd3d863ce54ce879dd2 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/criteria/CriteriaDefinitionTest.java40
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java21
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java23
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java75
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/TestCriteriaProvider.java38
5 files changed, 121 insertions, 76 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaDefinitionTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaDefinitionTest.java
index ac6c2ef8e..7e8c1acdd 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaDefinitionTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaDefinitionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 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,10 @@
package org.eclipse.ua.tests.help.criteria;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.help.ICriterionDefinition;
import org.eclipse.help.ICriterionValueDefinition;
import org.eclipse.help.internal.UAElement;
@@ -19,27 +23,27 @@ import org.eclipse.help.internal.criteria.CriterionDefinition;
import org.eclipse.help.internal.criteria.CriterionValueDefinition;
import org.eclipse.ua.tests.help.other.UserCriterionDefinition;
import org.eclipse.ua.tests.help.other.UserCriterionValueDefinition;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class CriteriaDefinitionTest extends TestCase {
+public class CriteriaDefinitionTest {
private static final String VALUEID1 = "valueid1";
private static final String VALUENAME1 = "first value";
private static final String VALUEID2 = "valueid2";
- private static final String VALUENAME2 = "second value";
+ private static final String VALUENAME2 = "second value";
private static final String CRITERIONID1 = "criterionid1";
private static final String CRITERIONNAME1 = "first criterion";
-
- // Criterion Value
+ // Criterion Value
+ @Test
public void testCriterionValueDefinition() {
UserCriterionValueDefinition valueDefinition = new UserCriterionValueDefinition(VALUEID1, VALUENAME1);
assertEquals(VALUEID1, valueDefinition.getId());
assertEquals(VALUENAME1, valueDefinition.getName());
assertEquals(0, valueDefinition.getChildren().length);
}
-
+
+ @Test
public void testCopyCriterionValueDefinition() {
UserCriterionValueDefinition valueDefinition = new UserCriterionValueDefinition(VALUEID1, VALUENAME1);
ICriterionValueDefinition copy = new CriterionValueDefinition(valueDefinition);
@@ -47,7 +51,8 @@ public class CriteriaDefinitionTest extends TestCase {
assertEquals(VALUENAME1, copy.getName());
assertEquals(0, copy.getChildren().length);
}
-
+
+ @Test
public void testFactoryCreateValueDefinition() {
UserCriterionValueDefinition valueDefinition = new UserCriterionValueDefinition(VALUEID1, VALUENAME1);
UAElement element = UAElementFactory.newElement(valueDefinition);
@@ -58,16 +63,17 @@ public class CriteriaDefinitionTest extends TestCase {
assertEquals(VALUENAME1, copy.getName());
assertEquals(0, copy.getChildren().length);
}
-
+
// Criterion - no children
-
+ @Test
public void testCriterionDefinition() {
UserCriterionDefinition definition = new UserCriterionDefinition(CRITERIONID1, CRITERIONNAME1);
assertEquals(CRITERIONID1, definition.getId());
assertEquals(CRITERIONNAME1, definition.getName());
assertEquals(0, definition.getChildren().length);
}
-
+
+ @Test
public void testCopyCriterionDefinition() {
UserCriterionDefinition definition = new UserCriterionDefinition(CRITERIONID1, CRITERIONNAME1);
ICriterionDefinition copy = new CriterionDefinition(definition);
@@ -75,7 +81,8 @@ public class CriteriaDefinitionTest extends TestCase {
assertEquals(CRITERIONNAME1, copy.getName());
assertEquals(0, copy.getChildren().length);
}
-
+
+ @Test
public void testFactoryCreateDefinition() {
UserCriterionDefinition definition = new UserCriterionDefinition(CRITERIONID1, CRITERIONNAME1);
UAElement element = UAElementFactory.newElement(definition);
@@ -87,19 +94,22 @@ public class CriteriaDefinitionTest extends TestCase {
assertEquals(0, copy.getChildren().length);
}
+ @Test
public void testCriterionDefinitionWithValues() {
UserCriterionDefinition definition;
definition = createDefinitionWithValues();
checkDefinitionWithValues(definition);
}
+ @Test
public void testCopyCriterionDefinitionWithValues() {
UserCriterionDefinition definition;
definition = createDefinitionWithValues();
ICriterionDefinition copy = new CriterionDefinition(definition);
checkDefinitionWithValues(copy);
}
-
+
+ @Test
public void testFactoryCreateCriterionDefinitionWithValues() {
UserCriterionDefinition definition;
definition = createDefinitionWithValues();
@@ -133,5 +143,5 @@ public class CriteriaDefinitionTest extends TestCase {
assertEquals(VALUENAME2, values[1].getName());
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
index 22c98730d..e1c9ad55b 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/CriteriaUtilitiesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 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,42 +10,49 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.criteria;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
-import junit.framework.TestCase;
+import java.util.List;
import org.eclipse.help.internal.base.util.CriteriaUtilities;
+import org.junit.Test;
-public class CriteriaUtilitiesTest extends TestCase {
+public class CriteriaUtilitiesTest {
+ @Test
public void testNullValues() {
List<String> values = CriteriaUtilities.getCriteriaValues(null);
assertEquals(0, values.size());
}
+ @Test
public void testSingleValue() {
List<String> values = CriteriaUtilities.getCriteriaValues("1.0");
assertEquals(1, values.size());
assertEquals("1.0", values.get(0));
}
+ @Test
public void testSingleValueWithWhitespace() {
List<String> values = CriteriaUtilities.getCriteriaValues(" 1.0 ");
assertEquals(1, values.size());
assertEquals("1.0", values.get(0));
}
-
+
+ @Test
public void testMultipleValues() {
List<String> values = CriteriaUtilities.getCriteriaValues(" 1.0, 2.0 ");
assertEquals(2, values.size());
assertEquals("1.0", values.get(0));
assertEquals("2.0", values.get(1));
}
-
+
+ @Test
public void testUppercaseValue() {
List<String> values = CriteriaUtilities.getCriteriaValues("LINUX");
assertEquals(1, values.size());
assertNotSame("linux", values.get(0));
}
-
+
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java
index 860f392ee..0d4227997 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseCriteriaDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 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,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.criteria;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -22,29 +24,28 @@ import org.eclipse.help.internal.criteria.CriteriaDefinitionFile;
import org.eclipse.help.internal.criteria.CriteriaDefinitionFileParser;
import org.eclipse.help.internal.dynamic.DocumentWriter;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class ParseCriteriaDefinition extends TestCase {
-
+public class ParseCriteriaDefinition {
+ @Test
public void testAssemble() throws Exception {
CriteriaDefinitionFileParser parser = new CriteriaDefinitionFileParser();
CriteriaDefinitionContribution a = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/a.xml", "en"));
CriteriaDefinitionContribution b = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/b.xml", "en"));
CriteriaDefinitionContribution result_a_b = parser.parse(new CriteriaDefinitionFile(UserAssistanceTestPlugin.getPluginId(), "data/help/criteria/criteria_definition/result_a_b.xml", "en"));
-
+
CriteriaDefinitionAssembler assembler = new CriteriaDefinitionAssembler();
List<CriteriaDefinitionContribution> contributions = new ArrayList<CriteriaDefinitionContribution>(Arrays.asList(a, b));
CriteriaDefinition assembled = assembler.assemble(contributions);
-
+
String expected = serialize((UAElement)result_a_b.getCriteriaDefinition());
String actual = serialize(assembled);
assertEquals(trimWhiteSpace(expected), trimWhiteSpace(actual));
}
-
-
+
+
// Replaces white space between ">" and "<" by a single newline
-
+
private String trimWhiteSpace(String input) {
StringBuffer result = new StringBuffer();
boolean betweenElements = false;
@@ -56,7 +57,7 @@ public class ParseCriteriaDefinition extends TestCase {
if (next == '<') {
betweenElements = false;
}
- }
+ }
} else {
result.append(next);
if (next == '>') {
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
index f079dc912..834ec90c6 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/ParseTocWithCriteria.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 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,11 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.criteria;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -34,12 +39,11 @@ import org.eclipse.ua.tests.help.other.UserCriteria;
import org.eclipse.ua.tests.help.other.UserToc2;
import org.eclipse.ua.tests.help.other.UserTopic2;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
+import org.junit.Test;
import org.xml.sax.SAXException;
-import junit.framework.TestCase;
+public class ParseTocWithCriteria {
-public class ParseTocWithCriteria extends TestCase {
-
private IToc2 parseToc(String filename) throws IOException, SAXException,
ParserConfigurationException {
IToc toc;
@@ -51,6 +55,7 @@ public class ParseTocWithCriteria extends TestCase {
return (IToc2) toc;
}
+ @Test
public void testTocWithCriteria() throws Exception {
IToc2 toc = parseToc("data/help/criteria/c1.xml");
Map<String, Set<String>> criteria = new HashMap<String, Set<String>>();
@@ -68,7 +73,8 @@ public class ParseTocWithCriteria extends TestCase {
assertTrue(platforms.contains("linux"));
assertTrue(platforms.contains("win32"));
}
-
+
+ @Test
public void testCopyTocWithCriteria() throws Exception {
IToc toc0 = parseToc("data/help/criteria/c1.xml");
Toc toc = new Toc(toc0);
@@ -79,7 +85,7 @@ public class ParseTocWithCriteria extends TestCase {
assertNotNull(versions);
assertEquals(2, versions.size());
assertTrue(versions.contains("1.0"));
- assertTrue(versions.contains("2.0"));
+ assertTrue(versions.contains("2.0"));
Set<String> platforms = criteria.get("platform");
assertNotNull(platforms);
@@ -87,7 +93,8 @@ public class ParseTocWithCriteria extends TestCase {
assertTrue(platforms.contains("linux"));
assertTrue(platforms.contains("win32"));
}
-
+
+ @Test
public void testTopicWithCriteria() throws Exception {
IToc toc = parseToc("data/help/criteria/c1.xml");
ITopic[] topics = toc.getTopics();
@@ -107,7 +114,7 @@ public class ParseTocWithCriteria extends TestCase {
criteria = new HashMap<String, Set<String>>();
assertTrue(topics[1] instanceof ITopic2);
- CriteriaUtilities.addCriteriaToMap(criteria, ((ITopic2)topics[1]).getCriteria());
+ CriteriaUtilities.addCriteriaToMap(criteria, ((ITopic2)topics[1]).getCriteria());
versions = criteria.get("version");
assertNotNull(versions);
assertEquals(1, versions.size());
@@ -115,6 +122,7 @@ public class ParseTocWithCriteria extends TestCase {
assertFalse(versions.contains("1.0"));
}
+ @Test
public void testCriteriaScoping1() throws Exception {
IToc toc = parseToc("data/help/criteria/c1.xml");
ITopic[] topics = toc.getTopics();
@@ -128,6 +136,7 @@ public class ParseTocWithCriteria extends TestCase {
assertFalse(scope.inScope(topics[1]));
}
+ @Test
public void testCriteriaScoping2() throws Exception {
IToc toc = parseToc("data/help/criteria/c1.xml");
ITopic[] topics = toc.getTopics();
@@ -141,6 +150,7 @@ public class ParseTocWithCriteria extends TestCase {
assertFalse(scope.inScope(topics[1]));
}
+ @Test
public void testMultipleCriteriaScoping() throws Exception {
IToc toc = parseToc("data/help/criteria/c1.xml");
ITopic[] topics = toc.getTopics();
@@ -155,7 +165,8 @@ public class ParseTocWithCriteria extends TestCase {
assertTrue(scope.inScope(topics[0]));
assertFalse(scope.inScope(topics[1]));
}
-
+
+ @Test
public void testMultipleCriteriaOnlyOneSatisfied() throws Exception {
IToc toc = parseToc("data/help/criteria/c1.xml");
ITopic[] topics = toc.getTopics();
@@ -171,13 +182,14 @@ public class ParseTocWithCriteria extends TestCase {
assertFalse(scope.inScope(topics[1]));
}
+ @Test
public void testUserTocWithCriteria() throws Exception {
UserToc2 toc = new UserToc2("myToc", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
UserCriteria criterion2 = new UserCriteria("version", "2.0", true);
toc.addCriterion(criterion1);
toc.addCriterion(criterion2);
-
+
ICriteria[] criteria = toc.getCriteria();
assertEquals(2, criteria.length);
assertEquals("version", criteria[0].getName());
@@ -185,16 +197,17 @@ public class ParseTocWithCriteria extends TestCase {
assertEquals("version", criteria[1].getName());
assertEquals("2.0", criteria[1].getValue());
}
-
+
+ @Test
public void testCopyUserTocWithCriteria() throws Exception {
UserToc2 toc = new UserToc2("myToc", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
UserCriteria criterion2 = new UserCriteria("version", "2.0", true);
toc.addCriterion(criterion1);
toc.addCriterion(criterion2);
-
+
Toc copy = new Toc(toc);
-
+
ICriteria[] criteria = copy.getCriteria();
assertEquals(2, criteria.length);
assertEquals("version", criteria[0].getName());
@@ -203,15 +216,16 @@ public class ParseTocWithCriteria extends TestCase {
assertEquals("2.0", criteria[1].getValue());
}
+ @Test
public void testUserTopicWithCriteria() throws Exception {
UserTopic2 topic = new UserTopic2("myToc", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
UserCriteria criterion2 = new UserCriteria("version", "2.0", true);
topic.addCriterion(criterion1);
topic.addCriterion(criterion2);
-
+
Topic copy = new Topic(topic);
-
+
ICriteria[] criteria = copy.getCriteria();
assertEquals(2, criteria.length);
assertEquals("version", criteria[0].getName());
@@ -220,6 +234,7 @@ public class ParseTocWithCriteria extends TestCase {
assertEquals("2.0", criteria[1].getValue());
}
+ @Test
public void testCopyUserTopicWithCriteria() throws Exception {
UserTopic2 topic = new UserTopic2("myToc", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
@@ -234,15 +249,16 @@ public class ParseTocWithCriteria extends TestCase {
assertEquals("2.0", criteria[1].getValue());
}
+ @Test
public void testMultipleValues() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
-
+
CriterionResource[] linuxResource = new CriterionResource[1];
linuxResource[0] = new CriterionResource("platform");
linuxResource[0].addCriterionValue("linux");
CriteriaHelpScope linuxScope = new CriteriaHelpScope(linuxResource);
assertTrue(linuxScope.inScope(toc));
-
+
CriterionResource[] win32Resource = new CriterionResource[1];
win32Resource[0] = new CriterionResource("platform");
win32Resource[0].addCriterionValue("win32");
@@ -250,59 +266,64 @@ public class ParseTocWithCriteria extends TestCase {
assertTrue(win32scope.inScope(toc));
}
+ @Test
public void testValuesOfDifferentCases() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
ITopic[] topics = toc.getTopics();
-
+
CriterionResource[] linuxResource = new CriterionResource[1];
linuxResource[0] = new CriterionResource("platform");
linuxResource[0].addCriterionValue("linux");
CriteriaHelpScope linuxScope = new CriteriaHelpScope(linuxResource);
- assertFalse(linuxScope.inScope(topics[0]));
+ assertFalse(linuxScope.inScope(topics[0]));
}
+ @Test
public void testValuesWithWhitespace() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
ITopic[] topics = toc.getTopics();
-
+
CriterionResource[] win32Resource = new CriterionResource[1];
win32Resource[0] = new CriterionResource("platform");
win32Resource[0].addCriterionValue("win32");
CriteriaHelpScope win32Scope = new CriteriaHelpScope(win32Resource);
- assertTrue(win32Scope.inScope(topics[1]));
+ assertTrue(win32Scope.inScope(topics[1]));
}
+ @Test
public void testNoName() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
ITopic[] topics = toc.getTopics();
-
+
CriterionResource[] win32Resource = new CriterionResource[1];
win32Resource[0] = new CriterionResource("platform");
win32Resource[0].addCriterionValue("win32");
CriteriaHelpScope win32Scope = new CriteriaHelpScope(win32Resource);
- assertFalse(win32Scope.inScope(topics[2]));
+ assertFalse(win32Scope.inScope(topics[2]));
}
+ @Test
public void testNoValue() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
ITopic[] topics = toc.getTopics();
-
+
CriterionResource[] win32Resource = new CriterionResource[1];
win32Resource[0] = new CriterionResource("platform");
win32Resource[0].addCriterionValue("win32");
CriteriaHelpScope win32Scope = new CriteriaHelpScope(win32Resource);
- assertFalse(win32Scope.inScope(topics[3]));
+ assertFalse(win32Scope.inScope(topics[3]));
}
+ @Test
public void testNoCriteria() throws Exception {
IToc toc = parseToc("data/help/criteria/c2.xml");
ITopic[] topics = toc.getTopics();
-
+
CriterionResource[] win32Resource = new CriterionResource[1];
win32Resource[0] = new CriterionResource("platform");
win32Resource[0].addCriterionValue("win32");
CriteriaHelpScope win32Scope = new CriteriaHelpScope(win32Resource);
- assertFalse(win32Scope.inScope(topics[4]));
+ assertFalse(win32Scope.inScope(topics[4]));
}
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/TestCriteriaProvider.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/TestCriteriaProvider.java
index 547b93081..5eb4ae94a 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/TestCriteriaProvider.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/criteria/TestCriteriaProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 IBM Corporation and others.
+ * Copyright (c) 2010, 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,7 +10,9 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.criteria;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.help.ICriteria;
import org.eclipse.help.internal.Topic;
@@ -21,55 +23,59 @@ import org.eclipse.help.internal.toc.Toc;
import org.eclipse.ua.tests.help.other.UserCriteria;
import org.eclipse.ua.tests.help.other.UserToc2;
import org.eclipse.ua.tests.help.other.UserTopic2;
+import org.junit.Test;
-public class TestCriteriaProvider extends TestCase {
+public class TestCriteriaProvider {
+ @Test
public void testUserTopicWithCriteria() throws Exception {
UserTopic2 topic = new UserTopic2("Topic", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
UserCriteria criterion2 = new UserCriteria("version", "2.0", true);
topic.addCriterion(criterion1);
topic.addCriterion(criterion2);
-
+
Topic copy = new Topic(topic);
-
+
ICriteria[] nativeCriteria = copy.getCriteria();
assertEquals(2, nativeCriteria.length);
assertEquals("version", nativeCriteria[0].getName());
assertEquals("1.0", nativeCriteria[0].getValue());
assertEquals("version", nativeCriteria[1].getName());
- assertEquals("2.0", nativeCriteria[1].getValue());
-
+ assertEquals("2.0", nativeCriteria[1].getValue());
+
ICriteria[] allCriteria = CriteriaProviderRegistry.getInstance().getAllCriteria(copy);
assertTrue(containsCriterion(allCriteria, "version", "2.0"));
assertTrue(containsCriterion(allCriteria, "version", "1.0"));
assertTrue(containsCriterion(allCriteria, "containsLetter", "c"));
- assertFalse(containsCriterion(allCriteria, "containsLetter", "k"));
+ assertFalse(containsCriterion(allCriteria, "containsLetter", "k"));
}
-
+
+ @Test
public void testUserTocWithCriteria() throws Exception {
UserToc2 toc = new UserToc2("Toc", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
UserCriteria criterion2 = new UserCriteria("version", "2.0", true);
toc.addCriterion(criterion1);
toc.addCriterion(criterion2);
-
+
Toc copy = new Toc(toc);
-
+
ICriteria[] nativeCriteria = copy.getCriteria();
assertEquals(2, nativeCriteria.length);
assertEquals("version", nativeCriteria[0].getName());
assertEquals("1.0", nativeCriteria[0].getValue());
assertEquals("version", nativeCriteria[1].getName());
- assertEquals("2.0", nativeCriteria[1].getValue());
-
+ assertEquals("2.0", nativeCriteria[1].getValue());
+
ICriteria[] allCriteria = CriteriaProviderRegistry.getInstance().getAllCriteria(copy);
assertTrue(containsCriterion(allCriteria, "version", "2.0"));
assertTrue(containsCriterion(allCriteria, "version", "1.0"));
assertTrue(containsCriterion(allCriteria, "containsLetter", "c"));
- assertFalse(containsCriterion(allCriteria, "containsLetter", "k"));
+ assertFalse(containsCriterion(allCriteria, "containsLetter", "k"));
}
+ @Test
public void testCriteriaScope() throws Exception {
UserTopic2 topic = new UserTopic2("Topic", null, true);
UserCriteria criterion1 = new UserCriteria("version", "1.0", true);
@@ -83,7 +89,7 @@ public class TestCriteriaProvider extends TestCase {
CriteriaHelpScope scopeK = new CriteriaHelpScope(new CriterionResource[] { resourceK });
assertFalse(scopeK.inScope(topic));
}
-
+
//public void testWorkingSetScope() throws Exception {
// TODO write a test which creates a working set scope based on the
@@ -99,5 +105,5 @@ public class TestCriteriaProvider extends TestCase {
}
return false;
}
-
+
}

Back to the top