View | Details | Raw Unified | Return to bug 324039
Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/hudson/core/HudsonServerBehaviour.java (-3 / +6 lines)
Lines 9-14 Link Here
9
 *     Markus Knittig - initial API and implementation
9
 *     Markus Knittig - initial API and implementation
10
 *     Tasktop Technologies - improvements
10
 *     Tasktop Technologies - improvements
11
 *     Eike Stepper - improvements for bug 323759
11
 *     Eike Stepper - improvements for bug 323759
12
 *     Benjamin Muskalla - 324039: [build] tests fail with NPE
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
14
package org.eclipse.mylyn.internal.hudson.core;
15
package org.eclipse.mylyn.internal.hudson.core;
Lines 38-54 Link Here
38
import org.eclipse.mylyn.builds.core.IParameterDefinition;
39
import org.eclipse.mylyn.builds.core.IParameterDefinition;
39
import org.eclipse.mylyn.builds.core.IPasswordParameterDefinition;
40
import org.eclipse.mylyn.builds.core.IPasswordParameterDefinition;
40
import org.eclipse.mylyn.builds.core.IStringParameterDefinition;
41
import org.eclipse.mylyn.builds.core.IStringParameterDefinition;
42
import org.eclipse.mylyn.builds.core.spi.AbstractConfigurationCache;
41
import org.eclipse.mylyn.builds.core.spi.BuildPlanRequest;
43
import org.eclipse.mylyn.builds.core.spi.BuildPlanRequest;
42
import org.eclipse.mylyn.builds.core.spi.GetBuildsRequest;
43
import org.eclipse.mylyn.builds.core.spi.GetBuildsRequest.Kind;
44
import org.eclipse.mylyn.builds.core.spi.BuildServerBehaviour;
44
import org.eclipse.mylyn.builds.core.spi.BuildServerBehaviour;
45
import org.eclipse.mylyn.builds.core.spi.BuildServerConfiguration;
45
import org.eclipse.mylyn.builds.core.spi.BuildServerConfiguration;
46
import org.eclipse.mylyn.builds.core.spi.GetBuildsRequest;
47
import org.eclipse.mylyn.builds.core.spi.GetBuildsRequest.Kind;
46
import org.eclipse.mylyn.builds.core.spi.RunBuildRequest;
48
import org.eclipse.mylyn.builds.core.spi.RunBuildRequest;
47
import org.eclipse.mylyn.builds.internal.core.BuildFactory;
49
import org.eclipse.mylyn.builds.internal.core.BuildFactory;
48
import org.eclipse.mylyn.builds.internal.core.util.RepositoryWebLocation;
50
import org.eclipse.mylyn.builds.internal.core.util.RepositoryWebLocation;
49
import org.eclipse.mylyn.commons.core.IOperationMonitor;
51
import org.eclipse.mylyn.commons.core.IOperationMonitor;
50
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
52
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
51
import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
53
import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
54
import org.eclipse.mylyn.internal.hudson.core.client.HudsonConfiguration;
52
import org.eclipse.mylyn.internal.hudson.core.client.HudsonConfigurationCache;
55
import org.eclipse.mylyn.internal.hudson.core.client.HudsonConfigurationCache;
53
import org.eclipse.mylyn.internal.hudson.core.client.HudsonException;
56
import org.eclipse.mylyn.internal.hudson.core.client.HudsonException;
54
import org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient;
57
import org.eclipse.mylyn.internal.hudson.core.client.RestfulHudsonClient;
Lines 116-122 Link Here
116
		return build;
119
		return build;
117
	}
120
	}
118
121
119
	public HudsonConfigurationCache getCache() {
122
	public AbstractConfigurationCache<HudsonConfiguration> getCache() {
120
		return client.getCache();
123
		return client.getCache();
121
	}
124
	}
122
125
(-)src/org/eclipse/mylyn/internal/hudson/core/client/RestfulHudsonClient.java (-3 / +5 lines)
Lines 9-14 Link Here
9
 *     Markus Knittig - initial API and implementation
