| 26 | public 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 { |