Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF2
-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
-rw-r--r--org.eclipse.mylyn.tasks.tests/testdata/FeedReaderTest/update1.xml41
5 files changed, 282 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index bc0ef9598..7cea214a0 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -33,10 +33,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.equinox.security,
org.eclipse.mylyn.tests.util,
org.eclipse.mylyn.tasks.search
+Import-Package: com.sun.syndication.feed.synd;version="0.9.0";resolution:=optional
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-internal:=true,
org.eclipse.mylyn.tasks.tests.core;x-internal:=true,
org.eclipse.mylyn.tasks.tests.data;x-internal:=true,
+ org.eclipse.mylyn.tasks.tests.support;x-internal:=true,
org.eclipse.mylyn.tasks.tests.ui;x-internal:=true,
org.eclipse.mylyn.tasks.tests.ui.editor;x-internal:=true,
org.eclipse.mylyn.tasks.tests.util;x-internal:=true
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"));
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/testdata/FeedReaderTest/update1.xml b/org.eclipse.mylyn.tasks.tests/testdata/FeedReaderTest/update1.xml
new file mode 100644
index 000000000..47fbb4af3
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/testdata/FeedReaderTest/update1.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ >
+<channel>
+<title>Mylyn Updates</title>
+<link>http://eclipse.org/mylyn</link>
+<description>Mylyn Updates</description>
+<lastBuildDate>Fri, 27 May 2011 17:33:37 +0000</lastBuildDate>
+<language>en</language>
+<item>
+<title>Mylyn 3.6 is now available</title>
+<link>http://eclipse.org/mylyn/new/</link>
+<pubDate>Thu, 24 Mar 2011 14:00:07 +0000</pubDate>
+<dc:creator>Steffen Pingel</dc:creator>
+<dc:subject>runtimeVersion=1.5.0</dc:subject>
+<dc:subject>requires=org.eclipse.mylyn</dc:subject>
+<category>Mylyn</category>
+<guid isPermaLink="false">20110527-0000</guid>
+<description>Mylyn 3.7 is now available. &lt;a href="http://eclipse.org/mylyn/new/"&gt;See New and Noteworthy&lt;/a&gt; for details.</description>
+</item>
+<item>
+<title>New Connectors</title>
+<link>http://eclipse.org/mylyn/new/</link>
+<pubDate>Fri, 27 May 2011 12:00:00 +0000</pubDate>
+<dc:creator>Steffen Pingel</dc:creator>
+<dc:subject>frameworkVersion=[0.0.0,3.7.0)</dc:subject>
+<guid isPermaLink="false">20110527-0001</guid>
+<description>New connectors are now available. &lt;a href="#discovery"&gt;Show connectors&lt;/a&gt;.</description>
+</item>
+<item>
+<title>Filtered Item</title>
+<link>http://eclipse.org/mylyn/new/</link>
+<pubDate>Fri, 27 May 2011 12:00:00 +0000</pubDate>
+<dc:creator>Steffen Pingel</dc:creator>
+<dc:subject>frameworkVersion=[1.0.0,2.0.0)</dc:subject>
+<guid isPermaLink="false">20110527-0002</guid>
+<description>Specifies an unsatisfiable framework version.</description>
+</item>
+</channel>
+</rss>

Back to the top