|
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004, 2007 Mylyn project committers and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
*******************************************************************************/ |
| 8 |
|
| 9 |
package org.eclipse.mylyn.jira.tests; |
| 10 |
|
| 11 |
import java.io.InputStream; |
| 12 |
|
| 13 |
import junit.framework.TestCase; |
| 14 |
|
| 15 |
import org.eclipse.mylyn.internal.jira.core.model.Issue; |
| 16 |
import org.eclipse.mylyn.internal.jira.core.model.ServerInfo; |
| 17 |
import org.eclipse.mylyn.internal.jira.core.service.JiraClient; |
| 18 |
import org.eclipse.mylyn.internal.jira.core.service.JiraException; |
| 19 |
import org.eclipse.mylyn.internal.jira.core.service.web.rss.RssReader; |
| 20 |
|
| 21 |
/** |
| 22 |
* @author Eugene Kuleshov |
| 23 |
*/ |
| 24 |
public class RssReaderTest extends TestCase { |
| 25 |
|
| 26 |
public void testRssReader() throws Exception { |
| 27 |
String baseUrl = "http://foo"; |
| 28 |
|
| 29 |
JiraClient client = new MockJiraClient(baseUrl) { |
| 30 |
public ServerInfo getServerInfo() throws JiraException { |
| 31 |
ServerInfo serverInfo = new ServerInfo(); |
| 32 |
return serverInfo; |
| 33 |
} |
| 34 |
}; |
| 35 |
|
| 36 |
MockIssueCollector collector = new MockIssueCollector(); |
| 37 |
RssReader reader = new RssReader(client, collector); |
| 38 |
|
| 39 |
InputStream is = getClass().getResourceAsStream("rssWithMarkup.xml"); |
| 40 |
reader.readRssFeed(is, baseUrl); |
| 41 |
|
| 42 |
Issue issue = collector.issues.get(0); |
| 43 |
|
| 44 |
String description = issue.getDescription(); |
| 45 |
|
| 46 |
// expected description is cut from rss xml with html entities converted |
| 47 |
assertEquals("Testing common markup\n" + |
| 48 |
"\n" + |
| 49 |
"<p>New paragraph</p>\n" + |
| 50 |
"\n" + |
| 51 |
"<ul>\n" + |
| 52 |
" <li>item 1</li>\n" + |
| 53 |
" <li>item 2</li>\n" + |
| 54 |
" <li>item 3</li>\n" + |
| 55 |
"</ul>\n" + |
| 56 |
"\n" + |
| 57 |
"\n" + |
| 58 |
"<div class=\"preformatted\"><div class=\"preformattedContent\">\n" + |
| 59 |
"<pre>+- root\n" + |
| 60 |
" +- child 1\n" + |
| 61 |
" +- child 2\n" + |
| 62 |
"</pre>\n" + |
| 63 |
"</div></div>", description); |
| 64 |
} |
| 65 |
} |