当前位置: 首页>>代码示例>>Java>>正文


Java Proxy类代码示例

本文整理汇总了Java中org.apache.maven.settings.Proxy的典型用法代码示例。如果您正苦于以下问题:Java Proxy类的具体用法?Java Proxy怎么用?Java Proxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Proxy类属于org.apache.maven.settings包,在下文中一共展示了Proxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: it_should_get_active_http_proxies

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void it_should_get_active_http_proxies() {
	Proxy p1 = createProxy("http", "foo1", true);
	Proxy p2 = createProxy("https", "foo2", true);

	Proxy p3 = createProxy("http", "foo3", false);
	Proxy p4 = createProxy("https", "foo4", false);
	Proxy p5 = createProxy("socks", "foo5", true);

	List<ProxyConfig> configs = findHttpActiveProfiles(asList(p1, p2, p3, p4, p5));

	assertThat(configs)
		.isNotNull()
		.isNotEmpty()
		.hasSize(2)
		.extracting("host")
		.containsExactly("foo1", "foo2");
}
 
开发者ID:mjeanroy,项目名称:node-maven-plugin,代码行数:19,代码来源:ProxyConfigUtilsTest.java

示例2: it_should_create_proxy_configuration

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void it_should_create_proxy_configuration() {
	Proxy proxy = mock(Proxy.class);
	when(proxy.getProtocol()).thenReturn("http");
	when(proxy.getHost()).thenReturn("squid.local");
	when(proxy.getPort()).thenReturn(8080);
	when(proxy.getUsername()).thenReturn(null);
	when(proxy.getPassword()).thenReturn(null);

	ProxyConfig config = proxyConfiguration(proxy);

	assertThat(config.isSecure()).isFalse();
	assertThat(config.hasAuthentication()).isFalse();
	assertThat(config.toArgument()).isEqualTo("http://squid.local:8080");
	assertThat(config.toString()).isEqualTo("http://squid.local:8080");
}
 
开发者ID:mjeanroy,项目名称:node-maven-plugin,代码行数:17,代码来源:ProxyConfigTest.java

示例3: it_should_create_authenticated_proxy_configuration

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void it_should_create_authenticated_proxy_configuration() {
	Proxy proxy = mock(Proxy.class);
	when(proxy.getProtocol()).thenReturn("http");
	when(proxy.getHost()).thenReturn("squid.local");
	when(proxy.getPort()).thenReturn(8080);
	when(proxy.getUsername()).thenReturn("mjeanroy");
	when(proxy.getPassword()).thenReturn("foobar");

	ProxyConfig config = proxyConfiguration(proxy);

	assertThat(config.isSecure()).isFalse();
	assertThat(config.hasAuthentication()).isTrue();
	assertThat(config.toArgument()).isEqualTo("http://mjeanroy:[email protected]:8080");
	assertThat(config.toString()).isEqualTo("http://mjeanroy:********@squid.local:8080");
}
 
开发者ID:mjeanroy,项目名称:node-maven-plugin,代码行数:17,代码来源:ProxyConfigTest.java

示例4: it_should_create_secure_proxy_configuration

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void it_should_create_secure_proxy_configuration() {
	Proxy proxy = mock(Proxy.class);
	when(proxy.getProtocol()).thenReturn("https");
	when(proxy.getHost()).thenReturn("squid.local");
	when(proxy.getPort()).thenReturn(8080);
	when(proxy.getUsername()).thenReturn("mjeanroy");
	when(proxy.getPassword()).thenReturn("foobar");

	ProxyConfig config = proxyConfiguration(proxy);

	assertThat(config.isSecure()).isTrue();
	assertThat(config.hasAuthentication()).isTrue();
	assertThat(config.toArgument()).isEqualTo("http://mjeanroy:[email protected]:8080");
	assertThat(config.toString()).isEqualTo("http://mjeanroy:********@squid.local:8080");
}
 
开发者ID:mjeanroy,项目名称:node-maven-plugin,代码行数:17,代码来源:ProxyConfigTest.java

