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.config;
29
30 import static org.junit.jupiter.api.Assertions.assertAll;
31 import static org.junit.jupiter.api.Assertions.assertEquals;
32 import static org.junit.jupiter.api.Assertions.assertNotNull;
33 import static org.junit.jupiter.api.Assertions.assertTrue;
34
35 import org.junit.jupiter.api.Test;
36
37 public class H2ConfigTest {
38
39 @Test
40 void builder() {
41
42 final H2Config h2Config = H2Config.custom()
43 .setPushEnabled(false)
44 .build();
45 assertNotNull(h2Config);
46 }
47
48 @Test
49 void checkValues() {
50
51 final H2Config h2Config = H2Config.custom()
52 .setHeaderTableSize(1)
53 .setMaxConcurrentStreams(1)
54 .setMaxFrameSize(16384)
55 .setPushEnabled(true)
56 .setCompressionEnabled(true)
57 .build();
58
59 assertEquals(1, h2Config.getHeaderTableSize());
60 assertEquals(1, h2Config.getMaxConcurrentStreams());
61 assertEquals(16384, h2Config.getMaxFrameSize());
62 assertTrue(h2Config.isPushEnabled());
63 assertTrue(h2Config.isCompressionEnabled());
64 }
65
66 @Test
67 void copy() {
68
69 final H2Config h2Config = H2Config.custom()
70 .setHeaderTableSize(1)
71 .setMaxConcurrentStreams(1)
72 .setMaxFrameSize(16384)
73 .setPushEnabled(true)
74 .setCompressionEnabled(true)
75 .build();
76
77 final H2Config.Builder builder = H2Config.copy(h2Config);
78 final H2Config h2Config2 = builder.build();
79
80 assertAll(
81 () -> assertEquals(h2Config.getHeaderTableSize(), h2Config2.getHeaderTableSize()),
82 () -> assertEquals(h2Config.getInitialWindowSize(), h2Config2.getInitialWindowSize()),
83 () -> assertEquals(h2Config.getMaxConcurrentStreams(), h2Config2.getMaxConcurrentStreams()),
84 () -> assertEquals(h2Config.getMaxFrameSize(), h2Config2.getMaxFrameSize()),
85 () -> assertEquals(h2Config.getMaxHeaderListSize(), h2Config2.getMaxHeaderListSize())
86 );
87
88 }
89
90 }