| 1 |
package com.github.markusbernhardt.proxy; |
| 2 |
|
| 3 |
import java.io.File; |
| 4 |
import java.net.InetSocketAddress; |
| 5 |
import java.net.Proxy; |
| 6 |
import java.net.Proxy.Type; |
| 7 |
|
| 8 |
import com.github.markusbernhardt.proxy.util.PlatformUtil; |
| 9 |
|
| 10 |
import java.net.URI; |
| 11 |
import java.net.URISyntaxException; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public class TestUtil { |
| 21 |
|
| 22 |
public static final String TEST_DATA_FOLDER = "src" + File.separator + "test" + File.separator + "resources" |
| 23 |
+ File.separator; |
| 24 |
|
| 25 |
public static final Proxy HTTP_TEST_PROXY = new Proxy(Type.HTTP, |
| 26 |
InetSocketAddress.createUnresolved("http_proxy.unit-test.invalid", 8090)); |
| 27 |
public static final Proxy HTTPS_TEST_PROXY = new Proxy(Type.HTTP, |
| 28 |
InetSocketAddress.createUnresolved("https_proxy.unit-test.invalid", 8091)); |
| 29 |
public static final Proxy FTP_TEST_PROXY = new Proxy(Type.HTTP, |
| 30 |
InetSocketAddress.createUnresolved("ftp_proxy.unit-test.invalid", 8092)); |
| 31 |
public static final Proxy SOCKS_TEST_PROXY = new Proxy(Type.SOCKS, |
| 32 |
InetSocketAddress.createUnresolved("socks_proxy.unit-test.invalid", 8095)); |
| 33 |
|
| 34 |
public static final URI NO_PROXY_TEST_URI; |
| 35 |
public static final URI HTTP_TEST_URI; |
| 36 |
public static final URI HTTPS_TEST_URI; |
| 37 |
public static final URI FTP_TEST_URI; |
| 38 |
public static final URI SOCKS_TEST_URI; |
| 39 |
public static final URI LOCAL_TEST_URI; |
| 40 |
public static final URI SOCKET_TEST_URI; |
| 41 |
|
| 42 |
|
| 43 |
static { |
| 44 |
try { |
| 45 |
NO_PROXY_TEST_URI = new URI("http://no_proxy.unit-test.invalid/"); |
| 46 |
HTTP_TEST_URI = new URI("http://host1.unit-test.invalid/"); |
| 47 |
HTTPS_TEST_URI = new URI("https://host1.unit-test.invalid/"); |
| 48 |
FTP_TEST_URI = new URI("ftp://host1.unit-test.invalid/"); |
| 49 |
SOCKS_TEST_URI = new URI("socks://host1.unit-test.invalid/"); |
| 50 |
LOCAL_TEST_URI = new URI("http://myhost"); |
| 51 |
SOCKET_TEST_URI = new URI("socket://host1.unit-test.invalid/"); |
| 52 |
} catch (URISyntaxException e) { |
| 53 |
throw new RuntimeException("URI error" + e.getMessage()); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public static final void setTestDataFolder(String folder) { |
| 65 |
System.setProperty(PlatformUtil.OVERRIDE_HOME_DIR, |
| 66 |
System.getProperty("user.dir") + File.separator + TestUtil.TEST_DATA_FOLDER + folder); |
| 67 |
} |
| 68 |
|
| 69 |
} |