Search in sources :

Example 21 with Route

use of com.google.cloud.compute.v1.Route in project okhttp-digest by rburgst.

the class AuthenticationCacheInterceptorTest 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);
}
Also used : Address(okhttp3.Address) InetSocketAddress(java.net.InetSocketAddress) InetSocketAddress(java.net.InetSocketAddress) Route(okhttp3.Route) Before(org.junit.Before)

Example 22 with Route

use of com.google.cloud.compute.v1.Route 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);
}
Also used : Address(okhttp3.Address) InetSocketAddress(java.net.InetSocketAddress) InetSocketAddress(java.net.InetSocketAddress) Route(okhttp3.Route) Before(org.junit.Before)

Example 23 with Route

use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.

the class ClientAttributePrependHandlerTest method testPreprendClientAttribute.

@Test
public void testPreprendClientAttribute() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("client-attribute-append-test")).findFirst().get();
    final Attributes att = new AttributesBuilder().setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(IPV4).build()).build()).build();
    final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(att);
    doReturn(Collections.emptyList()).when(this.exportParameters).getClientRouteTargetContrainCache();
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertEquals(att, result.getAttributes());
    final Attributes expected = new AttributesBuilder().setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("2.2.2.2")).build()).build()).build();
    final String rk = "testRoute";
    final Route rtRoute = new RouteTargetConstrainRouteBuilder().setRouteKey(rk).setPathId(new PathId(Uint32.ZERO)).setAttributes(expected).build();
    doReturn(Collections.singletonList(rtRoute)).when(this.exportParameters).getClientRouteTargetContrainCache();
    doReturn(rk).when(this.exportParameters).getRouteKey();
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, IPV4UNICAST.class, this.exportParameters, attributeContainer, statement);
    assertEquals(expected, result.getAttributes());
}
Also used : PathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) RouteEntryBaseAttributes(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes) RouteTargetConstrainRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.routes.route.target.constrain.routes.RouteTargetConstrainRouteBuilder) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) Test(org.junit.Test) AbstractStatementRegistryTest(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.AbstractStatementRegistryTest)

Example 24 with Route

use of com.google.cloud.compute.v1.Route in project java-docs-samples by GoogleCloudPlatform.

the class CreateRouteToWindowsActivationHost method createRouteToWindowsActivationHost.

// Creates a new route to kms.windows.googlecloud.com (35.190.247.13) for Windows activation.
public static void createRouteToWindowsActivationHost(String projectId, String routeName, String networkName) throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Instantiates a client.
    try (RoutesClient routesClient = RoutesClient.create()) {
        // If you have Windows instances without external IP addresses,
        // you must also enable Private Google Access so that instances
        // with only internal IP addresses can send traffic to the external
        // IP address for kms.windows.googlecloud.com.
        // More information: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling
        Route route = Route.newBuilder().setName(routeName).setDestRange("35.190.247.13/32").setNetwork(networkName).setNextHopGateway(String.format("projects/%s/global/gateways/default-internet-gateway", projectId)).build();
        InsertRouteRequest request = InsertRouteRequest.newBuilder().setProject(projectId).setRouteResource(route).build();
        // Wait for the operation to complete.
        Operation operation = routesClient.insertAsync(request).get(3, TimeUnit.MINUTES);
        if (operation.hasError()) {
            System.out.printf("Error in creating route %s", operation.getError());
            return;
        }
        System.out.printf("Route created %s", routeName);
    }
}
Also used : RoutesClient(com.google.cloud.compute.v1.RoutesClient) Operation(com.google.cloud.compute.v1.Operation) InsertRouteRequest(com.google.cloud.compute.v1.InsertRouteRequest) Route(com.google.cloud.compute.v1.Route)

Example 25 with Route

use of com.google.cloud.compute.v1.Route in project okhttp by square.

the class RouteSelectorTest method routeToString.

@Test
public void routeToString() throws Exception {
    Route route = new Route(httpAddress(), Proxy.NO_PROXY, InetSocketAddress.createUnresolved("host", 1234));
    assertEquals("Route{host:1234}", route.toString());
}
Also used : Route(okhttp3.Route) Test(org.junit.Test)

Aggregations

Route (okhttp3.Route)30 Response (okhttp3.Response)16 Authenticator (okhttp3.Authenticator)14 Request (okhttp3.Request)12 IOException (java.io.IOException)10 OkHttpClient (okhttp3.OkHttpClient)10 InetSocketAddress (java.net.InetSocketAddress)9 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)9 Proxy (java.net.Proxy)7 Route (io.fabric8.knative.serving.v1.Route)6 RouteBuilder (io.fabric8.knative.serving.v1.RouteBuilder)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 Address (okhttp3.Address)5 Connection (okhttp3.Connection)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)5 Builder (okhttp3.OkHttpClient.Builder)4