use of org.orcid.jaxb.model.record_rc4.Address in project okhttp-digest by rburgst.
the class DispatchingAuthenticatorTest method beforeMethod.
@Before
public void beforeMethod() {
MockitoAnnotations.initMocks(this);
// setup some dummy data so that we dont get NPEs
Address address = new Address("localhost", 8080, mockDns, socketFactory, null, null, null, proxyAuthenticator, null, Collections.singletonList(Protocol.HTTP_1_1), Collections.singletonList(ConnectionSpec.MODERN_TLS), proxySelector);
InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 8080);
mockRoute = new Route(address, proxy, inetSocketAddress);
given(mockConnection.route()).willReturn(mockRoute);
}
use of org.orcid.jaxb.model.record_rc4.Address in project grpc-java by grpc.
the class ChannelzProtoUtil method toAddress.
static Address toAddress(SocketAddress address) {
Preconditions.checkNotNull(address);
Address.Builder builder = Address.newBuilder();
if (address instanceof InetSocketAddress) {
InetSocketAddress inetAddress = (InetSocketAddress) address;
builder.setTcpipAddress(TcpIpAddress.newBuilder().setIpAddress(ByteString.copyFrom(inetAddress.getAddress().getAddress())).setPort(inetAddress.getPort()).build());
} else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) {
builder.setUdsAddress(UdsAddress.newBuilder().setFilename(// DomainSocketAddress.toString returns filename
address.toString()).build());
} else {
builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build());
}
return builder.build();
}
use of org.orcid.jaxb.model.record_rc4.Address in project okhttp by square.
the class RouteSelectorTest method singleRoute.
@Test
public void singleRoute() throws Exception {
Address address = httpAddress();
RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
assertTrue(routeSelector.hasNext());
dns.set(uriHost, dns.allocate(1));
assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
try {
routeSelector.next();
fail();
} catch (NoSuchElementException expected) {
}
}
use of org.orcid.jaxb.model.record_rc4.Address in project okhttp by square.
the class RouteSelectorTest method proxySelectorReturnsNull.
@Test
public void proxySelectorReturnsNull() throws Exception {
ProxySelector nullProxySelector = new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
assertEquals(uriHost, uri.getHost());
return null;
}
@Override
public void connectFailed(URI uri, SocketAddress socketAddress, IOException e) {
throw new AssertionError();
}
};
Address address = new Address(uriHost, uriPort, dns, socketFactory, null, null, null, authenticator, null, protocols, connectionSpecs, nullProxySelector);
RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
assertTrue(routeSelector.hasNext());
dns.set(uriHost, dns.allocate(1));
assertRoute(routeSelector.next(), address, NO_PROXY, dns.lookup(uriHost, 0), uriPort);
dns.assertRequests(uriHost);
assertFalse(routeSelector.hasNext());
}
use of org.orcid.jaxb.model.record_rc4.Address in project okhttp by square.
the class RouteSelectorTest method multipleProxiesMultipleInetAddressesMultipleConfigurations.
@Test
public void multipleProxiesMultipleInetAddressesMultipleConfigurations() throws Exception {
Address address = httpsAddress();
proxySelector.proxies.add(proxyA);
proxySelector.proxies.add(proxyB);
RouteSelector routeSelector = new RouteSelector(address, routeDatabase);
// Proxy A
dns.set(proxyAHost, dns.allocate(2));
assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 0), proxyAPort);
dns.assertRequests(proxyAHost);
assertRoute(routeSelector.next(), address, proxyA, dns.lookup(proxyAHost, 1), proxyAPort);
// Proxy B
dns.set(proxyBHost, dns.allocate(2));
assertRoute(routeSelector.next(), address, proxyB, dns.lookup(proxyBHost, 0), proxyBPort);
dns.assertRequests(proxyBHost);
assertRoute(routeSelector.next(), address, proxyB, dns.lookup(proxyBHost, 1), proxyBPort);
// No more proxies to attempt.
assertFalse(routeSelector.hasNext());
}
Aggregations