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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Mylyn project committers 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
*******************************************************************************/
package org.eclipse.mylyn.trac.tests;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.internal.trac.core.TracPermissionDeniedException;
import org.eclipse.mylyn.internal.trac.core.TracRemoteException;
import org.eclipse.mylyn.internal.trac.core.TracXmlRpcClient;
import org.eclipse.mylyn.internal.trac.core.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
/**
* @author Steffen Pingel
* @author Xiaoyang Guan
*/
public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
public TracXmlRpcClientTest() {
super(Version.XML_RPC);
}
@Override
public void testValidate011() throws Exception {
validate(TracTestConstants.TEST_TRAC_011_URL);
}
public void testValidateFailNoAuth() throws Exception {
connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
try {
repository.validate();
fail("Expected TracLoginException");
} catch (TracPermissionDeniedException e) {
}
}
public void testMulticallExceptions() throws Exception {
connect010();
try {
((TracXmlRpcClient) repository).getTickets(new int[] { 1, Integer.MAX_VALUE });
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
}
public void testUpdateAttributes010() throws Exception {
connect010();
updateAttributes();
}
public void testUpdateAttributes011() throws Exception {
connect011();
updateAttributes();
}
public void updateAttributes() throws Exception {
assertNull(repository.getMilestones());
repository.updateAttributes(new NullProgressMonitor(), true);
TracVersion[] versions = repository.getVersions();
assertEquals(2, versions.length);
Arrays.sort(versions, new Comparator<TracVersion>() {
public int compare(TracVersion o1, TracVersion o2) {
return o1.getName().compareTo(o2.getName());
}
});
assertEquals("1.0", versions[0].getName());
assertEquals("", versions[0].getDescription());
assertEquals(new Date(0), versions[0].getTime());
assertEquals("2.0", versions[1].getName());
assertEquals("", versions[1].getDescription());
assertEquals(new Date(0), versions[1].getTime());
}
public void testWikiToHtml() throws Exception {
connect010();
String html = ((TracXmlRpcClient) repository).wikiToHtml("");
assertEquals("", html);
html = ((TracXmlRpcClient) repository).wikiToHtml("A simple line of text.");
assertEquals("<p>\nA simple line of text.\n</p>\n", html);
String source = "= WikiFormattingTesting =\n" + " * '''bold''', '''!''' can be bold too''', and '''! '''\n"
+ " * ''italic''\n" + " * '''''bold italic'''''\n" + " * __underline__\n"
+ " * {{{monospace}}} or `monospace`\n" + " * ~~strike-through~~\n" + " * ^superscript^ \n"
+ " * ,,subscript,,\n" + "= Heading =\n" + "== Subheading ==\n";
String expectedHtml = "<h1 id=\"WikiFormattingTesting\"><a class=\"missing wiki\" href=\"http://mylyn.eclipse.org/trac010/wiki/WikiFormattingTesting\" rel=\"nofollow\">WikiFormattingTesting?</a></h1>\n<ul><li><strong>bold</strong>, <strong>\'\'\' can be bold too</strong>, and <strong>! </strong>\n</li><li><i>italic</i>\n</li><li><strong><i>bold italic</i></strong>\n</li><li><span class=\"underline\">underline</span>\n</li><li><tt>monospace</tt> or <tt>monospace</tt>\n</li><li><del>strike-through</del>\n</li><li><sup>superscript</sup> \n</li><li><sub>subscript</sub>\n</li></ul><h1 id=\"Heading\">Heading</h1>\n<h2 id=\"Subheading\">Subheading</h2>\n";
html = ((TracXmlRpcClient) repository).wikiToHtml(source);
assertEquals(expectedHtml, html);
}
}
|