示例5: it_should_ignore_proxy_configuration

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void it_should_ignore_proxy_configuration() throws Exception {
	T mojo = createMojo("mojo", false);
	writePrivate(mojo, "ignoreProxies", true);

	Proxy httpProxy = createProxy("http", "localhost", 8080, "mjeanroy", "foo");
	Proxy httpsProxy = createProxy("https", "localhost", 8080, "mjeanroy", "foo");

	Settings settings = mock(Settings.class);
	when(settings.getProxies()).thenReturn(asList(httpProxy, httpsProxy));
	writePrivate(mojo, "settings", settings);

	CommandResult result = createResult(false);
	CommandExecutor executor = readPrivate(mojo, "executor");
	ArgumentCaptor<Command> cmdCaptor = ArgumentCaptor.forClass(Command.class);
	when(executor.execute(any(File.class), cmdCaptor.capture(), any(NpmLogger.class))).thenReturn(result);

	mojo.execute();

	Command command = cmdCaptor.getValue();
	assertThat(command.toString())
		.doesNotContain("--proxy http://mjeanroy:[email protected]:8080")
		.doesNotContain("--https-proxy http://mjeanroy:[email protected]:8080");
}
 
开发者ID:mjeanroy,项目名称:node-maven-plugin,代码行数:25,代码来源:AbstractNpmScriptMojoTest.java

示例6: getProxyConfig

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
static ProxyConfig getProxyConfig(MavenSession mavenSession) {
  if (
          mavenSession == null ||
                  mavenSession.getSettings() == null ||
                  mavenSession.getSettings().getActiveProxy() == null ||
                  !mavenSession.getSettings().getActiveProxy().isActive()
          ) {
    return null;
  } else {
    Proxy mavenProxy = mavenSession.getSettings().getActiveProxy();
    return new ProxyConfig(
            mavenProxy.getProtocol(),
            mavenProxy.getHost(),
            mavenProxy.getPort(),
            mavenProxy.getUsername(),
            mavenProxy.getPassword());
  }
}
 
开发者ID:RabbitStewDio,项目名称:frontend-tomcat-maven-plugin,代码行数:19,代码来源:MojoUtils.java

示例7: getProxyConfig

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) {
    if (mavenSession == null ||
            mavenSession.getSettings() == null ||
            mavenSession.getSettings().getProxies() == null ||
            mavenSession.getSettings().getProxies().isEmpty()) {
        return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList());
    } else {
        final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies();

        final List<ProxyConfig.Proxy> proxies = new ArrayList<ProxyConfig.Proxy>(mavenProxies.size());

        for (Proxy mavenProxy : mavenProxies) {
            if (mavenProxy.isActive()) {
                mavenProxy = decryptProxy(mavenProxy, decrypter);
                proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(),
                        mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts()));
            }
        }

        LOGGER.info("Found proxies: {}", proxies);
        return new ProxyConfig(proxies);
    }
}
 
开发者ID:eirslett,项目名称:frontend-maven-plugin,代码行数:24,代码来源:MojoUtils.java

示例8: testUnAuthorizedProxyRequest

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void testUnAuthorizedProxyRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello Proxy!")));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello Proxy!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:17,代码来源:HttpClientFactoryTest.java

示例9: testAuthorixedProxyRequest

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void testAuthorixedProxyRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).withHeader("Proxy-Authorization", matching("Basic Zm9vOmJhcg=="))
            .willReturn(aResponse().withBody("Hello Proxy!"))
            .atPriority(1));
    proxyServer.stubFor(any(urlMatching(".*"))
            .willReturn(aResponse().withStatus(407).withHeader("Proxy-Authenticate", "Basic"))
            .atPriority(2));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");
    proxy.setUsername("foo");
    proxy.setPassword("bar");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello Proxy!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:24,代码来源:HttpClientFactoryTest.java

