HttpPostRequestEncoderTest Class — netty Architecture
Architecture documentation for the HttpPostRequestEncoderTest class in HttpPostRequestEncoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3af766b2_b7f3_8257_aeb8_621a4404fee6["HttpPostRequestEncoderTest"] 08306111_b156_e4bc_bff9_de3836ed7650["HttpPostRequestEncoderTest.java"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|defined in| 08306111_b156_e4bc_bff9_de3836ed7650 7239bc5f_2050_7a39_2ab6_ce37c9eeeeaf["testAllowedMethods()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 7239bc5f_2050_7a39_2ab6_ce37c9eeeeaf 021481da_de80_d081_59fd_8f6466f077e6["shouldThrowExceptionIfNotAllowed()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 021481da_de80_d081_59fd_8f6466f077e6 98d8d54d_9a56_4cef_ce6a_ad947ea68d1b["testSingleFileUploadNoName()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 98d8d54d_9a56_4cef_ce6a_ad947ea68d1b c34d5d97_a98a_2aa5_4468_8b077e1ea449["testMultiFileUploadInMixedMode()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| c34d5d97_a98a_2aa5_4468_8b077e1ea449 6a61d4d1_c39d_1068_6161_f5ae99870b11["testMultiFileUploadInMixedModeNoName()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 6a61d4d1_c39d_1068_6161_f5ae99870b11 7a383c8c_19ba_7087_ffbb_a498dda7f049["testSingleFileUploadInHtml5Mode()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 7a383c8c_19ba_7087_ffbb_a498dda7f049 9dfba346_38d1_e76f_85f2_a4c34d71463f["testMultiFileUploadInHtml5Mode()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 9dfba346_38d1_e76f_85f2_a4c34d71463f 415162c1_ebed_04b9_6c61_29f80f31b452["testHttpPostRequestEncoderSlicedBuffer()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 415162c1_ebed_04b9_6c61_29f80f31b452 d7054625_795e_5277_1f1f_37aeb40c353b["String()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| d7054625_795e_5277_1f1f_37aeb40c353b 9c359b03_dabb_195b_45b2_92eccc38c9f3["testDataIsMultipleOfChunkSize1()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 9c359b03_dabb_195b_45b2_92eccc38c9f3 020cddf3_6b0f_3623_d672_8145b7c602e7["testDataIsMultipleOfChunkSize2()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 020cddf3_6b0f_3623_d672_8145b7c602e7 55e10c37_aec7_562d_09fa_ae4d81f1652e["checkNextChunkSize()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| 55e10c37_aec7_562d_09fa_ae4d81f1652e ba8c3c6a_d1af_e6e0_fbca_1be0dd04d6b4["testEncodeChunkedContent()"] 3af766b2_b7f3_8257_aeb8_621a4404fee6 -->|method| ba8c3c6a_d1af_e6e0_fbca_1be0dd04d6b4
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoderTest.java lines 57–522
public class HttpPostRequestEncoderTest {
@Test
public void testAllowedMethods() throws Exception {
shouldThrowExceptionIfNotAllowed(HttpMethod.CONNECT);
shouldThrowExceptionIfNotAllowed(HttpMethod.PUT);
shouldThrowExceptionIfNotAllowed(HttpMethod.POST);
shouldThrowExceptionIfNotAllowed(HttpMethod.PATCH);
shouldThrowExceptionIfNotAllowed(HttpMethod.DELETE);
shouldThrowExceptionIfNotAllowed(HttpMethod.GET);
shouldThrowExceptionIfNotAllowed(HttpMethod.HEAD);
shouldThrowExceptionIfNotAllowed(HttpMethod.OPTIONS);
try {
shouldThrowExceptionIfNotAllowed(HttpMethod.TRACE);
fail("Should raised an exception with TRACE method");
} catch (ErrorDataEncoderException e) {
// Exception is willing
}
}
private void shouldThrowExceptionIfNotAllowed(HttpMethod method) throws Exception {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
method, "http://localhost");
HttpPostRequestEncoder encoder = new HttpPostRequestEncoder(request, true);
File file1 = new File(getClass().getResource("/file-01.txt").toURI());
encoder.addBodyAttribute("foo", "bar");
encoder.addBodyFileUpload("quux", file1, "text/plain", false);
String multipartDataBoundary = encoder.multipartDataBoundary;
String content = getRequestBody(encoder);
String expected = "--" + multipartDataBoundary + "\r\n" +
CONTENT_DISPOSITION + ": form-data; name=\"foo\"" + "\r\n" +
CONTENT_LENGTH + ": 3" + "\r\n" +
CONTENT_TYPE + ": text/plain; charset=UTF-8" + "\r\n" +
"\r\n" +
"bar" +
"\r\n" +
"--" + multipartDataBoundary + "\r\n" +
CONTENT_DISPOSITION + ": form-data; name=\"quux\"; filename=\"file-01.txt\"" + "\r\n" +
CONTENT_LENGTH + ": " + file1.length() + "\r\n" +
CONTENT_TYPE + ": text/plain" + "\r\n" +
CONTENT_TRANSFER_ENCODING + ": binary" + "\r\n" +
"\r\n" +
"File 01" + StringUtil.NEWLINE +
"\r\n" +
"--" + multipartDataBoundary + "--" + "\r\n";
assertEquals(expected, content);
}
@Test
public void testSingleFileUploadNoName() throws Exception {
DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.POST, "http://localhost");
HttpPostRequestEncoder encoder = new HttpPostRequestEncoder(request, true);
File file1 = new File(getClass().getResource("/file-01.txt").toURI());
encoder.addBodyAttribute("foo", "bar");
encoder.addBodyFileUpload("quux", "", file1, "text/plain", false);
String multipartDataBoundary = encoder.multipartDataBoundary;
String content = getRequestBody(encoder);
String expected = "--" + multipartDataBoundary + "\r\n" +
CONTENT_DISPOSITION + ": form-data; name=\"foo\"" + "\r\n" +
CONTENT_LENGTH + ": 3" + "\r\n" +
CONTENT_TYPE + ": text/plain; charset=UTF-8" + "\r\n" +
"\r\n" +
"bar" +
"\r\n" +
"--" + multipartDataBoundary + "\r\n" +
CONTENT_DISPOSITION + ": form-data; name=\"quux\"\r\n" +
CONTENT_LENGTH + ": " + file1.length() + "\r\n" +
CONTENT_TYPE + ": text/plain" + "\r\n" +
CONTENT_TRANSFER_ENCODING + ": binary" + "\r\n" +
"\r\n" +
"File 01" + StringUtil.NEWLINE +
"\r\n" +
"--" + multipartDataBoundary + "--" + "\r\n";
Defined In
Source
Frequently Asked Questions
What is the HttpPostRequestEncoderTest class?
HttpPostRequestEncoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoderTest.java.
Where is HttpPostRequestEncoderTest defined?
HttpPostRequestEncoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoderTest.java at line 57.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free