SocksCmdResponseDecoderTest Class — netty Architecture
Architecture documentation for the SocksCmdResponseDecoderTest class in SocksCmdResponseDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 80478196_8fb3_b1cc_4870_95b1d8ba283f["SocksCmdResponseDecoderTest"] 8fa4e6fc_82f7_73d6_2ce5_200ef26ab706["SocksCmdResponseDecoderTest.java"] 80478196_8fb3_b1cc_4870_95b1d8ba283f -->|defined in| 8fa4e6fc_82f7_73d6_2ce5_200ef26ab706 6051f884_6db3_7437_203d_b70ab435c631["testSocksCmdResponseDecoderWithDifferentParams()"] 80478196_8fb3_b1cc_4870_95b1d8ba283f -->|method| 6051f884_6db3_7437_203d_b70ab435c631 fc227e70_91ae_26c1_e291_727b387fbce0["testSocksCmdResponseDecoder()"] 80478196_8fb3_b1cc_4870_95b1d8ba283f -->|method| fc227e70_91ae_26c1_e291_727b387fbce0 68e48971_e627_919b_e916_b6df4531b696["testInvalidAddress()"] 80478196_8fb3_b1cc_4870_95b1d8ba283f -->|method| 68e48971_e627_919b_e916_b6df4531b696 13ecdd1e_f646_fdd5_4ab4_6926b342eb88["testSocksCmdResponseDecoderIncludingHost()"] 80478196_8fb3_b1cc_4870_95b1d8ba283f -->|method| 13ecdd1e_f646_fdd5_4ab4_6926b342eb88
Relationship Graph
Source Code
codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java lines 29–94
public class SocksCmdResponseDecoderTest {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocksCmdResponseDecoderTest.class);
private static void testSocksCmdResponseDecoderWithDifferentParams(
SocksCmdStatus cmdStatus, SocksAddressType addressType, String host, int port) {
logger.debug("Testing cmdStatus: " + cmdStatus + " addressType: " + addressType);
SocksResponse msg = new SocksCmdResponse(cmdStatus, addressType, host, port);
SocksCmdResponseDecoder decoder = new SocksCmdResponseDecoder();
EmbeddedChannel embedder = new EmbeddedChannel(decoder);
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
if (addressType == SocksAddressType.UNKNOWN) {
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
} else {
msg = embedder.readInbound();
assertEquals(((SocksCmdResponse) msg).cmdStatus(), cmdStatus);
if (host != null) {
assertEquals(((SocksCmdResponse) msg).host(), host);
}
assertEquals(((SocksCmdResponse) msg).port(), port);
}
assertNull(embedder.readInbound());
}
/**
* Verifies that sent socks messages are decoded correctly.
*/
@Test
public void testSocksCmdResponseDecoder() {
for (SocksCmdStatus cmdStatus : SocksCmdStatus.values()) {
for (SocksAddressType addressType : SocksAddressType.values()) {
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, addressType, null, 0);
}
}
}
/**
* Verifies that invalid bound host will fail with IllegalArgumentException during encoding.
*/
@Test
public void testInvalidAddress() {
assertThrows(IllegalArgumentException.class, new Executable() {
@Override
public void execute() {
testSocksCmdResponseDecoderWithDifferentParams(
SocksCmdStatus.SUCCESS, SocksAddressType.IPv4, "1", 80);
}
});
}
/**
* Verifies that send socks messages are decoded correctly when bound host and port are set.
*/
@Test
public void testSocksCmdResponseDecoderIncludingHost() {
for (SocksCmdStatus cmdStatus : SocksCmdStatus.values()) {
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, SocksAddressType.IPv4,
"127.0.0.1", 80);
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, SocksAddressType.DOMAIN,
"testDomain.com", 80);
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, SocksAddressType.IPv6,
"2001:db8:85a3:42:1000:8a2e:370:7334", 80);
testSocksCmdResponseDecoderWithDifferentParams(cmdStatus, SocksAddressType.IPv6,
"1111:111:11:1:0:0:0:1", 80);
}
}
}
Source
Frequently Asked Questions
What is the SocksCmdResponseDecoderTest class?
SocksCmdResponseDecoderTest is a class in the netty codebase, defined in codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java.
Where is SocksCmdResponseDecoderTest defined?
SocksCmdResponseDecoderTest is defined in codec-socks/src/test/java/io/netty/handler/codec/socks/SocksCmdResponseDecoderTest.java at line 29.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free