9
 *     Markus Knittig - initial API and implementation
10
 *     Tasktop Technologies - improvements
10
 *     Tasktop Technologies - improvements
11
 *     Eike Stepper - improvements for bug 323759
11
 *     Eike Stepper - improvements for bug 323759
12
 *     Benjamin Muskalla - 324039: [build] tests fail with NPE
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
14
package org.eclipse.mylyn.internal.hudson.core.client;
15
package org.eclipse.mylyn.internal.hudson.core.client;
Lines 38-43 Link Here
38
import org.apache.commons.httpclient.NameValuePair;
39
import org.apache.commons.httpclient.NameValuePair;
39
import org.eclipse.core.runtime.IStatus;
40
import org.eclipse.core.runtime.IStatus;
40
import org.eclipse.core.runtime.Status;
41
import org.eclipse.core.runtime.Status;
42
import org.eclipse.mylyn.builds.core.spi.AbstractConfigurationCache;
41
import org.eclipse.mylyn.commons.core.IOperationMonitor;
43
import org.eclipse.mylyn.commons.core.IOperationMonitor;
42
import org.eclipse.mylyn.commons.http.CommonHttpClient;
44
import org.eclipse.mylyn.commons.http.CommonHttpClient;
43
import org.eclipse.mylyn.commons.http.CommonHttpMethod;
45
import org.eclipse.mylyn.commons.http.CommonHttpMethod;
Lines 88-94 Link Here
88
90
89
	private static final String URL_API = "/api/xml"; //$NON-NLS-1$
91
	private static final String URL_API = "/api/xml"; //$NON-NLS-1$
90
92
91
	private HudsonConfigurationCache cache;
93
	private AbstractConfigurationCache<HudsonConfiguration> cache;
92
94
93
	private final CommonHttpClient client;
95
	private final CommonHttpClient client;
94
96
Lines 135-141 Link Here
135
		}
137
		}
136
	}
138
	}
137
139
138
	public HudsonConfigurationCache getCache() {
140
	public AbstractConfigurationCache<HudsonConfiguration> getCache() {
139
		return cache;
141
		return cache;
140
	}
142
	}
141
143
Lines 291-297 Link Here
291
		}.run();
293
		}.run();
292
	}
294
	}
293
295
294
	public void setCache(HudsonConfigurationCache cache) {
296
	public void setCache(AbstractConfigurationCache<HudsonConfiguration> cache) {
295
		this.cache = cache;
297
		this.cache = cache;
296
	}
298
	}
