From a3fd7dc22335cbce4c285a6aa0cf45a24c74c905 Mon Sep 17 00:00:00 2001 From: R Searls Date: Tue, 26 Sep 2023 16:34:40 -0400 Subject: [PATCH] jaxws bootable jar test --- demos/pom.xml | 22 ++ demos/ws-bootable-jar-example/README.md | 22 ++ .../jaxws/maven/bootable-jar-openshift | 0 demos/ws-bootable-jar-example/jaxws/pom.xml | 112 +++++++ .../jaxws/scripts/property.cli | 1 + .../main/java/org/jboss/jaxws/Endpoint.java | 30 ++ .../java/org/jboss/jaxws/EndpointImpl.java | 50 ++++ .../src/main/webapp/WEB-INF/jboss-web.xml | 5 + ...ildflyBootableOpenShiftJarApplication.java | 113 +++++++ .../SoapWildflyBootableOpenShiftJarTest.java | 72 +++++ ...it.platform.launcher.TestExecutionListener | 2 + .../jaxws/src/test/resources/logback.xml | 59 ++++ demos/ws-bootable-jar-example/pom.xml | 282 ++++++++++++++++++ pom.xml | 9 + .../HyperfoilOperatorProvisionerTest.java | 3 +- 15 files changed, 780 insertions(+), 2 deletions(-) create mode 100644 demos/pom.xml create mode 100644 demos/ws-bootable-jar-example/README.md create mode 100644 demos/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift create mode 100644 demos/ws-bootable-jar-example/jaxws/pom.xml create mode 100644 demos/ws-bootable-jar-example/jaxws/scripts/property.cli create mode 100644 demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/Endpoint.java create mode 100644 demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/EndpointImpl.java create mode 100644 demos/ws-bootable-jar-example/jaxws/src/main/webapp/WEB-INF/jboss-web.xml create mode 100644 demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarApplication.java create mode 100644 demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarTest.java create mode 100644 demos/ws-bootable-jar-example/jaxws/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener create mode 100644 demos/ws-bootable-jar-example/jaxws/src/test/resources/logback.xml create mode 100644 demos/ws-bootable-jar-example/pom.xml diff --git a/demos/pom.xml b/demos/pom.xml new file mode 100644 index 000000000..4b24e9655 --- /dev/null +++ b/demos/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + org.jboss.intersmash + intersmash-parent + 0.0.1-SNAPSHOT + ../pom.xml + + + Intersmash Demos + + intersmash-demos + pom + + + ws-bootable-jar-example + + + diff --git a/demos/ws-bootable-jar-example/README.md b/demos/ws-bootable-jar-example/README.md new file mode 100644 index 000000000..7cc8dcda3 --- /dev/null +++ b/demos/ws-bootable-jar-example/README.md @@ -0,0 +1,22 @@ +ws-bootable-jar-example +======================= + +This module provides a simple POC webservice's jaxws application that is built as a bootable jar consisting of Wildfly and the jaxws war file, and then deployed to OpenShift, and tested. + +The jaxws module builds 2 archives, the webservice's war file and a bootable jar to be run on OpenShift + +This module demonstrates building a fresh (relatively current) version of Wildfly using Galleon for inclusion in the bootable jar, as compared to pulling a pre-existing Wildfly image from a public repository. The process enables the user to build a current version of Wildfly for testing. + +Module, demos, is not declared in intersmash's root pom.xml file. The module must be built separately and the example must run from directory, demos. The user will also require a test.properties file with the appropriate OpenShift reference and configuration information. The test can be run with cmd. + +Built the project and then the demos module with these commands. + mvn clean install -DskipTests + mvn clean install -DskipTests -Pdemo + +Run the test. + mvn test -pl ws-bootable-jar-example/ -amd -Dtest=SoapWildflyBootableOpenShiftJarTest \ + -Dxtf.test_properties.path=/ABSOLUTE/PATH/TO/test.properties + +or if test.properties resides in the demos directory cmd, + + mvn test -pl ws-bootable-jar-example/ -amd -Dtest=SoapWildflyBootableOpenShiftJarTest diff --git a/demos/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift b/demos/ws-bootable-jar-example/jaxws/maven/bootable-jar-openshift new file mode 100644 index 000000000..e69de29bb diff --git a/demos/ws-bootable-jar-example/jaxws/pom.xml b/demos/ws-bootable-jar-example/jaxws/pom.xml new file mode 100644 index 000000000..5f7aac942 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/pom.xml @@ -0,0 +1,112 @@ + + + + + + 4.0.0 + + + org.jboss.intersmash + ws-bootable-jar-example + 0.0.1-SNAPSHOT + ../pom.xml + + + jaxws + war + + Intersmash Demos : (Wildfly): Webservices Bootable JAR Examples (jaxws) + + + + ${project.parent.parent.parent.basedir}/ide-config + 6.2.0.Final + + + + + jakarta.platform + jakarta.jakartaee-api + provided + + + + jakarta.inject + jakarta.inject-api + + + jakarta.ws.rs + jakarta.ws.rs-api + ${version.jakarta.ws.rs-api} + provided + + + org.jboss.ws.cxf + jbossws-cxf-client + ${version.jbossws-cxf} + + + org.jboss.slf4j + slf4j-jboss-logging + + + + + + + + + org.wildfly.plugins + wildfly-jar-maven-plugin + + + + + + ./scripts/property.cli + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${client.jvm.jpms.args} + + false + false + + + + + + diff --git a/demos/ws-bootable-jar-example/jaxws/scripts/property.cli b/demos/ws-bootable-jar-example/jaxws/scripts/property.cli new file mode 100644 index 000000000..a3e15a9a5 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/scripts/property.cli @@ -0,0 +1 @@ +/system-property=jaxws-test-property:add(value=jaxws-test-value) diff --git a/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/Endpoint.java b/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/Endpoint.java new file mode 100644 index 000000000..266306cd3 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/Endpoint.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.jaxws; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebService; + +@WebService(targetNamespace = "http://org.jboss.ws/cxf/container") +public interface Endpoint { + + @WebMethod + public String greetings(String time); + + @WebMethod + String ping(); +} diff --git a/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/EndpointImpl.java b/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/EndpointImpl.java new file mode 100644 index 000000000..054377e07 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/main/java/org/jboss/jaxws/EndpointImpl.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.jaxws; + +import jakarta.jws.WebMethod; +import jakarta.jws.WebService; + +@WebService(serviceName = "EndpointServiceSERVICE", name = "EndpointService", portName = "EndpointService", endpointInterface = "org.jboss.jaxws.Endpoint", targetNamespace = "http://org.jboss.ws/cxf/container") +public class EndpointImpl implements Endpoint { + @WebMethod + @Override + public String greetings(String input) { + return input + ", hello from WildFly bootable jar!"; + } + + @WebMethod + @Override + public String ping() { + return "pong"; + } +} diff --git a/demos/ws-bootable-jar-example/jaxws/src/main/webapp/WEB-INF/jboss-web.xml b/demos/ws-bootable-jar-example/jaxws/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 000000000..159229a8c --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarApplication.java b/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarApplication.java new file mode 100644 index 000000000..524f73e0d --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarApplication.java @@ -0,0 +1,113 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.jaxws; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.maven.settings.building.SettingsBuildingException; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.jboss.intersmash.deployments.util.maven.ArtifactProvider; +import org.jboss.intersmash.tools.application.openshift.BootableJarOpenShiftApplication; +import org.jboss.intersmash.tools.application.openshift.input.BinarySource; + +import cz.xtf.builder.builders.SecretBuilder; +import cz.xtf.builder.builders.secret.SecretType; +import io.fabric8.kubernetes.api.model.EnvVar; +import io.fabric8.kubernetes.api.model.EnvVarBuilder; +import io.fabric8.kubernetes.api.model.Secret; + +public class SoapWildflyBootableOpenShiftJarApplication implements BootableJarOpenShiftApplication { + private String GROUPID = "org.jboss.intersmash"; + private String ARTIFACTID = "jaxws"; + private String VERSION = "0.0.1-SNAPSHOT"; + static final String BOOTABLE_JAR_ARTIFACT_PACKAGING = "jar"; + static final String ARTIFACT_CLASSIFIER = "bootable-openshift"; + + static final EnvVar TEST_ENV_VAR = new EnvVarBuilder().withName("test-evn-key").withValue("test-evn-value").build(); + static final String TEST_SECRET_FOO = "foo"; + static final String TEST_SECRET_BAR = "bar"; + static final Secret TEST_SECRET = new SecretBuilder("test-secret") + .setType(SecretType.OPAQUE).addData(TEST_SECRET_FOO, TEST_SECRET_BAR.getBytes()).build(); + + @Override + public BinarySource getBuildInput() { + Path file = null; + try { + file = ArtifactProvider.resolveArtifact( + GROUPID, + ARTIFACTID, + VERSION, + BOOTABLE_JAR_ARTIFACT_PACKAGING, + ARTIFACT_CLASSIFIER).toPath(); + } catch (SettingsBuildingException | ArtifactResolutionException e) { + throw new RuntimeException("Can not get artifact", e); + } + return new BinarySourceImpl(file); + } + + @Override + public List getSecrets() { + List secrets = new ArrayList<>(); + secrets.add(TEST_SECRET); + return Collections.unmodifiableList(secrets); + } + + @Override + public List getEnvVars() { + List list = new ArrayList<>(); + list.add(new EnvVarBuilder().withName(TEST_ENV_VAR.getName()) + .withValue(TEST_ENV_VAR.getValue()).build()); + return Collections.unmodifiableList(list); + } + + @Override + public String getName() { + return "ws-bootable-openshift-jar"; + } + + // todo remove local class impl once intersmash issue #85 is resolved + class BinarySourceImpl implements BinarySource { + Path f; + + public BinarySourceImpl(Path f) { + this.f = f; + } + + public Path getArchive() { + return f; + } + } + +} diff --git a/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarTest.java b/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarTest.java new file mode 100644 index 000000000..632cb9ade --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/test/java/org/jboss/jaxws/SoapWildflyBootableOpenShiftJarTest.java @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.jaxws; + +import jakarta.xml.ws.BindingProvider; + +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.assertj.core.api.Assertions; +import org.jboss.intersmash.tools.annotations.Intersmash; +import org.jboss.intersmash.tools.annotations.Service; +import org.jboss.intersmash.tools.annotations.ServiceUrl; +import org.junit.jupiter.api.Test; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Intersmash({ + @Service(SoapWildflyBootableOpenShiftJarApplication.class) +}) +public class SoapWildflyBootableOpenShiftJarTest { + @ServiceUrl(SoapWildflyBootableOpenShiftJarApplication.class) + private String appOpenShiftUrl; + + @Test + public void testPing() throws Exception { + URL baseURL = new URL(appOpenShiftUrl + "/EndpointServiceSERVICE"); + QName serviceName = new QName("http://org.jboss.ws/cxf/container", "EndpointServiceSERVICE"); + URL wsdlURL = new URL(baseURL + "?wsdl"); + jakarta.xml.ws.Service service = jakarta.xml.ws.Service.create(wsdlURL, serviceName); + + Endpoint proxy = service.getPort(Endpoint.class); + + BindingProvider bp = (BindingProvider) proxy; + bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toExternalForm()); + + String greeting = proxy.ping(); + Assertions.assertThat(greeting).contains("pong"); + } + + @Test + public void testGreet() throws Exception { + URL baseURL = new URL(appOpenShiftUrl + "/EndpointServiceSERVICE"); + QName serviceName = new QName("http://org.jboss.ws/cxf/container", "EndpointServiceSERVICE"); + URL wsdlURL = new URL(baseURL + "?wsdl"); + jakarta.xml.ws.Service service = jakarta.xml.ws.Service.create(wsdlURL, serviceName); + + Endpoint proxy = service.getPort(Endpoint.class); + + BindingProvider bp = (BindingProvider) proxy; + bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toExternalForm()); + + String greeting = proxy.greetings("Bob"); + Assertions.assertThat(greeting).contains("Bob, hello from WildFly"); + } +} diff --git a/demos/ws-bootable-jar-example/jaxws/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/demos/ws-bootable-jar-example/jaxws/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener new file mode 100644 index 000000000..63b7383d3 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/test/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -0,0 +1,2 @@ +cz.xtf.junit5.listeners.TestExecutionLogger +cz.xtf.junit5.listeners.ProjectCreator diff --git a/demos/ws-bootable-jar-example/jaxws/src/test/resources/logback.xml b/demos/ws-bootable-jar-example/jaxws/src/test/resources/logback.xml new file mode 100644 index 000000000..972f6d015 --- /dev/null +++ b/demos/ws-bootable-jar-example/jaxws/src/test/resources/logback.xml @@ -0,0 +1,59 @@ + + + + + + + ${console-log-level:-INFO} + + + [%d] %-5p- %m%n + + + + 300 + + + + + log/test.log + false + + DEBUG + + + [%d] %-5level [%thread]: %message%n + + + + 300 + + + + + log/everything.log + false + + [%d] %-5p- %m%n + + + + 300 + + + + + + + + + + + + + + + + + + diff --git a/demos/ws-bootable-jar-example/pom.xml b/demos/ws-bootable-jar-example/pom.xml new file mode 100644 index 000000000..aef709537 --- /dev/null +++ b/demos/ws-bootable-jar-example/pom.xml @@ -0,0 +1,282 @@ + + + 4.0.0 + + org.jboss.intersmash + intersmash-demos + 0.0.1-SNAPSHOT + ../pom.xml + + ws-bootable-jar-example + pom + + Intersmash Demos : (Wildfly): Webservices Bootable JAR Examples + + + jaxws + + + + 3.1.0 + 6.2.4.Final + 6.2.4.Final + + 1.0.5 + 10.0.0 + 4.0.0 + 3.1.0 + + 1.3 + + 4.0.0.Final + 3.3.2 + + 10.0.0.Final + + 29.0.1.Final + + + + + + com.fasterxml.jackson + jackson-bom + ${version.com.fasterxml.jackson} + import + pom + + + org.jboss.resteasy + resteasy-bom + ${version.resteasy-bom} + pom + import + + + org.jboss.resteasy + resteasy-client-api + ${version.resteasy-client-api} + + + org.eclipse.microprofile.config + microprofile-config-api + ${version.microprofile-config-api} + provided + + + jakarta.platform + jakarta.jakartaee-api + ${version.jakarta.jakartaee-api} + provided + + + jakarta.inject + jakarta.inject-api + ${version.jakarta.inject-api} + provided + + + jakarta.xml.ws + jakarta.xml.ws-api + ${version.jakarta.xml.ws-api} + + + io.fabric8 + generator-annotations + ${version.io.fabric8} + + + io.fabric8 + openshift-client + ${version.openshift-client} + + + + + + + jakarta.platform + jakarta.jakartaee-api + provided + + + + jakarta.inject + jakarta.inject-api + provided + + + jakarta.ws.rs + jakarta.ws.rs-api + ${version.jakarta.ws.rs-api} + provided + + + org.jboss.resteasy + resteasy-client + provided + + + org.jboss.resteasy + resteasy-client-api + provided + + + org.jboss.intersmash + intersmash-tools-core + ${project.version} + test + + + org.jboss.intersmash + intersmash-tools-provisioners + ${project.version} + test + + + cz.xtf + core + test + + + org.projectlombok + lombok + test + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + test + + + + org.jboss.intersmash + intersmash-deployments-provider + ${project.version} + test + + + io.fabric8 + generator-annotations + + + io.fabric8 + openshift-client + + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${version.maven-war-plugin} + + WEB-INF/lib/*.jar + ROOT + + + + process-classes + + war + + + + + + org.wildfly.plugins + wildfly-jar-maven-plugin + ${version.wildfly-jar-maven-plugin} + + + + + org.wildfly:wildfly-galleon-pack:${version.wildfly.feature-pack} + + + + cloud-server + webservices + + + + true + + + + + + + + + + bootable-jar-openshift + + + maven/bootable-jar-openshift + + + + + + + org.wildfly.plugins + wildfly-jar-maven-plugin + + + + + bootable-openshift + + ${project.build.finalName}-bootable-openshift.jar + + + + process-test-sources + + package + + + + + + + org.apache.maven.plugins + maven-install-plugin + + + install-bootable-jar-openshift + generate-test-resources + + install-file + + + ${project.groupId} + ${project.artifactId} + ${project.version} + jar + bootable-openshift + ${project.build.directory}/${project.build.finalName}-bootable-openshift.jar + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index a6b282396..82e6d1623 100644 --- a/pom.xml +++ b/pom.xml @@ -588,6 +588,15 @@ + + + demo + + demos + + + + redhat-ga-repository diff --git a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/HyperfoilOperatorProvisionerTest.java b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/HyperfoilOperatorProvisionerTest.java index 8470aefb4..1d15b7c64 100644 --- a/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/HyperfoilOperatorProvisionerTest.java +++ b/testsuite/src/test/java/org/jboss/intersmash/testsuite/provision/openshift/HyperfoilOperatorProvisionerTest.java @@ -63,8 +63,7 @@ public Hyperfoil getHyperfoil() { return new HyperfoilBuilder( getName(), // see https://github.com/Hyperfoil/hyperfoil-operator/issues/18, "latest" (default) would fail. - "0.24.2" - ).build(); + "0.24.2").build(); } @Override