Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-12-05 16:34:12 +0000
committerSteffen Pingel2011-12-05 16:34:12 +0000
commit37fc151f7c3bcd975ea83fdc7d02a41a77e7f538 (patch)
tree76d541fa2009856d01e6e398b132caabf3ecb3f7 /org.eclipse.mylyn.tasks.tests
parente16cd7c253208a4324c43854bfb743e693beb1e7 (diff)
downloadorg.eclipse.mylyn.tasks-37fc151f7c3bcd975ea83fdc7d02a41a77e7f538.tar.gz
org.eclipse.mylyn.tasks-37fc151f7c3bcd975ea83fdc7d02a41a77e7f538.tar.xz
org.eclipse.mylyn.tasks-37fc151f7c3bcd975ea83fdc7d02a41a77e7f538.zip
NEW - bug 361048: [api] move service message implementation to
notifications component https://bugs.eclipse.org/bugs/show_bug.cgi?id=361048 Change-Id: I4f88348bfc60a084a01378931fd8210817fa8d79
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java152
-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/util/ServiceMessageManagerTest.java82
4 files changed, 1 insertions, 300 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index 67b304562..3ae3738c8 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Require-Bundle: org.junit,
org.eclipse.mylyn.commons.core,
org.eclipse.mylyn.commons.net,
org.eclipse.mylyn.commons.sdk.util,
+ org.eclipse.mylyn.commons.notifications.ui,
org.eclipse.mylyn.commons.ui,
org.eclipse.mylyn.commons.workbench,
org.eclipse.mylyn.monitor.core,
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
deleted file mode 100644
index 04d311efc..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/EnvironmentTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * 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>();
- System.setProperty("EnvironmentTest", "2");
- 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));
- }
-
- public void testMatchesFilter() {
- Map<String, String> values = new HashMap<String, String>();
- values.put("filter", "(EnvironmentTest<=1)");
- assertFalse(environment.matches(new StubEntry(values), null));
-
- values.put("filter", "(EnvironmentTest=2)");
- assertTrue(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
deleted file mode 100644
index 45c735753..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/FeedReaderTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * 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.sdk.util.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/util/ServiceMessageManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java
deleted file mode 100644
index 72aaf758f..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/ServiceMessageManagerTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.tasks.tests.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.httpclient.HttpStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessage;
-import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageManager;
-import org.eclipse.mylyn.internal.tasks.core.notifications.ServiceMessageXmlHandler;
-
-/**
- * @author Robert Elves
- */
-public class ServiceMessageManagerTest extends TestCase {
-
- private static final String MESSAGE_XML_URL = "http://mylyn.eclipse.org/message.xml";
-
- public void testRetrievingMessage() throws Exception {
- ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", "", 0l);
- int status = manager.updateServiceMessage(new NullProgressMonitor());
- assertEquals(HttpStatus.SC_OK, status);
- assertEquals(2, manager.getServiceMessages().size());
-
- ServiceMessage message = manager.getServiceMessages().get(1);
- assertEquals("1", message.getId());
- assertEquals("140 character description here....", message.getDescription());
- assertEquals("Mylyn 3.4 now available!", message.getTitle());
- assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl());
- assertEquals("Mylyn 3.4 now available!", message.getTitle());
- assertEquals("dialog_messasge_info_image", message.getImage());
- }
-
- public void testETag() throws Exception {
-
- ServiceMessageManager manager = new ServiceMessageManager(MESSAGE_XML_URL, "", "", 0l);
- int status = manager.updateServiceMessage(new NullProgressMonitor());
- assertEquals(HttpStatus.SC_OK, status);
- ServiceMessage message = manager.getServiceMessages().get(0);
-
- assertNotNull(message.getLastModified());
- assertNotNull(message.getETag());
-
- status = manager.updateServiceMessage(new NullProgressMonitor());
- assertEquals(HttpStatus.SC_NOT_MODIFIED, status);
- }
-
- public void testParsingMessageXml() throws Exception {
- String messageXml = "<ServiceMessage> <id>1</id><description>140 character description here....</description><title>Mylyn 3.4 now available!</title><url>http://eclipse.org/mylyn/downloads</url><image>dialog_messasge_info_image</image></ServiceMessage>";
- InputStream is = new ByteArrayInputStream(messageXml.getBytes("UTF-8"));
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(false);
- SAXParser parser = factory.newSAXParser();
- ServiceMessageXmlHandler handler = new ServiceMessageXmlHandler();
- parser.parse(is, handler);
- ServiceMessage message = handler.getMessages().get(0);
-
- assertEquals("1", message.getId());
- assertEquals("140 character description here....", message.getDescription());
- assertEquals("Mylyn 3.4 now available!", message.getTitle());
- assertEquals("http://eclipse.org/mylyn/downloads", message.getUrl());
- assertEquals("Mylyn 3.4 now available!", message.getTitle());
- assertEquals("dialog_messasge_info_image", message.getImage());
- }
-
-}

Back to the top