-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/v1.33.x] Fix tests for wicket 10 (#10819)
Co-authored-by: Lauri Tulmin <[email protected]>
- Loading branch information
1 parent
64dec1e
commit 4f75a1d
Showing
11 changed files
with
160 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
instrumentation/wicket-8.0/wicket10-testing/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
49 changes: 49 additions & 0 deletions
49
...0-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
instrumentation/wicket-8.0/wicket8-testing/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...8-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/wicket/WicketTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |