MCPcopy Create free account
hub / github.com/apache/tomcat / testEncode

Method testEncode

test/org/apache/coyote/http2/TestHpack.java:28–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26public class TestHpack {
27
28 @Test
29 public void testEncode() throws Exception {
30 MimeHeaders headers = new MimeHeaders();
31 headers.setValue("header1").setString("value1");
32 headers.setValue(":status").setString("200");
33 headers.setValue("header2").setString("value2");
34 ByteBuffer output = ByteBuffer.allocate(512);
35 HpackEncoder encoder = new HpackEncoder();
36 encoder.encode(headers, output);
37 output.flip();
38 // Size is supposed to be 33 without huffman, or 27 with it
39 // TODO: use the HpackHeaderFunction to enable huffman predictably
40 Assert.assertEquals(27, output.remaining());
41 output.clear();
42 encoder.encode(headers, output);
43 output.flip();
44 // Size is now 3 after using the table
45 Assert.assertEquals(3, output.remaining());
46 }
47
48 @Test
49 public void testDecode() throws Exception {

Callers

nothing calls this directly

Calls 7

setValueMethod · 0.95
encodeMethod · 0.95
remainingMethod · 0.95
flipMethod · 0.80
allocateMethod · 0.65
clearMethod · 0.65
setStringMethod · 0.45

Tested by

no test coverage detected