Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9034a424f1973d90964569525188e7a8f5a52776 (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
/****************************************************************************
 * Copyright (c) 2009 IBM, Inc., Composent, Inc. 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:
 *    IBM, Inc. - initial API and implementation
 *****************************************************************************/
package org.eclipse.ecf.tests.filetransfer;

import org.eclipse.ecf.core.util.Proxy;
import org.eclipse.ecf.core.util.ProxyAddress;

public class URLRetrieveTestProxy extends URLRetrieveTest {

	// This test depends upon the setting of two system properties:
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyHost=<proxy host name>
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPort=<proxy port>
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyUsername=<username for proxy authentication>
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPassword=<password for proxy authentication>
	// e.g.
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyHost=myproxy.foo.com
	// org.eclipse.ecf.tests.filetransfer.URLRetrieveTestProxy.proxyPort=8888
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
//		retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(
//				"localhost", 909)));
		try {
			String proxyName = System.getProperty(this.getClass().getName()+".proxyHost");
			if (proxyName != null) {
				String pPort = System.getProperty(this.getClass().getName()+".proxyPort");
				int proxyPort = ((pPort != null)?Integer.parseInt(pPort):9808);

				String username = System.getProperty(this.getClass().getName()+".proxyUsername");
				if (username != null) {
					String password = System.getProperty(this.getClass().getName()+".proxyPassword");
					retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(
					proxyName, proxyPort), username, password) );
				} else {
					retrieveAdapter.setProxy(new Proxy(Proxy.Type.HTTP, new ProxyAddress(
							proxyName, proxyPort)));
				}
			}
		} catch (Exception e) {
			// Print out problems to system err
			e.printStackTrace(System.err);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		retrieveAdapter.setProxy(null);
		super.tearDown();
	}

}

Back to the top