297
299
(-)src/org/eclipse/mylyn/hudson/tests/support/HudsonFixture.java (-8 / +12 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Markus Knittig - initial API and implementation
9
 *     Markus Knittig - initial API and implementation
10
 *     Benjamin Muskalla - 324039: [build] tests fail with NPE
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.mylyn.hudson.tests.support;
13
package org.eclipse.mylyn.hudson.tests.support;
Lines 31-41 Link Here
31
 */
32
 */
32
public class HudsonFixture extends TestFixture {
33
public class HudsonFixture extends TestFixture {
33
34
34
	public final static String HUDSON_TEST_URL = "http://mylyn.eclipse.org/hudson";
35
	public final static String HUDSON_TEST_URL = "http://localhost:8080/";
35
36
36
	private static HudsonFixture current;
37
	private static HudsonFixture current;
37
38
38
	private static final HudsonFixture DEFAULT = new HudsonFixture(HUDSON_TEST_URL, "1.339", "REST");
39
	private static final HudsonFixture DEFAULT = new HudsonFixture(HUDSON_TEST_URL, "1.374", "REST");
39
40
40
	/**
41
	/**
41
	 * Standard configurations for running all test against.
42
	 * Standard configurations for running all test against.
Lines 69-75 Link Here
69
		return this;
70
		return this;
70
	}
71
	}
71
72
72
	public RestfulHudsonClient connect() {
73
	public RestfulHudsonClient connect() throws Exception {
73
		return connect(getRepositoryUrl());
74
		return connect(getRepositoryUrl());
74
	}
75
	}
75
76
Lines 77-96 Link Here
77
		return connect(repositoryUrl, Proxy.NO_PROXY, level);
78
		return connect(repositoryUrl, Proxy.NO_PROXY, level);
78
	}
79
	}
79
80
80
	public RestfulHudsonClient connect(String url) {
81
	public RestfulHudsonClient connect(String url) throws Exception {
81
		return connect(url, Proxy.NO_PROXY, PrivilegeLevel.USER);
82
		return connect(url, Proxy.NO_PROXY, PrivilegeLevel.USER);
82
	}
83
	}
83
84
84
	public RestfulHudsonClient connect(String url, Proxy proxy, PrivilegeLevel level) {
85
	public RestfulHudsonClient connect(String url, Proxy proxy, PrivilegeLevel level) throws Exception {
85
		Credentials credentials = TestUtil.readCredentials(level);
86
		Credentials credentials = TestUtil.readCredentials(level);
86
		return connect(url, credentials.username, credentials.password, proxy);
87
		return connect(url, credentials.username, credentials.password, proxy);
87
	}
88
	}
88
89
89
	public RestfulHudsonClient connect(String url, String username, String password) {
90
	public RestfulHudsonClient connect(String url, String username, String password) throws Exception {
90
		return connect(url, username, password, Proxy.NO_PROXY);
91
		return connect(url, username, password, Proxy.NO_PROXY);
91
	}
92
	}
92
93
93
	public RestfulHudsonClient connect(String url, String username, String password, final Proxy proxy) {
94
	public RestfulHudsonClient connect(String url, String username, String password, final Proxy proxy)
95
			throws Exception {
94
		WebLocation location = new WebLocation(url, username, password, new IProxyProvider() {
96
		WebLocation location = new WebLocation(url, username, password, new IProxyProvider() {
95
			public Proxy getProxyForHost(String host, String proxyType) {
97
			public Proxy getProxyForHost(String host, String proxyType) {
96
				return proxy;
98
				return proxy;
Lines 99-105 Link Here
99
		if (username != null && password != null) {
101
		if (username != null && password != null) {
100
			location.setCredentials(AuthenticationType.HTTP, username, password);
102
			location.setCredentials(AuthenticationType.HTTP, username, password);
101
		}
103
		}
102
		return new RestfulHudsonClient(location);
104
		RestfulHudsonClient hudsonClient = new RestfulHudsonClient(location);
105
		hudsonClient.setCache(new MockHudsonConfigurationCache());
106
		return hudsonClient;
103
	}
107
	}
104
108
105
	@Override
109
	@Override
(-)src/org/eclipse/mylyn/hudson/tests/support/MockHudsonConfigurationCache.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Benjamin Muskalla 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
 * Contributors:
9
 *     Benjamin Muskalla - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.hudson.tests.support;
13
14
import java.io.File;
15
import java.io.IOException;
16
import java.io.ObjectInputStream;
17
18
import org.eclipse.mylyn.builds.core.spi.AbstractConfigurationCache;
19
import org.eclipse.mylyn.internal.hudson.core.client.HudsonConfiguration;
20
21
/**
22
 * @author Benjamin Muskalla
23
 */
24
public class MockHudsonConfigurationCache extends AbstractConfigurationCache<HudsonConfiguration> {
25
26
	public MockHudsonConfigurationCache() {
27
		super(new File(""));
28
	}
29
30
	@Override
31
	protected HudsonConfiguration createConfiguration() {
32
		return new HudsonConfiguration();
33
	}
34
35
	@Override
36
	protected HudsonConfiguration readConfiguration(ObjectInputStream in) throws IOException, ClassNotFoundException {
37
		return new HudsonConfiguration();
38
	}
39
40
	@Override
41
	public void setConfiguration(String url, HudsonConfiguration configuration) {
42
		// do nothing
43
	}
44
45
}

Return to bug 324039