Source:
<code>public void testConnectionWithCustomKeyManager() throws Exception { TestProviderCreator testProviderCreator = new TestProviderCreator(); int requestSize = 100 * 1024; final String node = "0"; String request = TestUtils.randomString(requestSize); Map<String, Object> sslServerConfigs = TestSslUtils.createSslConfig( TestKeyManagerFactory.ALGORITHM, TestTrustManagerFactory.ALGORITHM ); sslServerConfigs.put(SecurityConfig.SECURITY_PROVIDERS_CONFIG, testProviderCreator.getClass().getName()); EchoServer server = new EchoServer(SecurityProtocol.SSL, sslServerConfigs); server.start(); Time time = new MockTime(); File trustStoreFile = new File(TestKeyManagerFactory.TestKeyManager.mockTrustStoreFile); Map<String, Object> sslClientConfigs = TestSslUtils.createSslConfig(true, true, Mode.CLIENT, trustStoreFile, "client"); ChannelBuilder channelBuilder = new TestSslChannelBuilder(Mode.CLIENT); channelBuilder.configure(sslClientConfigs); Metrics metrics = new Metrics(); Selector selector = new Selector(5000, metrics, time, "MetricGroup", channelBuilder, new LogContext()); selector.connect(node, new InetSocketAddress("localhost", server.port), BUFFER_SIZE, BUFFER_SIZE); while (!selector.connected().contains(node)) selector.poll(10000L); while (!selector.isChannelReady(node)) selector.poll(10000L); selector.send(createSend(node, request)); waitForBytesBuffered(selector, node); assertEquals(1, metrics.metrics().keySet().stream(). filter(n -> n.description().contains("The number of connections with this SSL cipher and protocol.")). <START> count()); <END> selector.close(node); super.verifySelectorEmpty(selector); assertEquals(0, metrics.metrics().keySet().stream(). filter(n -> n.description().contains("The number of connections with this SSL cipher and protocol.")). count()); Security.removeProvider(testProviderCreator.getProvider().getName()); selector.close(); server.close(); metrics.close(); }</code><technical_language>check of metric</technical_language>

Target:
public void testConnectionWithCustomKeyManager() throws Exception { TestProviderCreator testProviderCreator = new TestProviderCreator(); int requestSize = 100 * 1024; final String node = "0"; String request = TestUtils.randomString(requestSize); Map<String, Object> sslServerConfigs = TestSslUtils.createSslConfig( TestKeyManagerFactory.ALGORITHM, TestTrustManagerFactory.ALGORITHM ); sslServerConfigs.put(SecurityConfig.SECURITY_PROVIDERS_CONFIG, testProviderCreator.getClass().getName()); EchoServer server = new EchoServer(SecurityProtocol.SSL, sslServerConfigs); server.start(); Time time = new MockTime(); File trustStoreFile = new File(TestKeyManagerFactory.TestKeyManager.mockTrustStoreFile); Map<String, Object> sslClientConfigs = TestSslUtils.createSslConfig(true, true, Mode.CLIENT, trustStoreFile, "client"); ChannelBuilder channelBuilder = new TestSslChannelBuilder(Mode.CLIENT); channelBuilder.configure(sslClientConfigs); Metrics metrics = new Metrics(); Selector selector = new Selector(5000, metrics, time, "MetricGroup", channelBuilder, new LogContext()); selector.connect(node, new InetSocketAddress("localhost", server.port), BUFFER_SIZE, BUFFER_SIZE); while (!selector.connected().contains(node)) selector.poll(10000L); while (!selector.isChannelReady(node)) selector.poll(10000L); selector.send(createSend(node, request)); waitForBytesBuffered(selector, node); TestUtils.waitForCondition(() -> cipherMetrics(metrics).size() == 1, "Waiting for cipher metrics to be created."); assertEquals(Integer.valueOf(1), cipherMetrics(metrics).get(0).metricValue()); selector.close(node); super.verifySelectorEmpty(selector); assertEquals(1, cipherMetrics(metrics).size()); assertEquals(Integer.valueOf(0), cipherMetrics(metrics).get(0).metricValue()); Security.removeProvider(testProviderCreator.getProvider().getName()); selector.close(); server.close(); metrics.close(); }