OptionalSslHandlerTest Class — netty Architecture
Architecture documentation for the OptionalSslHandlerTest class in OptionalSslHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3376e436_30c5_3354_11dc_446e9998cd73["OptionalSslHandlerTest"] fe94ec23_b34e_a3a2_ce18_d675454d7e44["OptionalSslHandlerTest.java"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|defined in| fe94ec23_b34e_a3a2_ce18_d675454d7e44 54997b7b_967c_3247_8b30_8ec141bfa25e["setUp()"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|method| 54997b7b_967c_3247_8b30_8ec141bfa25e 554a1559_8766_0394_c351_713616165c69["handlerRemoved()"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|method| 554a1559_8766_0394_c351_713616165c69 484958e3_58bf_6606_6f89_b5a422bd50ad["handlerReplaced()"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|method| 484958e3_58bf_6606_6f89_b5a422bd50ad 2f29ebcc_6751_c0b1_26c1_b55ab552f9be["sslHandlerReplaced()"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|method| 2f29ebcc_6751_c0b1_26c1_b55ab552f9be b6b94c5e_6f82_1fd5_0978_b5fd9d369bc7["decodeBuffered()"] 3376e436_30c5_3354_11dc_446e9998cd73 -->|method| b6b94c5e_6f82_1fd5_0978_b5fd9d369bc7
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/OptionalSslHandlerTest.java lines 34–123
public class OptionalSslHandlerTest {
private static final String SSL_HANDLER_NAME = "sslhandler";
private static final String HANDLER_NAME = "handler";
@Mock
private ChannelHandlerContext context;
@Mock
private SslContext sslContext;
@Mock
private ChannelPipeline pipeline;
@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(context.pipeline()).thenReturn(pipeline);
}
@Test
public void handlerRemoved() throws Exception {
OptionalSslHandler handler = new OptionalSslHandler(sslContext);
final ByteBuf payload = Unpooled.copiedBuffer("plaintext".getBytes());
try {
handler.decode(context, payload, null);
verify(pipeline).remove(handler);
} finally {
payload.release();
}
}
@Test
public void handlerReplaced() throws Exception {
final ChannelHandler nonSslHandler = Mockito.mock(ChannelHandler.class);
OptionalSslHandler handler = new OptionalSslHandler(sslContext) {
@Override
protected ChannelHandler newNonSslHandler(ChannelHandlerContext context) {
return nonSslHandler;
}
@Override
protected String newNonSslHandlerName() {
return HANDLER_NAME;
}
};
final ByteBuf payload = Unpooled.copiedBuffer("plaintext".getBytes());
try {
handler.decode(context, payload, null);
verify(pipeline).replace(handler, HANDLER_NAME, nonSslHandler);
} finally {
payload.release();
}
}
@Test
public void sslHandlerReplaced() throws Exception {
final SslHandler sslHandler = Mockito.mock(SslHandler.class);
OptionalSslHandler handler = new OptionalSslHandler(sslContext) {
@Override
protected SslHandler newSslHandler(ChannelHandlerContext context, SslContext sslContext) {
return sslHandler;
}
@Override
protected String newSslHandlerName() {
return SSL_HANDLER_NAME;
}
};
final ByteBuf payload = Unpooled.wrappedBuffer(new byte[] { 22, 3, 1, 0, 5 });
try {
handler.decode(context, payload, null);
verify(pipeline).replace(handler, SSL_HANDLER_NAME, sslHandler);
} finally {
payload.release();
}
}
@Test
public void decodeBuffered() throws Exception {
OptionalSslHandler handler = new OptionalSslHandler(sslContext);
Source
Frequently Asked Questions
What is the OptionalSslHandlerTest class?
OptionalSslHandlerTest is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/OptionalSslHandlerTest.java.
Where is OptionalSslHandlerTest defined?
OptionalSslHandlerTest is defined in handler/src/test/java/io/netty/handler/ssl/OptionalSslHandlerTest.java at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free