Fix tests for wicket 10 (#10814)
This commit is contained in:
parent
fa5548b9a5
commit
dc8be4771d
|
@ -0,0 +1,9 @@
|
|||
plugins {
|
||||
id("otel.java-conventions")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":testing-common"))
|
||||
implementation("org.apache.wicket:wicket:8.0.0")
|
||||
implementation("org.jsoup:jsoup:1.13.1")
|
||||
}
|
|
@ -8,6 +8,8 @@ package hello;
|
|||
import org.apache.wicket.markup.html.WebPage;
|
||||
|
||||
public class ExceptionPage extends WebPage {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ExceptionPage() throws Exception {
|
||||
throw new Exception("test exception");
|
||||
}
|
|
@ -9,6 +9,8 @@ import org.apache.wicket.markup.html.WebPage;
|
|||
import org.apache.wicket.markup.html.basic.Label;
|
||||
|
||||
public class HelloPage extends WebPage {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HelloPage() {
|
||||
add(new Label("message", "Hello World!"));
|
||||
}
|
|
@ -7,64 +7,24 @@ package io.opentelemetry.javaagent.instrumentation.wicket;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import hello.HelloApplication;
|
||||
import io.opentelemetry.api.trace.SpanKind;
|
||||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
||||
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
|
||||
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
|
||||
import io.opentelemetry.sdk.trace.data.StatusData;
|
||||
import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse;
|
||||
import java.util.EnumSet;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import org.apache.wicket.protocol.http.WicketFilter;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.resource.FileResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
class WicketTest extends AbstractHttpServerUsingTest<Server> {
|
||||
abstract class AbstractWicketTest<SERVER> extends AbstractHttpServerUsingTest<SERVER> {
|
||||
|
||||
@RegisterExtension
|
||||
public static final InstrumentationExtension testing =
|
||||
HttpServerInstrumentationExtension.forAgent();
|
||||
|
||||
@Override
|
||||
protected Server setupServer() throws Exception {
|
||||
Server server = new Server(port);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler(0);
|
||||
context.setContextPath(getContextPath());
|
||||
|
||||
Resource resource = new FileResource(getClass().getResource("/"));
|
||||
context.setBaseResource(resource);
|
||||
server.setHandler(context);
|
||||
|
||||
context.addServlet(DefaultServlet.class, "/");
|
||||
FilterRegistration.Dynamic registration =
|
||||
context.getServletContext().addFilter("WicketApplication", WicketFilter.class);
|
||||
registration.setInitParameter("applicationClassName", HelloApplication.class.getName());
|
||||
registration.setInitParameter("filterMappingUrlPattern", "/wicket-test/*");
|
||||
registration.addMappingForUrlPatterns(
|
||||
EnumSet.of(DispatcherType.REQUEST), false, "/wicket-test/*");
|
||||
|
||||
server.start();
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopServer(Server server) throws Exception {
|
||||
server.stop();
|
||||
server.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getContextPath() {
|
||||
return "/jetty-context";
|
|
@ -15,21 +15,4 @@ dependencies {
|
|||
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))
|
||||
|
||||
library("org.apache.wicket:wicket:8.0.0")
|
||||
|
||||
testImplementation(project(":testing-common"))
|
||||
testImplementation("org.jsoup:jsoup:1.13.1")
|
||||
testImplementation("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
|
||||
testImplementation("org.eclipse.jetty:jetty-servlet:8.0.0.v20110901")
|
||||
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
|
||||
}
|
||||
|
||||
val latestDepTest = findProperty("testLatestDeps") as Boolean
|
||||
|
||||
// Wicket 9 requires Java 11
|
||||
if (latestDepTest) {
|
||||
otelJava {
|
||||
minJavaVersionSupported.set(JavaVersion.VERSION_11)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id("otel.javaagent-testing")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library("org.apache.wicket:wicket:10.0.0")
|
||||
|
||||
testImplementation(project(":instrumentation:wicket-8.0:common-testing"))
|
||||
testImplementation("org.jsoup:jsoup:1.13.1")
|
||||
testImplementation("org.eclipse.jetty:jetty-server:11.0.0")
|
||||
testImplementation("org.eclipse.jetty:jetty-servlet:11.0.0")
|
||||
|
||||
testInstrumentation(project(":instrumentation:wicket-8.0:javaagent"))
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-5.0:javaagent"))
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
|
||||
}
|
||||
|
||||
otelJava {
|
||||
minJavaVersionSupported.set(JavaVersion.VERSION_11)
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.javaagent.instrumentation.wicket;
|
||||
|
||||
import hello.HelloApplication;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.FilterRegistration;
|
||||
import java.util.EnumSet;
|
||||
import org.apache.wicket.protocol.http.WicketFilter;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
class WicketTest extends AbstractWicketTest<Server> {
|
||||
|
||||
@Override
|
||||
protected Server setupServer() throws Exception {
|
||||
Server server = new Server(port);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler(0);
|
||||
context.setContextPath(getContextPath());
|
||||
|
||||
Resource resource = Resource.newResource(getClass().getResource("/"));
|
||||
context.setBaseResource(resource);
|
||||
server.setHandler(context);
|
||||
|
||||
context.addServlet(DefaultServlet.class, "/");
|
||||
FilterRegistration.Dynamic registration =
|
||||
context.getServletContext().addFilter("WicketApplication", WicketFilter.class);
|
||||
registration.setInitParameter("applicationClassName", HelloApplication.class.getName());
|
||||
registration.setInitParameter("filterMappingUrlPattern", "/wicket-test/*");
|
||||
registration.addMappingForUrlPatterns(
|
||||
EnumSet.of(DispatcherType.REQUEST), false, "/wicket-test/*");
|
||||
|
||||
server.start();
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopServer(Server server) throws Exception {
|
||||
server.stop();
|
||||
server.destroy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
plugins {
|
||||
id("otel.javaagent-testing")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library("org.apache.wicket:wicket:8.0.0")
|
||||
|
||||
testImplementation(project(":instrumentation:wicket-8.0:common-testing"))
|
||||
testImplementation("org.jsoup:jsoup:1.13.1")
|
||||
testImplementation("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
|
||||
testImplementation("org.eclipse.jetty:jetty-servlet:8.0.0.v20110901")
|
||||
|
||||
testInstrumentation(project(":instrumentation:wicket-8.0:javaagent"))
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
|
||||
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
|
||||
|
||||
latestDepTestLibrary("org.apache.wicket:wicket:9.+")
|
||||
}
|
||||
|
||||
val latestDepTest = findProperty("testLatestDeps") as Boolean
|
||||
|
||||
// Wicket 9 requires Java 11
|
||||
if (latestDepTest) {
|
||||
otelJava {
|
||||
minJavaVersionSupported.set(JavaVersion.VERSION_11)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.javaagent.instrumentation.wicket;
|
||||
|
||||
import hello.HelloApplication;
|
||||
import java.util.EnumSet;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import org.apache.wicket.protocol.http.WicketFilter;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.util.resource.FileResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
class WicketTest extends AbstractWicketTest<Server> {
|
||||
|
||||
@Override
|
||||
protected Server setupServer() throws Exception {
|
||||
Server server = new Server(port);
|
||||
|
||||
ServletContextHandler context = new ServletContextHandler(0);
|
||||
context.setContextPath(getContextPath());
|
||||
|
||||
Resource resource = new FileResource(getClass().getResource("/"));
|
||||
context.setBaseResource(resource);
|
||||
server.setHandler(context);
|
||||
|
||||
context.addServlet(DefaultServlet.class, "/");
|
||||
FilterRegistration.Dynamic registration =
|
||||
context.getServletContext().addFilter("WicketApplication", WicketFilter.class);
|
||||
registration.setInitParameter("applicationClassName", HelloApplication.class.getName());
|
||||
registration.setInitParameter("filterMappingUrlPattern", "/wicket-test/*");
|
||||
registration.addMappingForUrlPatterns(
|
||||
EnumSet.of(DispatcherType.REQUEST), false, "/wicket-test/*");
|
||||
|
||||
server.start();
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopServer(Server server) throws Exception {
|
||||
server.stop();
|
||||
server.destroy();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue