diff --git a/instrumentation/wicket-8.0/common-testing/build.gradle.kts b/instrumentation/wicket-8.0/common-testing/build.gradle.kts new file mode 100644 index 000000000000..d99731170744 --- /dev/null +++ b/instrumentation/wicket-8.0/common-testing/build.gradle.kts @@ -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") +} diff --git a/instrumentation/wicket-8.0/javaagent/src/test/java/hello/ExceptionPage.java b/instrumentation/wicket-8.0/common-testing/src/main/java/hello/ExceptionPage.java similarity index 84% rename from instrumentation/wicket-8.0/javaagent/src/test/java/hello/ExceptionPage.java rename to instrumentation/wicket-8.0/common-testing/src/main/java/hello/ExceptionPage.java index a5867e017129..eccacc9325e0 100644 --- a/instrumentation/wicket-8.0/javaagent/src/test/java/hello/ExceptionPage.java +++ b/instrumentation/wicket-8.0/common-testing/src/main/java/hello/ExceptionPage.java @@ -8,6 +8,8 @@ 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"); } diff --git a/instrumentation/wicket-8.0/javaagent/src/test/java/hello/HelloApplication.java b/instrumentation/wicket-8.0/common-testing/src/main/java/hello/HelloApplication.java similarity index 100% rename from instrumentation/wicket-8.0/javaagent/src/test/java/hello/HelloApplication.java rename to instrumentation/wicket-8.0/common-testing/src/main/java/hello/HelloApplication.java diff --git a/instrumentation/wicket-8.0/javaagent/src/test/java/hello/HelloPage.java b/instrumentation/wicket-8.0/common-testing/src/main/java/hello/HelloPage.java similarity index 85% rename from instrumentation/wicket-8.0/javaagent/src/test/java/hello/HelloPage.java rename to instrumentation/wicket-8.0/common-testing/src/main/java/hello/HelloPage.java index 09ae0d4a2bb3..bf327b6dc38d 100644 --- a/instrumentation/wicket-8.0/javaagent/src/test/java/hello/HelloPage.java +++ b/instrumentation/wicket-8.0/common-testing/src/main/java/hello/HelloPage.java @@ -9,6 +9,8 @@ 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!")); } diff --git a/instrumentation/wicket-8.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java b/instrumentation/wicket-8.0/common-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/AbstractWicketTest.java similarity index 61% rename from instrumentation/wicket-8.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java rename to instrumentation/wicket-8.0/common-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/AbstractWicketTest.java index 955013dfe659..dbbf92df79f0 100644 --- a/instrumentation/wicket-8.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java +++ b/instrumentation/wicket-8.0/common-testing/src/main/java/io/opentelemetry/javaagent/instrumentation/wicket/AbstractWicketTest.java @@ -7,64 +7,24 @@ 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 { +abstract class AbstractWicketTest extends AbstractHttpServerUsingTest { @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"; diff --git a/instrumentation/wicket-8.0/javaagent/src/test/resources/hello/HelloPage.html b/instrumentation/wicket-8.0/common-testing/src/main/resources/hello/HelloPage.html similarity index 100% rename from instrumentation/wicket-8.0/javaagent/src/test/resources/hello/HelloPage.html rename to instrumentation/wicket-8.0/common-testing/src/main/resources/hello/HelloPage.html diff --git a/instrumentation/wicket-8.0/javaagent/build.gradle.kts b/instrumentation/wicket-8.0/javaagent/build.gradle.kts index 2e9504d415e3..e0ab75135adb 100644 --- a/instrumentation/wicket-8.0/javaagent/build.gradle.kts +++ b/instrumentation/wicket-8.0/javaagent/build.gradle.kts @@ -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) - } } diff --git a/instrumentation/wicket-8.0/wicket10-testing/build.gradle.kts b/instrumentation/wicket-8.0/wicket10-testing/build.gradle.kts new file mode 100644 index 000000000000..b333fc1c7dfc --- /dev/null +++ b/instrumentation/wicket-8.0/wicket10-testing/build.gradle.kts @@ -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) +} diff --git a/instrumentation/wicket-8.0/wicket10-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java b/instrumentation/wicket-8.0/wicket10-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java new file mode 100644 index 000000000000..4e6d35644379 --- /dev/null +++ b/instrumentation/wicket-8.0/wicket10-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java @@ -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 { + + @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(); + } +} diff --git a/instrumentation/wicket-8.0/wicket8-testing/build.gradle.kts b/instrumentation/wicket-8.0/wicket8-testing/build.gradle.kts new file mode 100644 index 000000000000..635199f93a25 --- /dev/null +++ b/instrumentation/wicket-8.0/wicket8-testing/build.gradle.kts @@ -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) + } +} diff --git a/instrumentation/wicket-8.0/wicket8-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java b/instrumentation/wicket-8.0/wicket8-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java new file mode 100644 index 000000000000..2ce637aa5a4c --- /dev/null +++ b/instrumentation/wicket-8.0/wicket8-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java @@ -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 { + + @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(); + } +}