val traceHandler = tracing.newClientHandler(); Pipelines.addHandler(channel.pipeline(), "distributed tracing", traceHandler);
@Test public void testDisableSsl() { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.basicClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have enabled Tracing the tracing returns a non-null newClientHandler when(tracing.newClientHandler()).thenReturn(tracingHandler); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(SslHandler.class); assertNull(result); }
@Test public void testEnableSsl() { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.sslClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have enabled Tracing the tracing returns a non-null newClientHandler when(tracing.newClientHandler()).thenReturn(tracingHandler); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(SslHandler.class); assertNotNull(result); }
@Test public void testDisableIdleTimeout() { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.idleDisabledClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have enabled Tracing the tracing returns a non-null newClientHandler when(tracing.newClientHandler()).thenReturn(tracingHandler); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(XioIdleDisconnectHandler.class); assertNull(result); }
@Test public void testDisabledTracing() { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.basicClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have disabled Tracing the tracing returns null for newClientHandler when(tracing.newClientHandler()).thenReturn(null); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(HttpClientTracingHandler.class); assertEquals(result, null); }
@Test public void testEnabledTracing() throws Exception { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.basicClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have enabled Tracing the tracing returns a non-null newClientHandler when(tracing.newClientHandler()).thenReturn(tracingHandler); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(HttpClientTracingHandler.class); assertEquals(result, tracingHandler); }
@Test public void testEnableIdleTimeout() { val channelConfig = ChannelConfiguration.clientConfig(1, "worker"); val clientConfig = ClientConfig.from(ConfigFactory.load().getConfig("xio.idleEnabledClient")); val clientState = new ClientState(channelConfig, clientConfig); // when we have enabled Tracing the tracing returns a non-null newClientHandler when(tracing.newClientHandler()).thenReturn(tracingHandler); subject = new ClientChannelInitializer(clientState, () -> appHandler, tracing); // Assert that we did not add a HttpClientTracingHandler to the pipeline val testChannel = new EmbeddedChannel(subject); val result = testChannel.pipeline().get(XioIdleDisconnectHandler.class); assertNotNull(result); } }
@Test public void testValidParametersConfig() { // This when the zipkinurl is non-empty AND the sampling rate is > 0.0f subject = new XioTracing(validParametersConfig); assertNotNull(subject.newClientHandler()); assertNotNull(subject.newServerHandler()); }
@Test public void testInvalidParametersConfig() { // This when the zipkinurl is empty OR the sampling rate is <= 0.0f subject = new XioTracing(invalidParametersConfig); assertNull(subject.newClientHandler()); assertNull(subject.newServerHandler()); } }