View Javadoc
1   /*
2    * SPDX-License-Identifier: MIT
3    * See LICENSE file for details.
4    *
5    * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6    */
7   package waffle.servlet;
8   
9   import jakarta.servlet.ServletException;
10  
11  import java.io.IOException;
12  
13  import org.junit.jupiter.api.Assertions;
14  import org.junit.jupiter.api.Test;
15  import org.openjdk.jmh.annotations.Benchmark;
16  import org.openjdk.jmh.annotations.Level;
17  import org.openjdk.jmh.annotations.Scope;
18  import org.openjdk.jmh.annotations.Setup;
19  import org.openjdk.jmh.annotations.State;
20  import org.openjdk.jmh.annotations.TearDown;
21  import org.openjdk.jmh.runner.Runner;
22  import org.openjdk.jmh.runner.RunnerException;
23  import org.openjdk.jmh.runner.options.Options;
24  import org.openjdk.jmh.runner.options.OptionsBuilder;
25  
26  /**
27   * The Class NegotiateSecurityFilterLoadTest.
28   */
29  class NegotiateSecurityFilterLoadTest {
30  
31      /**
32       * Launch load test.
33       *
34       * @throws RunnerException
35       *             the runner exception
36       */
37      @Test
38      void launchLoadTest() throws RunnerException {
39          final Options opt = new OptionsBuilder().threads(10).measurementIterations(10).build();
40          Assertions.assertNotNull(new Runner(opt).run());
41      }
42  
43      /**
44       * The Class St.
45       */
46      @State(Scope.Thread)
47      public static class St {
48  
49          /** The tests. */
50          private final NegotiateSecurityFilterTest tests = new NegotiateSecurityFilterTest();
51  
52          /**
53           * Initialize.
54           *
55           * @throws ServletException
56           *             the servlet exception
57           */
58          @Setup(Level.Trial)
59          public void initialize() throws ServletException {
60              this.tests.setUp();
61          }
62  
63          /**
64           * Benchmark.
65           *
66           * @throws IOException
67           *             Signals that an I/O exception has occurred.
68           * @throws ServletException
69           *             the servlet exception
70           */
71          @Benchmark
72          public void benchmark() throws IOException, ServletException {
73              this.tests.testNegotiate();
74          }
75  
76          /**
77           * Cleanup.
78           */
79          @TearDown(Level.Trial)
80          public void cleanup() {
81              this.tests.tearDown();
82          }
83  
84      }
85  
86  }