Test jax-ws on tomee and wildfly (#3382)
* Test jax-ws on tomee and wildfly * Search only org.gradle artifacts from gradle repo
This commit is contained in:
parent
2c2c19d293
commit
39508bc07e
|
@ -5,7 +5,12 @@ plugins {
|
|||
// add repo for org.gradle:gradle-tooling-api which org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.gradle.org/artifactory/libs-releases-local' }
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,12 @@ plugins {
|
|||
// which is used by jaxrs-2.0-arquillian-testing depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.gradle.org/artifactory/libs-releases-local' }
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,12 @@ plugins {
|
|||
// which is used by jaxrs-2.0-arquillian-testing depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.gradle.org/artifactory/libs-releases-local' }
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
plugins {
|
||||
id("otel.javaagent-testing")
|
||||
}
|
||||
|
||||
// add repo for org.gradle:gradle-tooling-api which org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "javax:javaee-api:7.0"
|
||||
|
||||
api project(':testing-common')
|
||||
implementation "io.opentelemetry:opentelemetry-api"
|
||||
implementation "org.jsoup:jsoup:1.13.1"
|
||||
|
||||
def arquillianVersion = '1.4.0.Final'
|
||||
implementation "org.jboss.arquillian.junit:arquillian-junit-container:${arquillianVersion}"
|
||||
implementation "org.jboss.arquillian.protocol:arquillian-protocol-servlet:${arquillianVersion}"
|
||||
implementation 'org.jboss.arquillian.spock:arquillian-spock-container:1.0.0.CR1'
|
||||
api "org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain:3.1.3"
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
||||
import static io.opentelemetry.api.trace.SpanKind.SERVER
|
||||
import static io.opentelemetry.api.trace.StatusCode.ERROR
|
||||
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import io.opentelemetry.testing.internal.armeria.client.WebClient
|
||||
import org.jboss.arquillian.container.test.api.Deployment
|
||||
import org.jboss.arquillian.container.test.api.RunAsClient
|
||||
import org.jboss.arquillian.spock.ArquillianSputnik
|
||||
import org.jboss.arquillian.test.api.ArquillianResource
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive
|
||||
import org.jsoup.Jsoup
|
||||
import org.junit.runner.RunWith
|
||||
import spock.lang.Unroll
|
||||
import test.EjbHelloServiceImpl
|
||||
import test.HelloService
|
||||
import test.HelloServiceImpl
|
||||
|
||||
@RunWith(ArquillianSputnik)
|
||||
@RunAsClient
|
||||
abstract class ArquillianJaxWsTest extends AgentInstrumentationSpecification {
|
||||
|
||||
static WebClient client = WebClient.of()
|
||||
|
||||
@ArquillianResource
|
||||
static URI url
|
||||
|
||||
@Deployment
|
||||
static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create(WebArchive)
|
||||
.addClass(HelloService)
|
||||
.addClass(HelloServiceImpl)
|
||||
.addClass(EjbHelloServiceImpl)
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
|
||||
}
|
||||
|
||||
def getAddress(String service) {
|
||||
return url.resolve(service).toString()
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "test #service"() {
|
||||
setup:
|
||||
def soapMessage =
|
||||
"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://opentelemetry.io/test/hello-web-service">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<hel:helloRequest>
|
||||
<name>Test</name>
|
||||
</hel:helloRequest>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>"""
|
||||
|
||||
def response = client.post(getAddress(service), soapMessage).aggregate().join()
|
||||
def doc = Jsoup.parse(response.contentUtf8())
|
||||
|
||||
expect:
|
||||
response.status().code() == 200
|
||||
doc.selectFirst("message").text() == "Hello Test"
|
||||
|
||||
and:
|
||||
def methodName = "hello"
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
serverSpan(it, 0, serverSpanName(service, methodName))
|
||||
handlerSpan(it, 1, service, methodName, span(0))
|
||||
annotationHandlerSpan(it, 2, service, methodName, span(1))
|
||||
}
|
||||
}
|
||||
|
||||
where:
|
||||
service << ["HelloService", "EjbHelloService"]
|
||||
}
|
||||
|
||||
def serverSpanName(String service, String operation) {
|
||||
return service + "Impl." + operation
|
||||
}
|
||||
|
||||
static serverSpan(TraceAssert trace, int index, String operation, Throwable exception = null) {
|
||||
trace.span(index) {
|
||||
hasNoParent()
|
||||
name operation
|
||||
kind SERVER
|
||||
if (exception != null) {
|
||||
status ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static handlerSpan(TraceAssert trace, int index, String service, String operation, Object parentSpan = null, Throwable exception = null) {
|
||||
trace.span(index) {
|
||||
if (parentSpan == null) {
|
||||
hasNoParent()
|
||||
} else {
|
||||
childOf((SpanData) parentSpan)
|
||||
}
|
||||
name service + "/" + operation
|
||||
kind INTERNAL
|
||||
if (exception) {
|
||||
status ERROR
|
||||
errorEvent(exception.class, exception.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static annotationHandlerSpan(TraceAssert trace, int index, String service, String methodName, Object parentSpan = null, Throwable exception = null) {
|
||||
trace.span(index) {
|
||||
if (parentSpan == null) {
|
||||
hasNoParent()
|
||||
} else {
|
||||
childOf((SpanData) parentSpan)
|
||||
}
|
||||
name service + "Impl." + methodName
|
||||
kind INTERNAL
|
||||
if (exception) {
|
||||
status ERROR
|
||||
errorEvent(exception.class, exception.message)
|
||||
}
|
||||
attributes {
|
||||
"${SemanticAttributes.CODE_NAMESPACE.key}" "test." + service + "Impl"
|
||||
"${SemanticAttributes.CODE_FUNCTION.key}" methodName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService(
|
||||
serviceName = "EjbHelloService",
|
||||
endpointInterface = "test.HelloService",
|
||||
targetNamespace = "http://opentelemetry.io/test/hello-web-service")
|
||||
@Stateless
|
||||
public class EjbHelloServiceImpl implements HelloService {
|
||||
|
||||
@Override
|
||||
public String hello(String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import javax.jws.WebParam;
|
||||
import javax.jws.WebResult;
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.ws.RequestWrapper;
|
||||
|
||||
@WebService(targetNamespace = "http://opentelemetry.io/test/hello-web-service")
|
||||
public interface HelloService {
|
||||
|
||||
@RequestWrapper(localName = "helloRequest")
|
||||
@WebResult(name = "message")
|
||||
String hello(@WebParam(name = "name") String name);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService(
|
||||
serviceName = "HelloService",
|
||||
endpointInterface = "test.HelloService",
|
||||
targetNamespace = "http://opentelemetry.io/test/hello-web-service")
|
||||
public class HelloServiceImpl implements HelloService {
|
||||
|
||||
@Override
|
||||
public String hello(String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
plugins {
|
||||
id("otel.javaagent-testing")
|
||||
}
|
||||
|
||||
// add repo for org.gradle:gradle-tooling-api which org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain
|
||||
// which is used by jaxws-2.0-arquillian-testing depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation project(':instrumentation:jaxws:jaxws-2.0-arquillian-testing')
|
||||
testCompileOnly "jakarta.enterprise:jakarta.enterprise.cdi-api:2.0.2"
|
||||
testRuntimeOnly "org.apache.tomee:arquillian-tomee-embedded:8.0.6"
|
||||
testRuntimeOnly "org.apache.tomee:tomee-embedded:8.0.6"
|
||||
testRuntimeOnly "org.apache.tomee:tomee-webservices:8.0.6"
|
||||
|
||||
testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jaxws-2.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jaxws-2.0-cxf-3.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jws-1.1:javaagent')
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import javax.enterprise.inject.Vetoed
|
||||
|
||||
// exclude this class from CDI as it causes NullPointerException when tomee is run with jdk8
|
||||
@Vetoed
|
||||
class TomeeJaxWsTest extends ArquillianJaxWsTest {
|
||||
|
||||
@Override
|
||||
def getAddress(String service) {
|
||||
if (service == "EjbHelloService") {
|
||||
service = "webservices/EjbHelloServiceImpl"
|
||||
}
|
||||
return super.getAddress(service)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<arquillian xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://jboss.org/schema/arquillian
|
||||
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<container qualifier="tomee-embedded" default="true">
|
||||
<configuration>
|
||||
<property name="httpPort">-1</property>
|
||||
<property name="stopPort">-1</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</arquillian>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<Pattern>
|
||||
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<logger name="io.opentelemetry" level="debug"/>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,80 @@
|
|||
plugins {
|
||||
id("otel.javaagent-testing")
|
||||
}
|
||||
|
||||
// add repo for org.gradle:gradle-tooling-api which org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain
|
||||
// which is used by jaxws-2.0-arquillian-testing depends on
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://repo.gradle.org/artifactory/libs-releases-local'
|
||||
content {
|
||||
includeGroup 'org.gradle'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
configurations {
|
||||
testServer
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation "javax:javaee-api:7.0"
|
||||
|
||||
testImplementation project(':instrumentation:jaxws:jaxws-2.0-arquillian-testing')
|
||||
testRuntimeOnly "org.wildfly.arquillian:wildfly-arquillian-container-embedded:2.2.0.Final"
|
||||
|
||||
testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jaxws-2.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jaxws-2.0-cxf-3.0:javaagent')
|
||||
testInstrumentation project(':instrumentation:jaxws:jws-1.1:javaagent')
|
||||
|
||||
// wildfly version used to run tests
|
||||
testServer "org.wildfly:wildfly-dist:18.0.0.Final@zip"
|
||||
}
|
||||
|
||||
// extract wildfly dist, path is used from arquillian.xml
|
||||
task setupServer(type: Copy) {
|
||||
from zipTree(configurations.testServer.singleFile)
|
||||
into file('build/server/')
|
||||
}
|
||||
|
||||
// logback-classic contains /META-INF/services/javax.servlet.ServletContainerInitializer
|
||||
// that breaks deploy on embedded wildfly
|
||||
// create a copy of logback-classic jar that does not have this file
|
||||
task modifyLogbackJar(type: Jar) {
|
||||
doFirst {
|
||||
configurations.configureEach {
|
||||
if (it.name.toLowerCase().endsWith('testruntimeclasspath')) {
|
||||
def logbackJar = it.find { it.name.contains('logback-classic') }
|
||||
from zipTree(logbackJar)
|
||||
exclude(
|
||||
"/META-INF/services/javax.servlet.ServletContainerInitializer"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
destinationDirectory = file("$buildDir/tmp")
|
||||
archiveFileName = "logback-classic-modified.jar"
|
||||
}
|
||||
|
||||
test.dependsOn modifyLogbackJar, setupServer
|
||||
|
||||
test {
|
||||
doFirst {
|
||||
// --add-modules is unrecognized on jdk8, ignore it instead of failing
|
||||
jvmArgs "-XX:+IgnoreUnrecognizedVMOptions"
|
||||
// needed for java 11 to avoid org.jboss.modules.ModuleNotFoundException: java.se
|
||||
jvmArgs "--add-modules=java.se"
|
||||
// add offset to default port values
|
||||
jvmArgs "-Djboss.socket.binding.port-offset=200"
|
||||
|
||||
// remove logback-classic from classpath
|
||||
classpath = classpath.filter {
|
||||
return !it.absolutePath.contains("logback-classic")
|
||||
}
|
||||
// add modified copy of logback-classic to classpath
|
||||
classpath += files("$buildDir/tmp/logback-classic-modified.jar")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
class WildflyJaxWsTest extends ArquillianJaxWsTest {
|
||||
|
||||
@Override
|
||||
def getAddress(String service) {
|
||||
if (service == "EjbHelloService") {
|
||||
service = "EjbHelloService/EjbHelloServiceImpl"
|
||||
}
|
||||
return super.getAddress(service)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<arquillian xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://jboss.org/schema/arquillian
|
||||
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<container qualifier="wildfly-embedded" default="true">
|
||||
<configuration>
|
||||
<property name="jbossHome">build/server/wildfly-18.0.0.Final</property>
|
||||
<property name="modulePath">build/server/wildfly-18.0.0.Final/modules</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</arquillian>
|
|
@ -169,12 +169,15 @@ include ':instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-cxf-3.0
|
|||
include ':instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-jersey-2.0:javaagent'
|
||||
include ':instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-resteasy-3.0:javaagent'
|
||||
include ':instrumentation:jaxws:jaxws-2.0:javaagent'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-arquillian-testing'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-axis2-1.6:javaagent'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-axis2-1.6:library'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-cxf-3.0:javaagent'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-cxf-3.0:library'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-metro-2.2:javaagent'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-testing'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-tomee-testing'
|
||||
include ':instrumentation:jaxws:jaxws-2.0-wildfly-testing'
|
||||
include ':instrumentation:jaxws:jaxws-common:library'
|
||||
include ':instrumentation:jaxws:jws-1.1:javaagent'
|
||||
include ':instrumentation:jdbc:javaagent'
|
||||
|
|
Loading…
Reference in New Issue