Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-05-29 14:46:11 +0000
committerspingel2011-05-29 14:46:11 +0000
commit3845075581138bb690843b570f0723ef240f18a3 (patch)
treed808823a40f2833468081c30e6c0050b5a3878e9 /org.eclipse.mylyn.tasks.tests/src
parent293e1f6cf4284f2c5465175460e765826637d1c8 (diff)
downloadorg.eclipse.mylyn.tasks-3845075581138bb690843b570f0723ef240f18a3.tar.gz
org.eclipse.mylyn.tasks-3845075581138bb690843b570f0723ef240f18a3.tar.xz
org.eclipse.mylyn.tasks-3845075581138bb690843b570f0723ef240f18a3.zip
NEW - bug 339467: [discovery] inform users when new versions or connectors are available
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339467
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java142
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/FeedReaderTest.java66
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java31
3 files changed, 239 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java
new file mode 100644
index 000000000..bc90e9034
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.core;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.mylyn.internal.tasks.core.notifications.Environment;
+import org.eclipse.mylyn.internal.tasks.core.notifications.FeedEntry;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
+
+/**
+ * @author Steffen Pingel
+ */
+public class EnvironmentTest extends TestCase {
+
+ private class StubEntry extends FeedEntry {
+
+ private final Map<String, String> map;
+
+ public StubEntry(Map<String, String> map) {
+ this.map = map;
+ }
+
+ @Override
+ public List<String> getFilters(String key) {
+ String value = getFilter(key);
+ if (value != null) {
+ return Collections.singletonList(value);
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public String getFilter(String key) {
+ return map.get(key);
+ }
+
+ }
+
+ private Environment environment;
+
+ Set<String> installedFeatures;
+
+ @Override
+ protected void setUp() throws Exception {
+ installedFeatures = new HashSet<String>();
+ environment = new Environment() {
+ @Override
+ public Set<String> getInstalledFeatures(IProgressMonitor monitor) {
+ return installedFeatures;
+ }
+ };
+ }
+
+ public void testGetRuntimeVersion() {
+ Version runtimeVersion = environment.getRuntimeVersion();
+ assertTrue("Expected value between 1.5-1.8, got " + runtimeVersion,
+ new VersionRange("[1.5.0,1.8.0)").isIncluded(runtimeVersion));
+ }
+
+ public void testGetPlatformVersion() {
+ Version platformVersion = environment.getPlatformVersion();
+ if (Platform.isRunning()) {
+ assertTrue("Expected value between 3.4-5.0, got " + platformVersion,
+ new VersionRange("[3.4.0,5.0.0)").isIncluded(platformVersion));
+ } else {
+ assertEquals(Version.emptyVersion, platformVersion);
+ }
+ }
+
+ public void testGetFrameworkVersion() {
+ Version frameworkVersion = environment.getFrameworkVersion();
+ if (Platform.isRunning()) {
+ assertTrue("Expected value > 3.6, got " + frameworkVersion,
+ new VersionRange("3.6.0").isIncluded(frameworkVersion));
+ } else {
+ assertEquals(Version.emptyVersion, frameworkVersion);
+ }
+ }
+
+ public void testMatchesFrameworkVersion() {
+ Map<String, String> values = new HashMap<String, String>();
+ assertTrue(environment.matches(new StubEntry(values), null));
+
+ values.put("frameworkVersion", "[1.0.0,2.0.0)");
+ assertFalse(environment.matches(new StubEntry(values), null));
+
+ values.put("frameworkVersion", "[0.0.0,10.0.0)");
+ assertTrue(environment.matches(new StubEntry(values), null));
+ }
+
+ public void testMatchesRequires() {
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("requires", "org.eclipse.mylyn");
+ assertFalse(environment.matches(new StubEntry(values), null));
+
+ installedFeatures.add("org.eclipse.mylyn");
+ assertTrue(environment.matches(new StubEntry(values), null));
+ }
+
+ public void testMatchesConflicts() {
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("conflicts", "org.eclipse.mylyn");
+ assertTrue(environment.matches(new StubEntry(values), null));
+
+ installedFeatures.add("org.eclipse.mylyn");
+ assertFalse(environment.matches(new StubEntry(values), null));
+ }
+
+ public void testMatchesRequiresConflicts() {
+ Map<String, String> values = new HashMap<String, String>();
+ values.put("requires", "org.eclipse.mylyn");
+ values.put("conflicts", "org.eclipse.cdt");
+ assertFalse(environment.matches(new StubEntry(values), null));
+
+ installedFeatures.add("org.eclipse.mylyn");
+ assertTrue(environment.matches(new StubEntry(values), null));
+
+ installedFeatures.add("org.eclipse.cdt");
+ assertFalse(environment.matches(new StubEntry(values), null));
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/FeedReaderTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/FeedReaderTest.java
new file mode 100644
index 000000000..a42345a89
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/FeedReaderTest.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.core;
+
+import java.util.Collections;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.tests.support.CommonTestUtil;
+import org.eclipse.mylyn.internal.tasks.core.notifications.Environment;
+import org.eclipse.mylyn.internal.tasks.core.notifications.FeedEntry;
+import org.eclipse.mylyn.internal.tasks.core.notifications.FeedReader;
+
+/**
+ * @author Steffen Pingel
+ */
+public class FeedReaderTest extends TestCase {
+
+ private FeedReader reader;
+
+ private Environment environment;
+
+ @Override
+ protected void setUp() throws Exception {
+ environment = new Environment() {
+ @Override
+ public Set<String> getInstalledFeatures(IProgressMonitor monitor) {
+ return Collections.singleton("org.eclipse.mylyn");
+ }
+ };
+ reader = new FeedReader(environment);
+ }
+
+ public void testParse() throws Exception {
+ assertEquals(Status.OK_STATUS, reader.parse(
+ CommonTestUtil.getResource(FeedReaderTest.class, "testdata/FeedReaderTest/update1.xml"), null));
+ assertEquals(2, reader.getEntries().size());
+ Collections.sort(reader.getEntries());
+
+ FeedEntry entry = reader.getEntries().get(0);
+ assertEquals("New Connectors", entry.getTitle());
+ assertEquals("[0.0.0,3.7.0)", entry.getFilter("frameworkVersion"));
+ assertEquals("New connectors are now available. <a href=\"#discovery\">Show connectors</a>.",
+ entry.getDescription());
+
+ entry = reader.getEntries().get(1);
+ assertEquals("Mylyn 3.6 is now available", entry.getTitle());
+ assertEquals("1.5.0", entry.getFilter("runtimeVersion"));
+ assertEquals(
+ "Mylyn 3.7 is now available. <a href=\"http://eclipse.org/mylyn/new/\">See New and Noteworthy</a> for details.",
+ entry.getDescription());
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
new file mode 100644
index 000000000..b8edda030
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskListServiceMessageControlTest extends TestCase {
+
+ public void testGetAction() {
+ assertEquals("abc", TaskListServiceMessageControl.getAction("ABC"));
+ assertEquals("abc", TaskListServiceMessageControl.getAction("abc"));
+ assertEquals("def", TaskListServiceMessageControl.getAction("http://eclipse.org?action=DEF"));
+ assertEquals("defg", TaskListServiceMessageControl.getAction("http://eclipse.org?action=defg&foo=bar"));
+ assertEquals(null, TaskListServiceMessageControl.getAction("http://eclipse.org?foo=bar&action=defg"));
+ }
+
+}

Back to the top