@Test
public void testFcmClientWithProxySettings() throws Exception {
// Create Settings:
IFcmClientSettings settings = new FakeFcmClientSettings();
// Define the Credentials to be used:
BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider();
// Set the Credentials (any auth scope used):
basicCredentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("your_username", "your_password"));
// Create the Apache HttpClientBuilder:
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
// Set the Proxy Address:
.setProxy(new HttpHost("your_hostname", 1234))
// Set the Authentication Strategy:
.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy())
// Set the Credentials Provider we built above:
.setDefaultCredentialsProvider(basicCredentialsProvider);
// Create the DefaultHttpClient:
DefaultHttpClient httpClient = new DefaultHttpClient(settings, httpClientBuilder);
// Finally build the FcmClient:
try(IFcmClient client = new FcmClient(settings, httpClient)) {
// TODO Work with the Proxy ...
}
}
HttpBuilderConfigurationTest.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:FcmJava
作者:
评论列表
文章目录