Search in sources :

Example 1 with ChannelBuilderDefaultPortProvider

use of io.grpc.internal.ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider in project grpc-java by grpc.

the class ManagedChannelImplBuilderTest method getDefaultPort_custom.

/**
 * Ensure getDefaultPort() delegates to the custom implementation.
 */
@Test
public void getDefaultPort_custom() {
    int customPort = 43;
    ChannelBuilderDefaultPortProvider mockChannelBuilderDefaultPortProvider = mock(ChannelBuilderDefaultPortProvider.class);
    when(mockChannelBuilderDefaultPortProvider.getDefaultPort()).thenReturn(customPort);
    builder = new ManagedChannelImplBuilder(DUMMY_TARGET, new UnsupportedClientTransportFactoryBuilder(), mockChannelBuilderDefaultPortProvider);
    assertEquals(customPort, builder.getDefaultPort());
    verify(mockChannelBuilderDefaultPortProvider).getDefaultPort();
}
Also used : UnsupportedClientTransportFactoryBuilder(io.grpc.internal.ManagedChannelImplBuilder.UnsupportedClientTransportFactoryBuilder) ChannelBuilderDefaultPortProvider(io.grpc.internal.ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider) Test(org.junit.Test)

Aggregations

ChannelBuilderDefaultPortProvider (io.grpc.internal.ManagedChannelImplBuilder.ChannelBuilderDefaultPortProvider)1 UnsupportedClientTransportFactoryBuilder (io.grpc.internal.ManagedChannelImplBuilder.UnsupportedClientTransportFactoryBuilder)1 Test (org.junit.Test)1