View Javadoc
1   /*
2    * MIT License
3    *
4    * Copyright (c) 2010-2024 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
5    *
6    * Permission is hereby granted, free of charge, to any person obtaining a copy
7    * of this software and associated documentation files (the "Software"), to deal
8    * in the Software without restriction, including without limitation the rights
9    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10   * copies of the Software, and to permit persons to whom the Software is
11   * furnished to do so, subject to the following conditions:
12   *
13   * The above copyright notice and this permission notice shall be included in all
14   * copies or substantial portions of the Software.
15   *
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22   * SOFTWARE.
23   */
24  package waffle.servlet;
25  
26  import java.io.IOException;
27  
28  import javax.servlet.ServletException;
29  
30  import org.junit.jupiter.api.Test;
31  import org.openjdk.jmh.annotations.Benchmark;
32  import org.openjdk.jmh.annotations.Level;
33  import org.openjdk.jmh.annotations.Scope;
34  import org.openjdk.jmh.annotations.Setup;
35  import org.openjdk.jmh.annotations.State;
36  import org.openjdk.jmh.annotations.TearDown;
37  import org.openjdk.jmh.runner.Runner;
38  import org.openjdk.jmh.runner.RunnerException;
39  import org.openjdk.jmh.runner.options.Options;
40  import org.openjdk.jmh.runner.options.OptionsBuilder;
41  
42  /**
43   * The Class NegotiateSecurityFilterLoadTest.
44   */
45  class NegotiateSecurityFilterLoadTest {
46  
47      /**
48       * Launch load test.
49       *
50       * @throws RunnerException
51       *             the runner exception
52       */
53      @Test
54      void launchLoadTest() throws RunnerException {
55          final Options opt = new OptionsBuilder().threads(10).measurementIterations(10).build();
56          new Runner(opt).run();
57      }
58  
59      /**
60       * The Class St.
61       */
62      @State(Scope.Thread)
63      public static class St {
64  
65          /** The tests. */
66          private final NegotiateSecurityFilterTest tests = new NegotiateSecurityFilterTest();
67  
68          /**
69           * Initialize.
70           *
71           * @throws ServletException
72           *             the servlet exception
73           */
74          @Setup(Level.Trial)
75          public void initialize() throws ServletException {
76              this.tests.setUp();
77          }
78  
79          /**
80           * Benchmark.
81           *
82           * @throws IOException
83           *             Signals that an I/O exception has occurred.
84           * @throws ServletException
85           *             the servlet exception
86           */
87          @Benchmark
88          public void benchmark() throws IOException, ServletException {
89              this.tests.testNegotiate();
90          }
91  
92          /**
93           * Cleanup.
94           *
95           * @throws ServletException
96           *             the servlet exception
97           */
98          @TearDown(Level.Trial)
99          public void cleanup() throws ServletException {
100             this.tests.tearDown();
101         }
102 
103     }
104 
105 }