diff --git a/.github/workflows/quickstart_spring-resteasy_ci.yml b/.github/workflows/quickstart_spring-resteasy_ci.yml new file mode 100644 index 0000000000..69d43fcdeb --- /dev/null +++ b/.github/workflows/quickstart_spring-resteasy_ci.yml @@ -0,0 +1,14 @@ +name: WildFly spring-resteasy Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'spring-resteasy/**' + - '.github/workflows/quickstart_ci.yml' +jobs: + call-quickstart_ci: + uses: ./.github/workflows/quickstart_ci.yml + with: + QUICKSTART_PATH: spring-resteasy + TEST_PROVISIONED_SERVER: true diff --git a/spring-resteasy/README.adoc b/spring-resteasy/README.adoc index 7fab5a0af3..c1fe81616b 100644 --- a/spring-resteasy/README.adoc +++ b/spring-resteasy/README.adoc @@ -24,8 +24,6 @@ The `spring-resteasy` quickstart demonstrates how to package and deploy a web ap // Product Release content only //************************************************* -ifndef::EAPCDRelease[] - // System Requirements include::../shared-doc/system-requirements.adoc[leveloffset=+1] // Use of {jbossHomeName} @@ -65,30 +63,13 @@ WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing opti WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause) ---- +// Server Distribution Testing +include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2] // Undeploy the Quickstart -include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1] -// Run the Arquillian Tests -include::../shared-doc/run-arquillian-tests.adoc[leveloffset=+1] -// Run the Quickstart in Red Hat CodeReady Studio or Eclipse -include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1] - -endif::[] - -//************************************************* -// Product Release content only -//************************************************* -ifdef::ProductRelease[] - -// Getting Started with OpenShift -include::../shared-doc/openshift-getting-started.adoc[leveloffset=+1] -//Prepare OpenShift for Quickstart Deployment -include::../shared-doc/openshift-create-project.adoc[leveloffset=+1] -// Import the Latest {xpaasproduct-shortname} Image Streams and Templates -include::../shared-doc/openshift-import-imagestreams-templates.adoc[leveloffset=+1] -// Deploy the {ProductShortName} Source-to-Image (S2I) Quickstart to OpenShift -include::../shared-doc/openshift-deploy-project.adoc[leveloffset=+1] -// Openshift post deployment tasks -include::../shared-doc/openshift-post-deployment-tasks.adoc[leveloffset=+1] - +include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+2] +// Build and run sections for other environments/builds +ifndef::ProductRelease,EAPXPRelease[] +include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] endif::[] +include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] diff --git a/spring-resteasy/charts/helm.yaml b/spring-resteasy/charts/helm.yaml new file mode 100644 index 0000000000..4d1d940e24 --- /dev/null +++ b/spring-resteasy/charts/helm.yaml @@ -0,0 +1,6 @@ +build: + uri: https://github.com/wildfly/quickstart.git + ref: main + contextDir: spring-resteasy +deploy: + replicas: 1 \ No newline at end of file diff --git a/spring-resteasy/pom.xml b/spring-resteasy/pom.xml index a5d7549f9c..dae703e309 100644 --- a/spring-resteasy/pom.xml +++ b/spring-resteasy/pom.xml @@ -48,9 +48,16 @@ 17 17 - + + 30.0.0.Final + + ${version.server} + 5.0.0.Final + 4.2.0.Final + + 6.0.4 - 30.0.0.Final + 3.0.4.Final @@ -114,7 +121,7 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import @@ -185,30 +192,79 @@ + + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + + + - - arq-managed - - - org.wildfly.arquillian - wildfly-arquillian-container-managed - test - - + provisioned-server - org.apache.maven.plugins - maven-failsafe-plugin - ${version.failsafe.plugin} + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + org.jboss.resteasy.spring + galleon-feature-pack + ${version.resteasy.spring} + + + + ROOT.war + - integration-test - verify + package + + + + + + + + + openshift + + + + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.pack.cloud} + + + + org.jboss.resteasy.spring + galleon-feature-pack + ${version.resteasy.spring} + + + ROOT.war + + + + + package @@ -217,22 +273,17 @@ - - arq-remote - - - org.wildfly.arquillian - wildfly-arquillian-container-remote - test - - + integration-testing org.apache.maven.plugins maven-failsafe-plugin - ${version.failsafe.plugin} + + + **/*IT + + diff --git a/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/BasicRuntimeIT.java b/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/BasicRuntimeIT.java new file mode 100644 index 0000000000..4b96e7d33c --- /dev/null +++ b/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/BasicRuntimeIT.java @@ -0,0 +1,61 @@ +/* + * Copyright 2023 JBoss by Red Hat. + * + * 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.as.quickstarts.resteasyspring.test; + +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * The very basic runtime integration testing. + * @author liweinan + */ +public class BasicRuntimeIT { + + private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy"; + + @Test + public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + final HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(serverHost+"/")) + .GET() + .build(); + final HttpClient client = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + assertTrue(response.body().toString().contains("Hello.")); + + } +} diff --git a/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/ResteasySpringIT.java b/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/ResteasySpringIT.java index 20f14379be..354f26940a 100644 --- a/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/ResteasySpringIT.java +++ b/spring-resteasy/src/test/java/org/jboss/as/quickstarts/resteasyspring/test/ResteasySpringIT.java @@ -16,6 +16,7 @@ */ package org.jboss.as.quickstarts.resteasyspring.test; +import java.net.MalformedURLException; import java.net.URI; import java.net.URL; @@ -29,47 +30,31 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.container.test.api.RunAsClient; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.arquillian.test.api.ArquillianResource; -import org.jboss.as.quickstarts.resteasyspring.GreetingBean; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.jboss.shrinkwrap.resolver.api.maven.Maven; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; /** * Basic unit tests for resteasy spring integration */ -@RunWith(Arquillian.class) -@RunAsClient public class ResteasySpringIT { - @Deployment - public static WebArchive getDeployment() { - return ShrinkWrap.create(WebArchive.class, "spring-resteasy.war") - .addPackages(true, GreetingBean.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .addAsWebInfResource("web.xml") - .addAsWebInfResource("applicationContext.xml") - .addAsWebInfResource("jboss-deployment-structure.xml") - .addAsLibraries(Maven.configureResolver() - .loadPomFromFile("pom.xml") - .resolve( - "org.springframework:spring-core", - "org.springframework:spring-web", - "org.springframework:spring-context", - "org.springframework:spring-beans" - ) - .withTransitivity().asFile()); - } - @ArquillianResource - URL url; + static URL url; + + private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy"; + + @BeforeClass + public static void setupUrl() throws MalformedURLException { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + url = new URL(serverHost); + } @Test public void testHelloSpringResource() throws Exception { @@ -79,7 +64,7 @@ public void testHelloSpringResource() throws Exception { .setScheme("http") .setHost(url.getHost()) .setPort(url.getPort()) - .setPath(url.getPath() + "hello") + .setPath(url.getPath() + "/hello") .setParameter("name", "JBoss Developer") .build(); HttpGet method = new HttpGet(uri); @@ -91,7 +76,7 @@ public void testHelloSpringResource() throws Exception { } } { - HttpGet method = new HttpGet(url.toString() + "basic"); + HttpGet method = new HttpGet(url.toString() + "/basic"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("basic")); @@ -100,7 +85,7 @@ public void testHelloSpringResource() throws Exception { } } { - HttpPut method = new HttpPut(url.toString() + "basic"); + HttpPut method = new HttpPut(url.toString() + "/basic"); method.setEntity(new StringEntity("basic", ContentType.TEXT_PLAIN)); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode()); @@ -125,19 +110,19 @@ public void testHelloSpringResource() throws Exception { } } { - HttpGet method = new HttpGet(url.toString() + "matrixParam;param=matrix"); + HttpGet method = new HttpGet(url.toString() + "/matrixParam;param=matrix"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); - Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("matrix")); + Assert.assertEquals("matrix", EntityUtils.toString(response.getEntity())); } finally { method.releaseConnection(); } } { - HttpGet method = new HttpGet(url.toString() + "uriParam/1234"); + HttpGet method = new HttpGet(url.toString() + "/uriParam/1234"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); - Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("1234")); + Assert.assertEquals("1234", EntityUtils.toString(response.getEntity())); } finally { method.releaseConnection(); } @@ -153,7 +138,7 @@ public void testLocatingResource() throws Exception { .setScheme("http") .setHost(url.getHost()) .setPort(url.getPort()) - .setPath(url.getPath() + "locating/hello") + .setPath(url.getPath() + "/locating/hello") .setParameter("name", "JBoss Developer") .build(); HttpGet method = new HttpGet(uri); @@ -165,7 +150,7 @@ public void testLocatingResource() throws Exception { } } { - HttpGet method = new HttpGet(url.toString() + "locating/basic"); + HttpGet method = new HttpGet(url.toString() + "/locating/basic"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertTrue(EntityUtils.toString(response.getEntity()).contains("basic")); @@ -174,7 +159,7 @@ public void testLocatingResource() throws Exception { } } { - HttpPut method = new HttpPut(url.toString() + "locating/basic"); + HttpPut method = new HttpPut(url.toString() + "/locating/basic"); method.setEntity(new StringEntity("basic", ContentType.TEXT_PLAIN)); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatusLine().getStatusCode()); @@ -187,7 +172,7 @@ public void testLocatingResource() throws Exception { .setScheme("http") .setHost(url.getHost()) .setPort(url.getPort()) - .setPath(url.getPath() + "locating/queryParam") + .setPath(url.getPath() + "/locating/queryParam") .setParameter("param", "hello world") .build(); HttpGet method = new HttpGet(uri); @@ -199,19 +184,19 @@ public void testLocatingResource() throws Exception { } } { - HttpGet method = new HttpGet(url.toString() + "locating/matrixParam;param=matrix"); + HttpGet method = new HttpGet(url.toString() + "/locating/matrixParam;param=matrix"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); - Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("matrix")); + Assert.assertEquals("matrix", EntityUtils.toString(response.getEntity())); } finally { method.releaseConnection(); } } { - HttpGet method = new HttpGet(url.toString() + "locating/uriParam/1234"); + HttpGet method = new HttpGet(url.toString() + "/locating/uriParam/1234"); try (CloseableHttpResponse response = client.execute(method)) { Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); - Assert.assertTrue(EntityUtils.toString(response.getEntity()).equals("1234")); + Assert.assertEquals("1234", EntityUtils.toString(response.getEntity())); } finally { method.releaseConnection(); }