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.Assert;
31 import org.junit.Test;
32
33 public class TestInboundDynamicTable {
34
35 @Test
36 public void testBasics() throws Exception {
37
38 final InboundDynamicTable table = new InboundDynamicTable();
39 Assert.assertEquals(Integer.MAX_VALUE, table.getMaxSize());
40 Assert.assertEquals(0, table.getCurrentSize());
41
42 final HPackHeader header1 = new HPackHeader("h", "1");
43 table.add(header1);
44 Assert.assertEquals(1, table.dynamicLength());
45 Assert.assertEquals(61, table.staticLength());
46 Assert.assertEquals(62, table.length());
47 Assert.assertSame(header1, table.getHeader(62));
48 Assert.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 Assert.assertEquals(68, table.getCurrentSize());
60
61 table.setMaxSize(256);
62 Assert.assertEquals(68, table.getCurrentSize());
63 table.setMaxSize(67);
64 Assert.assertEquals(34, table.getCurrentSize());
65 table.setMaxSize(10);
66 Assert.assertEquals(0, table.getCurrentSize());
67 }
68
69 }
70