Example #1
0
  @Test
  public void testInitializationManualProxy() {
    Map<String, String> proxyData = new HashMap<String, String>();
    proxyData.put("proxyType", "manual");
    proxyData.put("httpProxy", "http.proxy:1234");
    proxyData.put("ftpProxy", "ftp.proxy");
    proxyData.put("sslProxy", "ssl.proxy");
    proxyData.put("noProxy", "localhost,127.0.0.*");
    proxyData.put("socksProxy", "socks.proxy:65555");
    proxyData.put("socksUsername", "test1");
    proxyData.put("socksPassword", "test2");

    Proxy proxy = new Proxy(proxyData);

    assertEquals(ProxyType.MANUAL, proxy.getProxyType());
    assertEquals("ftp.proxy", proxy.getFtpProxy());
    assertEquals("http.proxy:1234", proxy.getHttpProxy());
    assertEquals("ssl.proxy", proxy.getSslProxy());
    assertEquals("socks.proxy:65555", proxy.getSocksProxy());
    assertEquals("test1", proxy.getSocksUsername());
    assertEquals("test2", proxy.getSocksPassword());
    assertEquals("localhost,127.0.0.*", proxy.getNoProxy());

    assertNull(proxy.getProxyAutoconfigUrl());
    assertFalse(proxy.isAutodetect());
  }
Example #2
0
  @Test
  public void testManualProxy() {
    Proxy proxy = new Proxy();

    proxy
        .setHttpProxy("http.proxy:1234")
        .setFtpProxy("ftp.proxy")
        .setSslProxy("ssl.proxy")
        .setNoProxy("localhost,127.0.0.*")
        .setSocksProxy("socks.proxy:65555")
        .setSocksUsername("test1")
        .setSocksPassword("test2");

    assertEquals(ProxyType.MANUAL, proxy.getProxyType());
    assertEquals("ftp.proxy", proxy.getFtpProxy());
    assertEquals("http.proxy:1234", proxy.getHttpProxy());
    assertEquals("ssl.proxy", proxy.getSslProxy());
    assertEquals("socks.proxy:65555", proxy.getSocksProxy());
    assertEquals("test1", proxy.getSocksUsername());
    assertEquals("test2", proxy.getSocksPassword());
    assertEquals("localhost,127.0.0.*", proxy.getNoProxy());

    assertNull(proxy.getProxyAutoconfigUrl());
    assertFalse(proxy.isAutodetect());
  }
Example #3
0
  @Test
  public void testNotInitializedProxy() {
    Proxy proxy = new Proxy();

    assertEquals(ProxyType.UNSPECIFIED, proxy.getProxyType());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertNull(proxy.getProxyAutoconfigUrl());
    assertFalse(proxy.isAutodetect());
  }
Example #4
0
  @Test
  public void testAutodetectProxy() {
    Proxy proxy = new Proxy();
    proxy.setAutodetect(true);

    assertEquals(proxy.getProxyType(), ProxyType.AUTODETECT);
    assertTrue(proxy.isAutodetect());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertNull(proxy.getProxyAutoconfigUrl());
  }
Example #5
0
  @Test
  public void testPACProxy() {
    Proxy proxy = new Proxy();
    proxy.setProxyAutoconfigUrl("http://aaa/bbb.pac");

    assertEquals(proxy.getProxyType(), ProxyType.PAC);
    assertEquals("http://aaa/bbb.pac", proxy.getProxyAutoconfigUrl());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertFalse(proxy.isAutodetect());
  }
Example #6
0
  @Test
  public void testInitializationDirectProxy() {
    Map<String, String> proxyData = new HashMap<String, String>();
    proxyData.put("proxyType", "DIRECT");

    Proxy proxy = new Proxy(proxyData);

    assertEquals(ProxyType.DIRECT, proxy.getProxyType());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertFalse(proxy.isAutodetect());
    assertNull(proxy.getProxyAutoconfigUrl());
  }
Example #7
0
  @Test
  public void testInitializationAutodetectProxy() {
    Map<String, Object> proxyData = new HashMap<String, Object>();
    proxyData.put("proxyType", "AUTODETECT");
    proxyData.put("autodetect", true);

    Proxy proxy = new Proxy(proxyData);

    assertEquals(ProxyType.AUTODETECT, proxy.getProxyType());
    assertTrue(proxy.isAutodetect());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertNull(proxy.getProxyAutoconfigUrl());
  }
Example #8
0
  @Test
  public void testInitializationPACProxy() {
    Map<String, String> proxyData = new HashMap<String, String>();
    proxyData.put("proxyType", "PAC");
    proxyData.put("proxyAutoconfigUrl", "http://aaa/bbb.pac");

    Proxy proxy = new Proxy(proxyData);

    assertEquals(ProxyType.PAC, proxy.getProxyType());
    assertEquals("http://aaa/bbb.pac", proxy.getProxyAutoconfigUrl());

    assertNull(proxy.getFtpProxy());
    assertNull(proxy.getHttpProxy());
    assertNull(proxy.getSslProxy());
    assertNull(proxy.getSocksProxy());
    assertNull(proxy.getSocksUsername());
    assertNull(proxy.getSocksPassword());
    assertNull(proxy.getNoProxy());
    assertFalse(proxy.isAutodetect());
  }