Search in sources :

Example 1 with CronetTransportFactory

use of io.grpc.cronet.CronetChannelBuilder.CronetTransportFactory in project grpc-java by grpc.

the class CronetChannelBuilderTest method alwaysUsePut_defaultsToFalse.

@Test
public void alwaysUsePut_defaultsToFalse() throws Exception {
    CronetChannelBuilder builder = CronetChannelBuilder.forAddress("address", 1234, mockEngine);
    CronetTransportFactory transportFactory = (CronetTransportFactory) builder.buildTransportFactory();
    CronetClientTransport transport = (CronetClientTransport) transportFactory.newClientTransport(new InetSocketAddress("localhost", 443), new ClientTransportOptions(), channelLogger);
    CronetClientStream stream = transport.newStream(method, new Metadata(), CallOptions.DEFAULT, tracers);
    assertFalse(stream.idempotent);
}
Also used : ClientTransportOptions(io.grpc.internal.ClientTransportFactory.ClientTransportOptions) InetSocketAddress(java.net.InetSocketAddress) Metadata(io.grpc.Metadata) CronetTransportFactory(io.grpc.cronet.CronetChannelBuilder.CronetTransportFactory) Test(org.junit.Test)

Example 2 with CronetTransportFactory

use of io.grpc.cronet.CronetChannelBuilder.CronetTransportFactory in project grpc-java by grpc.

the class CronetChannelBuilderTest method alwaysUsePutTrue_cronetStreamIsIdempotent.

@Test
public void alwaysUsePutTrue_cronetStreamIsIdempotent() throws Exception {
    CronetChannelBuilder builder = CronetChannelBuilder.forAddress("address", 1234, mockEngine).alwaysUsePut(true);
    CronetTransportFactory transportFactory = (CronetTransportFactory) builder.buildTransportFactory();
    CronetClientTransport transport = (CronetClientTransport) transportFactory.newClientTransport(new InetSocketAddress("localhost", 443), new ClientTransportOptions(), channelLogger);
    CronetClientStream stream = transport.newStream(method, new Metadata(), CallOptions.DEFAULT, tracers);
    assertTrue(stream.idempotent);
}
Also used : ClientTransportOptions(io.grpc.internal.ClientTransportFactory.ClientTransportOptions) InetSocketAddress(java.net.InetSocketAddress) Metadata(io.grpc.Metadata) CronetTransportFactory(io.grpc.cronet.CronetChannelBuilder.CronetTransportFactory) Test(org.junit.Test)

Aggregations

Metadata (io.grpc.Metadata)2 CronetTransportFactory (io.grpc.cronet.CronetChannelBuilder.CronetTransportFactory)2 ClientTransportOptions (io.grpc.internal.ClientTransportFactory.ClientTransportOptions)2 InetSocketAddress (java.net.InetSocketAddress)2 Test (org.junit.Test)2