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 jakarta.servlet.ServletException;
27  
28  import java.io.IOException;
29  
30  import org.junit.jupiter.api.Assertions;
31  import org.junit.jupiter.api.Test;
32  import org.openjdk.jmh.annotations.Benchmark;
33  import org.openjdk.jmh.annotations.Level;
34  import org.openjdk.jmh.annotations.Scope;
35  import org.openjdk.jmh.annotations.Setup;
36  import org.openjdk.jmh.annotations.State;
37  import org.openjdk.jmh.annotations.TearDown;
38  import org.openjdk.jmh.runner.Runner;
39  import org.openjdk.jmh.runner.RunnerException;
40  import org.openjdk.jmh.runner.options.Options;
41  import org.openjdk.jmh.runner.options.OptionsBuilder;
42  
43  /**
44   * The Class NegotiateSecurityFilterLoadTest.
45   */
46  class NegotiateSecurityFilterLoadTest {
47  
48      /**
49       * Launch load test.
50       *
51       * @throws RunnerException
52       *             the runner exception
53       */
54      @Test
55      void launchLoadTest() throws RunnerException {
56          final Options opt = new OptionsBuilder().threads(10).measurementIterations(10).build();
57          Assertions.assertNotNull(new Runner(opt).run());
58      }
59  
60      /**
61       * The Class St.
62       */
63      @State(Scope.Thread)
64      public static class St {
65  
66          /** The tests. */
67          private final NegotiateSecurityFilterTest tests = new NegotiateSecurityFilterTest();
68  
69          /**
70           * Initialize.
71           *
72           * @throws ServletException
73           *             the servlet exception
74           */
75          @Setup(Level.Trial)
76          public void initialize() throws ServletException {
77              this.tests.setUp();
78          }
79  
80          /**
81           * Benchmark.
82           *
83           * @throws IOException
84           *             Signals that an I/O exception has occurred.
85           * @throws ServletException
86           *             the servlet exception
87           */
88          @Benchmark
89          public void benchmark() throws IOException, ServletException {
90              this.tests.testNegotiate();
91          }
92  
93          /**
94           * Cleanup.
95           */
96          @TearDown(Level.Trial)
97          public void cleanup() {
98              this.tests.tearDown();
99          }
100 
101     }
102 
103 }