Skip to main content
summaryrefslogtreecommitdiffstats
blob: f3d1a6b4be9db4dc3c14ceaddf520ec448939f15 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*******************************************************************************
* Copyright (c) 2004, 2008 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.trac.tests.client;

import java.util.Arrays;
import java.util.Comparator;

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.internal.trac.core.client.TracException;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
import org.eclipse.mylyn.trac.tests.support.TracTestConstants;

/**
 * @author Steffen Pingel
 */
public class TracWebClientTest extends AbstractTracClientRepositoryTest {

	public TracWebClientTest() {
		super(Version.TRAC_0_9);
	}

	public void testValidate096() throws Exception {
		validate(TracTestConstants.TEST_TRAC_096_URL);
	}

	@Override
	public void testValidate011() throws Exception {
		try {
			validate(TracTestConstants.TEST_TRAC_011_URL);
		} catch (TracException e) {
		}
	}

	public void testValidateAnyPage() throws Exception {
		connect("http://mylyn.eclipse.org/");
		try {
			repository.validate(callback);
			fail("Expected TracException");
		} catch (TracException e) {
		}
	}

	public void testValidateAnonymousLogin() throws Exception {
		connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
		repository.validate(callback);

		connect(TracTestConstants.TEST_TRAC_096_URL, "", "");
		repository.validate(callback);
	}

	public void testUpdateAttributesAnonymous096() throws Exception {
		connect(TracTestConstants.TEST_TRAC_096_URL, "", "");
		updateAttributes();
	}

	public void testUpdateAttributesAnonymous010() throws Exception {
		connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
		updateAttributes();
	}

	private void updateAttributes() throws TracException {
		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("2.0", versions[1].getName());
	}

}

Back to the top