|
7 | 7 |
|
8 | 8 | import static org.assertj.core.api.Assertions.assertThat;
|
9 | 9 |
|
10 |
| -import hello.HelloApplication; |
11 | 10 | import io.opentelemetry.api.trace.SpanKind;
|
12 | 11 | import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
13 | 12 | import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
|
14 | 13 | import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
|
15 | 14 | import io.opentelemetry.sdk.trace.data.StatusData;
|
16 | 15 | import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse;
|
17 |
| -import java.util.EnumSet; |
18 |
| -import javax.servlet.DispatcherType; |
19 |
| -import javax.servlet.FilterRegistration; |
20 |
| -import org.apache.wicket.protocol.http.WicketFilter; |
21 |
| -import org.eclipse.jetty.server.Server; |
22 |
| -import org.eclipse.jetty.servlet.DefaultServlet; |
23 |
| -import org.eclipse.jetty.servlet.ServletContextHandler; |
24 |
| -import org.eclipse.jetty.util.resource.FileResource; |
25 |
| -import org.eclipse.jetty.util.resource.Resource; |
26 | 16 | import org.jsoup.Jsoup;
|
27 | 17 | import org.jsoup.nodes.Document;
|
28 | 18 | import org.junit.jupiter.api.BeforeAll;
|
29 | 19 | import org.junit.jupiter.api.Test;
|
30 | 20 | import org.junit.jupiter.api.extension.RegisterExtension;
|
31 | 21 |
|
32 |
| -class WicketTest extends AbstractHttpServerUsingTest<Server> { |
| 22 | +abstract class AbstractWicketTest<SERVER> extends AbstractHttpServerUsingTest<SERVER> { |
33 | 23 |
|
34 | 24 | @RegisterExtension
|
35 | 25 | public static final InstrumentationExtension testing =
|
36 | 26 | HttpServerInstrumentationExtension.forAgent();
|
37 | 27 |
|
38 |
| - @Override |
39 |
| - protected Server setupServer() throws Exception { |
40 |
| - Server server = new Server(port); |
41 |
| - |
42 |
| - ServletContextHandler context = new ServletContextHandler(0); |
43 |
| - context.setContextPath(getContextPath()); |
44 |
| - |
45 |
| - Resource resource = new FileResource(getClass().getResource("/")); |
46 |
| - context.setBaseResource(resource); |
47 |
| - server.setHandler(context); |
48 |
| - |
49 |
| - context.addServlet(DefaultServlet.class, "/"); |
50 |
| - FilterRegistration.Dynamic registration = |
51 |
| - context.getServletContext().addFilter("WicketApplication", WicketFilter.class); |
52 |
| - registration.setInitParameter("applicationClassName", HelloApplication.class.getName()); |
53 |
| - registration.setInitParameter("filterMappingUrlPattern", "/wicket-test/*"); |
54 |
| - registration.addMappingForUrlPatterns( |
55 |
| - EnumSet.of(DispatcherType.REQUEST), false, "/wicket-test/*"); |
56 |
| - |
57 |
| - server.start(); |
58 |
| - |
59 |
| - return server; |
60 |
| - } |
61 |
| - |
62 |
| - @Override |
63 |
| - protected void stopServer(Server server) throws Exception { |
64 |
| - server.stop(); |
65 |
| - server.destroy(); |
66 |
| - } |
67 |
| - |
68 | 28 | @Override
|
69 | 29 | protected String getContextPath() {
|
70 | 30 | return "/jetty-context";
|
|
0 commit comments