Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8aa11d3393dd4fc618a38516caef14dfbaa6247c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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.commons.notifications.tests.feed;

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.notifications.core.NotificationEnvironment;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
import org.eclipse.mylyn.internal.commons.notifications.feed.FeedEntry;
import org.eclipse.mylyn.internal.commons.notifications.feed.FeedReader;

/**
 * @author Steffen Pingel
 */
public class FeedReaderTest extends TestCase {

	private FeedReader reader;

	private NotificationEnvironment environment;

	@Override
	protected void setUp() throws Exception {
		environment = new NotificationEnvironment() {
			@Override
			public Set<String> getInstalledFeatures(IProgressMonitor monitor) {
				return Collections.singleton("org.eclipse.mylyn");
			}
		};
		reader = new FeedReader("eventId", 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());
	}

}

Back to the top