View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
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          // Create and start requester
42          final H2Config h2Config = H2Config.custom()
43                  .setPushEnabled(false)
44                  .build();
45          assertNotNull(h2Config);
46      }
47  
48      @Test
49      void checkValues() {
50          // Create and start requester
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          // Create and start requester
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  }