ApplicationProtocolNegotiationHandlerTest Class — netty Architecture
Architecture documentation for the ApplicationProtocolNegotiationHandlerTest class in ApplicationProtocolNegotiationHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6a59c536_b4df_055a_02c9_49ed1745fd53["ApplicationProtocolNegotiationHandlerTest"] 380fbc15_456f_abcd_175f_4ad5c20d26c3["ApplicationProtocolNegotiationHandlerTest.java"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|defined in| 380fbc15_456f_abcd_175f_4ad5c20d26c3 d5d49c51_ba7f_2e7b_9b8c_55c245131153["testRemoveItselfIfNoSslHandlerPresent()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| d5d49c51_ba7f_2e7b_9b8c_55c245131153 f20e5859_2022_cf45_4dd4_e07b2a21202f["testHandshakeFailure()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| f20e5859_2022_cf45_4dd4_e07b2a21202f 85025863_6068_fc53_cdb6_4b7cbb569925["testHandshakeSuccess()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| 85025863_6068_fc53_cdb6_4b7cbb569925 2f68ab88_f51a_2a42_93b5_8b3c8210f66c["testHandshakeSuccessWithSslHandlerAddedLater()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| 2f68ab88_f51a_2a42_93b5_8b3c8210f66c 50b8bb54_1471_d7ba_771d_3f6a997c9300["testHandshakeSuccess0()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| 50b8bb54_1471_d7ba_771d_3f6a997c9300 d3fa6e91_8963_a1ba_a79e_b4f4011c415a["testHandshakeSuccessButNoSslHandler()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| d3fa6e91_8963_a1ba_a79e_b4f4011c415a 527ca451_4662_6bf8_0258_0742c915de11["testBufferMessagesUntilHandshakeComplete()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| 527ca451_4662_6bf8_0258_0742c915de11 6069e8df_c20f_6bc4_8dff_2c5475ae35a8["testBufferMessagesUntilHandshakeCompleteWithClose()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| 6069e8df_c20f_6bc4_8dff_2c5475ae35a8 d94011aa_bebd_02c3_8561_08309fd1189d["testBufferMessagesUntilHandshakeCompleteWithInputShutdown()"] 6a59c536_b4df_055a_02c9_49ed1745fd53 -->|method| d94011aa_bebd_02c3_8561_08309fd1189d
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandlerTest.java lines 44–232
public class ApplicationProtocolNegotiationHandlerTest {
@Test
public void testRemoveItselfIfNoSslHandlerPresent() throws NoSuchAlgorithmException {
ChannelHandler alpnHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_1_1) {
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
fail();
}
};
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
// This test is mocked/simulated and doesn't go through full TLS handshake. Currently only JDK SSLEngineImpl
// client mode will generate a close_notify.
engine.setUseClientMode(true);
EmbeddedChannel channel = new EmbeddedChannel(alpnHandler);
String msg = "msg";
String msg2 = "msg2";
assertTrue(channel.writeInbound(msg));
assertTrue(channel.writeInbound(msg2));
assertNull(channel.pipeline().context(alpnHandler));
assertEquals(msg, channel.readInbound());
assertEquals(msg2, channel.readInbound());
assertFalse(channel.finishAndReleaseAll());
}
@Test
public void testHandshakeFailure() {
ChannelHandler alpnHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_1_1) {
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
fail();
}
};
EmbeddedChannel channel = new EmbeddedChannel(alpnHandler);
SSLHandshakeException exception = new SSLHandshakeException("error");
SslHandshakeCompletionEvent completionEvent = new SslHandshakeCompletionEvent(exception);
channel.pipeline().fireUserEventTriggered(completionEvent);
channel.pipeline().fireExceptionCaught(new DecoderException(exception));
assertNull(channel.pipeline().context(alpnHandler));
assertFalse(channel.finishAndReleaseAll());
}
@Test
public void testHandshakeSuccess() throws NoSuchAlgorithmException {
testHandshakeSuccess0(false);
}
@Test
public void testHandshakeSuccessWithSslHandlerAddedLater() throws NoSuchAlgorithmException {
testHandshakeSuccess0(true);
}
private static void testHandshakeSuccess0(boolean addLater) throws NoSuchAlgorithmException {
final AtomicBoolean configureCalled = new AtomicBoolean(false);
ChannelHandler alpnHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_1_1) {
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
configureCalled.set(true);
assertEquals(ApplicationProtocolNames.HTTP_1_1, protocol);
}
};
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
// This test is mocked/simulated and doesn't go through full TLS handshake. Currently only JDK SSLEngineImpl
// client mode will generate a close_notify.
engine.setUseClientMode(true);
EmbeddedChannel channel = new EmbeddedChannel();
if (addLater) {
channel.pipeline().addLast(alpnHandler);
channel.pipeline().addFirst(new SslHandler(engine));
} else {
channel.pipeline().addLast(new SslHandler(engine));
channel.pipeline().addLast(alpnHandler);
}
channel.pipeline().fireUserEventTriggered(SslHandshakeCompletionEvent.SUCCESS);
Defined In
Source
Frequently Asked Questions
What is the ApplicationProtocolNegotiationHandlerTest class?
ApplicationProtocolNegotiationHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandlerTest.java.
Where is ApplicationProtocolNegotiationHandlerTest defined?
ApplicationProtocolNegotiationHandlerTest is defined in handler/src/test/java/io/netty/handler/ssl/ApplicationProtocolNegotiationHandlerTest.java at line 44.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free