1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.core5.http2.hpack;
29
30 import org.junit.jupiter.api.Assertions;
31 import org.junit.jupiter.api.Test;
32
33 public class TestInboundDynamicTable {
34
35 @Test
36 public void testBasics() throws Exception {
37
38 final InboundDynamicTable table = new InboundDynamicTable();
39 Assertions.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
40 Assertions.assertEquals(0, table.getCurrentSize());
41
42 final HPackHeader header1 = new HPackHeader("h", "1");
43 table.add(header1);
44 Assertions.assertEquals(1, table.dynamicLength());
45 Assertions.assertEquals(61, table.staticLength());
46 Assertions.assertEquals(62, table.length());
47 Assertions.assertSame(header1, table.getHeader(62));
48 Assertions.assertEquals(34, table.getCurrentSize());
49 }
50
51 @Test
52 public void testEviction() throws Exception {
53
54 final InboundDynamicTable table = new InboundDynamicTable();
55
56 table.add(new HPackHeader("h", "1"));
57 table.add(new HPackHeader("h", "2"));
58
59 Assertions.assertEquals(68, table.getCurrentSize());
60
61 table.setMaxSize(256);
62 Assertions.assertEquals(68, table.getCurrentSize());
63 table.setMaxSize(67);
64 Assertions.assertEquals(34, table.getCurrentSize());
65 table.setMaxSize(10);
66 Assertions.assertEquals(0, table.getCurrentSize());
67 }
68
69 }
70