示例10: testNonProxiedHostRequest

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Test
public void testNonProxiedHostRequest() throws Exception {
    targetServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello World!")));

    proxyServer.stubFor(get(urlMatching(".*")).willReturn(aResponse().withBody("Hello Proxy!")));

    Proxy proxy = new Proxy();
    proxy.setHost("localhost");
    proxy.setPort(PROXY_PORT);
    proxy.setProtocol("http");
    proxy.setNonProxyHosts("localhost|example.com");

    HttpClient client = new HttpClientFactory(TARGET_URL).proxy(proxy).create();
    String body = EntityUtils.toString(client.execute(new HttpGet(TARGET_URL)).getEntity());

    Assert.assertEquals("Hello World!", body);
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:18,代码来源:HttpClientFactoryTest.java

示例11: addProxy

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
public MavenExecutionRequest addProxy( Proxy proxy )
{
    if ( proxy == null )
    {
        throw new IllegalArgumentException( "proxy missing" );
    }

    for ( Proxy p : getProxies() )
    {
        if ( p.getId() != null && p.getId().equals( proxy.getId() ) )
        {
            return this;
        }
    }

    getProxies().add( proxy );

    return this;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:DefaultMavenExecutionRequest.java

示例12: configureProxyToInlineRepo

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
private org.apache.maven.repository.Proxy configureProxyToInlineRepo() {
    if (mavenSession != null && mavenSession.getSettings() != null) {
        Proxy proxy = mavenSession.getSettings().getActiveProxy();
        org.apache.maven.repository.Proxy mavenProxy = new org.apache.maven.repository.Proxy();
        if (proxy != null) {
            mavenProxy.setProtocol(proxy.getProtocol());
            mavenProxy.setHost(proxy.getHost());
            mavenProxy.setPort(proxy.getPort());
            mavenProxy.setNonProxyHosts(proxy.getNonProxyHosts());
            mavenProxy.setUserName(proxy.getUsername());
            mavenProxy.setPassword(proxy.getPassword());
            return mavenProxy;
        } else {
            return null;
        }
        
    } else {
        return null;
    }
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:21,代码来源:MojoSupport.java

示例13: getProxyConfig

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
public static ProxyConfig getProxyConfig(MavenSession mavenSession, SettingsDecrypter decrypter) {
    if (mavenSession == null ||
            mavenSession.getSettings() == null ||
            mavenSession.getSettings().getProxies() == null ||
            mavenSession.getSettings().getProxies().isEmpty()) {
        return new ProxyConfig(Collections.<ProxyConfig.Proxy>emptyList());
    } else {
        final List<Proxy> mavenProxies = mavenSession.getSettings().getProxies();

        final List<ProxyConfig.Proxy> proxies = new ArrayList<>(mavenProxies.size());

        for (Proxy mavenProxy : mavenProxies) {
            if (mavenProxy.isActive()) {
                mavenProxy = decryptProxy(mavenProxy, decrypter);
                proxies.add(new ProxyConfig.Proxy(mavenProxy.getId(), mavenProxy.getProtocol(), mavenProxy.getHost(),
                        mavenProxy.getPort(), mavenProxy.getUsername(), mavenProxy.getPassword(), mavenProxy.getNonProxyHosts()));
            }
        }

        return new ProxyConfig(proxies);
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:23,代码来源:MojoUtils.java

示例14: setProxy

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
/**
 * @param proxy
 */
public void setProxy(Proxy proxy) {
    if (this.proxy != proxy) {
        this.proxy = proxy;
        if (httpClient != null) {
            applyProxy();
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:12,代码来源:DeploymentManager.java

示例15: extractProxySettings

import org.apache.maven.settings.Proxy; //导入依赖的package包/类
@Nullable
private ProxySettings extractProxySettings() {
  final ProxySettings result;
  if (this.isUseMavenProxy()) {
    final Proxy activeMavenProxy = this.settings == null ? null : this.settings.getActiveProxy();
    result = activeMavenProxy == null ? null : new ProxySettings(activeMavenProxy);
    getLog().debug("Detected maven proxy : " + result);
  } else {
    result = this.proxy;
    if (result != null) {
      getLog().debug("Defined proxy : " + result);
    }
  }
  return result;
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:16,代码来源:AbstractGolangMojo.java


注:本文中的org.apache.maven.settings.Proxy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。