From 7f50307899907b6b9f69787d3e9d99e1984da125 Mon Sep 17 00:00:00 2001 From: HaoZhang Date: Tue, 9 Dec 2025 19:51:15 +0800 Subject: [PATCH 1/2] improve JBoss EAP detection Signed-off-by: HaoZhang --- .../framework/java/jboss_eap_detector.go | 19 +- .../pom.xml | 2 +- .../quickstarts/helloworld/HelloService.java | 0 .../helloworld/HelloWorldServlet.java | 0 .../src/main/webapp/WEB-INF/beans.xml | 0 .../src/main/webapp/index.html | 0 .../helloworld/HelloWorldServletIT.java | 0 .../managed/ManagedHelloWorldServletIT.java | 0 .../src/test/resources/arquillian.xml | 0 .../pom.xml | 242 ++++++++++++++++++ .../quickstarts/helloworld/HelloService.java | 31 +++ .../helloworld/HelloWorldServlet.java | 63 +++++ .../src/main/webapp/WEB-INF/beans.xml | 23 ++ .../src/main/webapp/index.html | 23 ++ .../helloworld/HelloWorldServletIT.java | 84 ++++++ .../managed/ManagedHelloWorldServletIT.java | 46 ++++ .../src/test/resources/arquillian.xml | 23 ++ .../jboss-eap-by-jboss-eap-jakartaee8/pom.xml | 242 ++++++++++++++++++ .../quickstarts/helloworld/HelloService.java | 31 +++ .../helloworld/HelloWorldServlet.java | 63 +++++ .../src/main/webapp/WEB-INF/beans.xml | 23 ++ .../src/main/webapp/index.html | 23 ++ .../helloworld/HelloWorldServletIT.java | 84 ++++++ .../managed/ManagedHelloWorldServletIT.java | 46 ++++ .../src/test/resources/arquillian.xml | 23 ++ .../jboss-eap-by-jboss-eap-javaee7/pom.xml | 242 ++++++++++++++++++ .../quickstarts/helloworld/HelloService.java | 31 +++ .../helloworld/HelloWorldServlet.java | 63 +++++ .../src/main/webapp/WEB-INF/beans.xml | 23 ++ .../src/main/webapp/index.html | 23 ++ .../helloworld/HelloWorldServletIT.java | 84 ++++++ .../managed/ManagedHelloWorldServletIT.java | 46 ++++ .../src/test/resources/arquillian.xml | 23 ++ .../jboss-eap-by-jboss-eap-javaee8/pom.xml | 242 ++++++++++++++++++ .../quickstarts/helloworld/HelloService.java | 31 +++ .../helloworld/HelloWorldServlet.java | 63 +++++ .../src/main/webapp/WEB-INF/beans.xml | 23 ++ .../src/main/webapp/index.html | 23 ++ .../helloworld/HelloWorldServletIT.java | 84 ++++++ .../managed/ManagedHelloWorldServletIT.java | 46 ++++ .../src/test/resources/arquillian.xml | 23 ++ .../jboss-eap-by-jboss-javaee-6.0/pom.xml | 242 ++++++++++++++++++ .../quickstarts/helloworld/HelloService.java | 31 +++ .../helloworld/HelloWorldServlet.java | 63 +++++ .../src/main/webapp/WEB-INF/beans.xml | 23 ++ .../src/main/webapp/index.html | 23 ++ .../helloworld/HelloWorldServletIT.java | 84 ++++++ .../managed/ManagedHelloWorldServletIT.java | 46 ++++ .../src/test/resources/arquillian.xml | 23 ++ test/apis/component_recognizer_test.go | 28 +- 50 files changed, 2717 insertions(+), 7 deletions(-) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/pom.xml (99%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/main/webapp/WEB-INF/beans.xml (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/main/webapp/index.html (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java (100%) rename resources/projects/{jboss-eap => jboss-eap-by-eap-maven-plugin}/src/test/resources/arquillian.xml (100%) create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/pom.xml create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/WEB-INF/beans.xml create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/index.html create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/resources/arquillian.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/pom.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/WEB-INF/beans.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/index.html create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/resources/arquillian.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/pom.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/WEB-INF/beans.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/index.html create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/resources/arquillian.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/pom.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/WEB-INF/beans.xml create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/index.html create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/resources/arquillian.xml create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/pom.xml create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/WEB-INF/beans.xml create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/index.html create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java create mode 100644 resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/resources/arquillian.xml diff --git a/pkg/apis/enricher/framework/java/jboss_eap_detector.go b/pkg/apis/enricher/framework/java/jboss_eap_detector.go index 680e6ee1..f894d722 100644 --- a/pkg/apis/enricher/framework/java/jboss_eap_detector.go +++ b/pkg/apis/enricher/framework/java/jboss_eap_detector.go @@ -39,8 +39,23 @@ func (o JBossEAPDetector) GetApplicationFileInfos(componentPath string, ctx *con // DoFrameworkDetection uses the groupId and artifactId to check for the framework name func (o JBossEAPDetector) DoFrameworkDetection(language *model.Language, config string) { - if hasFwk, _ := hasFramework(config, "org.jboss.eap.plugins", "eap-maven-plugin"); hasFwk { - language.Frameworks = append(language.Frameworks, "JBoss EAP") + jbossEapClues := []struct { + GroupId string + ArtifactId string + }{ + {"org.jboss.eap.plugins", "eap-maven-plugin"}, + {"org.jboss.bom", "eap-runtime-artifacts"}, + {"org.jboss.bom", "jboss-eap-jakartaee8"}, + {"org.jboss.bom", "jboss-eap-javaee8"}, + {"org.jboss.bom", "jboss-eap-javaee7"}, + {"org.jboss.bom.eap", "jboss-javaee-6.0"}, + } + + for _, clue := range jbossEapClues { + if hasFwk, _ := hasFramework(config, clue.GroupId, clue.ArtifactId); hasFwk { + language.Frameworks = append(language.Frameworks, "JBoss EAP") + break + } } } diff --git a/resources/projects/jboss-eap/pom.xml b/resources/projects/jboss-eap-by-eap-maven-plugin/pom.xml similarity index 99% rename from resources/projects/jboss-eap/pom.xml rename to resources/projects/jboss-eap-by-eap-maven-plugin/pom.xml index f0d6f939..46603643 100644 --- a/resources/projects/jboss-eap/pom.xml +++ b/resources/projects/jboss-eap-by-eap-maven-plugin/pom.xml @@ -28,7 +28,7 @@ 1.0.0.redhat-00001 - jboss-eap + jboss-eap-by-eap-maven-plugin 8.0.0.Beta war jboss-eap diff --git a/resources/projects/jboss-eap/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-eap-maven-plugin/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java similarity index 100% rename from resources/projects/jboss-eap/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java diff --git a/resources/projects/jboss-eap/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-eap-maven-plugin/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java similarity index 100% rename from resources/projects/jboss-eap/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java diff --git a/resources/projects/jboss-eap/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-eap-maven-plugin/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from resources/projects/jboss-eap/src/main/webapp/WEB-INF/beans.xml rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/main/webapp/WEB-INF/beans.xml diff --git a/resources/projects/jboss-eap/src/main/webapp/index.html b/resources/projects/jboss-eap-by-eap-maven-plugin/src/main/webapp/index.html similarity index 100% rename from resources/projects/jboss-eap/src/main/webapp/index.html rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/main/webapp/index.html diff --git a/resources/projects/jboss-eap/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-eap-maven-plugin/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java similarity index 100% rename from resources/projects/jboss-eap/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java diff --git a/resources/projects/jboss-eap/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-eap-maven-plugin/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java similarity index 100% rename from resources/projects/jboss-eap/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java diff --git a/resources/projects/jboss-eap/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-eap-maven-plugin/src/test/resources/arquillian.xml similarity index 100% rename from resources/projects/jboss-eap/src/test/resources/arquillian.xml rename to resources/projects/jboss-eap-by-eap-maven-plugin/src/test/resources/arquillian.xml diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/pom.xml b/resources/projects/jboss-eap-by-eap-runtime-artifacts/pom.xml new file mode 100644 index 00000000..15c0e223 --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/pom.xml @@ -0,0 +1,242 @@ + + + + 4.0.0 + + org.jboss.eap.quickstarts + jboss-eap-quickstart-parent + + 1.0.0.redhat-00001 + + + jboss-eap-by-eap-runtime-artifacts + 8.0.0.Beta + war + jboss-eap + jboss-eap + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + 8.0.0.Beta-redhat-00004 + 1.0.0.Beta6-redhat-00001 + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + never + + + true + never + + default + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + never + + + true + never + + default + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + true + never + + default + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + + + true + + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + + + true + + + + + + + + + org.jboss.bom + jboss-eap-ee-with-tools + ${version.server.bom} + pom + import + + + org.jboss.bom + eap-runtime-artifacts + 7.4.0.GA + pom + import + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + jar + + + org.jboss.arquillian.container + arquillian-container-test-api + test + jar + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + test + + + org.wildfly.arquillian + wildfly-arquillian-common + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + test + + + + + + arq-remote + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.failsafe.plugin} + + + **/HelloWorldServletIT + + + **/managed/* + + + + + + integration-test + + + + + + + + + + diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java new file mode 100644 index 00000000..28918dd8 --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +/** + * A simple CDI service which is able to say hello to someone + * + * @author Pete Muir + * + */ +public class HelloService { + + String createHelloMessage(String name) { + return "Hello " + name + "!"; + } + +} diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java new file mode 100644 index 00000000..3246685a --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.inject.Inject; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet + * @HttpServlet}. The {@link HelloService} is injected by CDI. + *

+ * + * @author Pete Muir + * + */ +@SuppressWarnings("serial") +@WebServlet("/HelloWorld") +public class HelloWorldServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Inject + HelloService helloService; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

" + helloService.createHelloMessage("World") + "

"); + writer.println(PAGE_FOOTER); + writer.close(); + } + +} diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 00000000..4b8daeb2 --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,23 @@ + + + + diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/index.html b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/index.html new file mode 100644 index 00000000..eb15de32 --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/main/webapp/index.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java new file mode 100644 index 00000000..39507d19 --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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.helloworld; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import java.util.Optional; +import org.junit.Test; + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +public class HelloWorldServletIT { + + protected URI getHTTPEndpoint() { + String host = getServerHost(); + if (host == null) { + host = "http://localhost:8080/helloworld"; + } + try { + return new URI(host + "/HelloWorld"); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } + } + + private String getServerHost() { + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } + return host; + } + + @Test + public void testHelloWorld() throws IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .followRedirects(Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + HttpRequest request = HttpRequest.newBuilder() + .uri(getHTTPEndpoint()) + .GET() + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + Optional contentType = response.headers().firstValue("Content-Type"); + assertTrue(contentType.isPresent()); + assertEquals("text/html;charset=ISO-8859-1", contentType.get()); + String[] content = response.body().split(getLineSeparator()); + assertEquals(3, content.length); + assertEquals("helloworld", content[0].trim()); + assertEquals("

Hello World!

", content[1].trim()); + assertEquals("", content[2].trim()); + } + + protected String getLineSeparator() { + return"\n"; + } +} diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java new file mode 100644 index 00000000..d03fef8c --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.helloworld.managed; + +import java.net.URI; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ContainerResource; +import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.as.quickstarts.helloworld.HelloWorldServletIT; +import org.junit.runner.RunWith; + + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +@RunWith(Arquillian.class) +@RunAsClient +public class ManagedHelloWorldServletIT extends HelloWorldServletIT { + @ContainerResource + private ManagementClient managementClient; + + @Override + protected URI getHTTPEndpoint() { + return managementClient.getWebUri().resolve("/HelloWorld"); + } + + @Override + protected String getLineSeparator() { + return System.lineSeparator(); + } +} diff --git a/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/resources/arquillian.xml new file mode 100644 index 00000000..31d4c3cc --- /dev/null +++ b/resources/projects/jboss-eap-by-eap-runtime-artifacts/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/pom.xml b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/pom.xml new file mode 100644 index 00000000..102e8216 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/pom.xml @@ -0,0 +1,242 @@ + + + + 4.0.0 + + org.jboss.eap.quickstarts + jboss-eap-quickstart-parent + + 1.0.0.redhat-00001 + + + jboss-eap-by-jboss-eap-jakartaee8 + 8.0.0.Beta + war + jboss-eap + jboss-eap + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + 8.0.0.Beta-redhat-00004 + 1.0.0.Beta6-redhat-00001 + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + never + + + true + never + + default + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + never + + + true + never + + default + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + true + never + + default + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + + + true + + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + + + true + + + + + + + + + org.jboss.bom + jboss-eap-ee-with-tools + ${version.server.bom} + pom + import + + + org.jboss.bom + jboss-eap-jakartaee8 + 7.3.0.GA + pom + import + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + jar + + + org.jboss.arquillian.container + arquillian-container-test-api + test + jar + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + test + + + org.wildfly.arquillian + wildfly-arquillian-common + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + test + + + + + + arq-remote + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.failsafe.plugin} + + + **/HelloWorldServletIT + + + **/managed/* + + + + + + integration-test + + + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java new file mode 100644 index 00000000..28918dd8 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +/** + * A simple CDI service which is able to say hello to someone + * + * @author Pete Muir + * + */ +public class HelloService { + + String createHelloMessage(String name) { + return "Hello " + name + "!"; + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java new file mode 100644 index 00000000..3246685a --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.inject.Inject; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet + * @HttpServlet}. The {@link HelloService} is injected by CDI. + *

+ * + * @author Pete Muir + * + */ +@SuppressWarnings("serial") +@WebServlet("/HelloWorld") +public class HelloWorldServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Inject + HelloService helloService; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

" + helloService.createHelloMessage("World") + "

"); + writer.println(PAGE_FOOTER); + writer.close(); + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 00000000..4b8daeb2 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,23 @@ + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/index.html b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/index.html new file mode 100644 index 00000000..eb15de32 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/main/webapp/index.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java new file mode 100644 index 00000000..39507d19 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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.helloworld; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import java.util.Optional; +import org.junit.Test; + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +public class HelloWorldServletIT { + + protected URI getHTTPEndpoint() { + String host = getServerHost(); + if (host == null) { + host = "http://localhost:8080/helloworld"; + } + try { + return new URI(host + "/HelloWorld"); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } + } + + private String getServerHost() { + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } + return host; + } + + @Test + public void testHelloWorld() throws IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .followRedirects(Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + HttpRequest request = HttpRequest.newBuilder() + .uri(getHTTPEndpoint()) + .GET() + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + Optional contentType = response.headers().firstValue("Content-Type"); + assertTrue(contentType.isPresent()); + assertEquals("text/html;charset=ISO-8859-1", contentType.get()); + String[] content = response.body().split(getLineSeparator()); + assertEquals(3, content.length); + assertEquals("helloworld", content[0].trim()); + assertEquals("

Hello World!

", content[1].trim()); + assertEquals("", content[2].trim()); + } + + protected String getLineSeparator() { + return"\n"; + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java new file mode 100644 index 00000000..d03fef8c --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.helloworld.managed; + +import java.net.URI; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ContainerResource; +import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.as.quickstarts.helloworld.HelloWorldServletIT; +import org.junit.runner.RunWith; + + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +@RunWith(Arquillian.class) +@RunAsClient +public class ManagedHelloWorldServletIT extends HelloWorldServletIT { + @ContainerResource + private ManagementClient managementClient; + + @Override + protected URI getHTTPEndpoint() { + return managementClient.getWebUri().resolve("/HelloWorld"); + } + + @Override + protected String getLineSeparator() { + return System.lineSeparator(); + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/resources/arquillian.xml new file mode 100644 index 00000000..31d4c3cc --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-jakartaee8/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/pom.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee7/pom.xml new file mode 100644 index 00000000..1a88a15a --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/pom.xml @@ -0,0 +1,242 @@ + + + + 4.0.0 + + org.jboss.eap.quickstarts + jboss-eap-quickstart-parent + + 1.0.0.redhat-00001 + + + jboss-eap-by-jboss-eap-javaee7 + 8.0.0.Beta + war + jboss-eap + jboss-eap + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + 8.0.0.Beta-redhat-00004 + 1.0.0.Beta6-redhat-00001 + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + never + + + true + never + + default + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + never + + + true + never + + default + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + true + never + + default + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + + + true + + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + + + true + + + + + + + + + org.jboss.bom + jboss-eap-ee-with-tools + ${version.server.bom} + pom + import + + + org.jboss.bom + jboss-eap-javaee8 + 7.2.0.GA + pom + import + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + jar + + + org.jboss.arquillian.container + arquillian-container-test-api + test + jar + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + test + + + org.wildfly.arquillian + wildfly-arquillian-common + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + test + + + + + + arq-remote + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.failsafe.plugin} + + + **/HelloWorldServletIT + + + **/managed/* + + + + + + integration-test + + + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java new file mode 100644 index 00000000..28918dd8 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +/** + * A simple CDI service which is able to say hello to someone + * + * @author Pete Muir + * + */ +public class HelloService { + + String createHelloMessage(String name) { + return "Hello " + name + "!"; + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java new file mode 100644 index 00000000..3246685a --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.inject.Inject; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet + * @HttpServlet}. The {@link HelloService} is injected by CDI. + *

+ * + * @author Pete Muir + * + */ +@SuppressWarnings("serial") +@WebServlet("/HelloWorld") +public class HelloWorldServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Inject + HelloService helloService; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

" + helloService.createHelloMessage("World") + "

"); + writer.println(PAGE_FOOTER); + writer.close(); + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 00000000..4b8daeb2 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,23 @@ + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/index.html b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/index.html new file mode 100644 index 00000000..eb15de32 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/main/webapp/index.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java new file mode 100644 index 00000000..39507d19 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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.helloworld; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import java.util.Optional; +import org.junit.Test; + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +public class HelloWorldServletIT { + + protected URI getHTTPEndpoint() { + String host = getServerHost(); + if (host == null) { + host = "http://localhost:8080/helloworld"; + } + try { + return new URI(host + "/HelloWorld"); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } + } + + private String getServerHost() { + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } + return host; + } + + @Test + public void testHelloWorld() throws IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .followRedirects(Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + HttpRequest request = HttpRequest.newBuilder() + .uri(getHTTPEndpoint()) + .GET() + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + Optional contentType = response.headers().firstValue("Content-Type"); + assertTrue(contentType.isPresent()); + assertEquals("text/html;charset=ISO-8859-1", contentType.get()); + String[] content = response.body().split(getLineSeparator()); + assertEquals(3, content.length); + assertEquals("helloworld", content[0].trim()); + assertEquals("

Hello World!

", content[1].trim()); + assertEquals("", content[2].trim()); + } + + protected String getLineSeparator() { + return"\n"; + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java new file mode 100644 index 00000000..d03fef8c --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.helloworld.managed; + +import java.net.URI; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ContainerResource; +import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.as.quickstarts.helloworld.HelloWorldServletIT; +import org.junit.runner.RunWith; + + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +@RunWith(Arquillian.class) +@RunAsClient +public class ManagedHelloWorldServletIT extends HelloWorldServletIT { + @ContainerResource + private ManagementClient managementClient; + + @Override + protected URI getHTTPEndpoint() { + return managementClient.getWebUri().resolve("/HelloWorld"); + } + + @Override + protected String getLineSeparator() { + return System.lineSeparator(); + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/resources/arquillian.xml new file mode 100644 index 00000000..31d4c3cc --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee7/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/pom.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee8/pom.xml new file mode 100644 index 00000000..ecf0ead9 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/pom.xml @@ -0,0 +1,242 @@ + + + + 4.0.0 + + org.jboss.eap.quickstarts + jboss-eap-quickstart-parent + + 1.0.0.redhat-00001 + + + jboss-eap-by-jboss-eap-javaee8 + 8.0.0.Beta + war + jboss-eap + jboss-eap + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + 8.0.0.Beta-redhat-00004 + 1.0.0.Beta6-redhat-00001 + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + never + + + true + never + + default + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + never + + + true + never + + default + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + true + never + + default + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + + + true + + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + + + true + + + + + + + + + org.jboss.bom + jboss-eap-ee-with-tools + ${version.server.bom} + pom + import + + + org.jboss.bom + jboss-eap-javaee7 + 7.0.0.GA + pom + import + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + jar + + + org.jboss.arquillian.container + arquillian-container-test-api + test + jar + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + test + + + org.wildfly.arquillian + wildfly-arquillian-common + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + test + + + + + + arq-remote + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.failsafe.plugin} + + + **/HelloWorldServletIT + + + **/managed/* + + + + + + integration-test + + + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java new file mode 100644 index 00000000..28918dd8 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +/** + * A simple CDI service which is able to say hello to someone + * + * @author Pete Muir + * + */ +public class HelloService { + + String createHelloMessage(String name) { + return "Hello " + name + "!"; + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java new file mode 100644 index 00000000..3246685a --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.inject.Inject; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet + * @HttpServlet}. The {@link HelloService} is injected by CDI. + *

+ * + * @author Pete Muir + * + */ +@SuppressWarnings("serial") +@WebServlet("/HelloWorld") +public class HelloWorldServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Inject + HelloService helloService; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

" + helloService.createHelloMessage("World") + "

"); + writer.println(PAGE_FOOTER); + writer.close(); + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 00000000..4b8daeb2 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,23 @@ + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/index.html b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/index.html new file mode 100644 index 00000000..eb15de32 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/main/webapp/index.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java new file mode 100644 index 00000000..39507d19 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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.helloworld; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import java.util.Optional; +import org.junit.Test; + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +public class HelloWorldServletIT { + + protected URI getHTTPEndpoint() { + String host = getServerHost(); + if (host == null) { + host = "http://localhost:8080/helloworld"; + } + try { + return new URI(host + "/HelloWorld"); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } + } + + private String getServerHost() { + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } + return host; + } + + @Test + public void testHelloWorld() throws IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .followRedirects(Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + HttpRequest request = HttpRequest.newBuilder() + .uri(getHTTPEndpoint()) + .GET() + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + Optional contentType = response.headers().firstValue("Content-Type"); + assertTrue(contentType.isPresent()); + assertEquals("text/html;charset=ISO-8859-1", contentType.get()); + String[] content = response.body().split(getLineSeparator()); + assertEquals(3, content.length); + assertEquals("helloworld", content[0].trim()); + assertEquals("

Hello World!

", content[1].trim()); + assertEquals("", content[2].trim()); + } + + protected String getLineSeparator() { + return"\n"; + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java new file mode 100644 index 00000000..d03fef8c --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.helloworld.managed; + +import java.net.URI; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ContainerResource; +import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.as.quickstarts.helloworld.HelloWorldServletIT; +import org.junit.runner.RunWith; + + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +@RunWith(Arquillian.class) +@RunAsClient +public class ManagedHelloWorldServletIT extends HelloWorldServletIT { + @ContainerResource + private ManagementClient managementClient; + + @Override + protected URI getHTTPEndpoint() { + return managementClient.getWebUri().resolve("/HelloWorld"); + } + + @Override + protected String getLineSeparator() { + return System.lineSeparator(); + } +} diff --git a/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/resources/arquillian.xml new file mode 100644 index 00000000..31d4c3cc --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-eap-javaee8/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/pom.xml b/resources/projects/jboss-eap-by-jboss-javaee-6.0/pom.xml new file mode 100644 index 00000000..4308ae58 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/pom.xml @@ -0,0 +1,242 @@ + + + + 4.0.0 + + org.jboss.eap.quickstarts + jboss-eap-quickstart-parent + + 1.0.0.redhat-00001 + + + jboss-eap-by-jboss-javaee-6.0 + 8.0.0.Beta + war + jboss-eap + jboss-eap + + + + Apache License, Version 2.0 + repo + http://www.apache.org/licenses/LICENSE-2.0.html + + + + + + 8.0.0.Beta-redhat-00004 + 1.0.0.Beta6-redhat-00001 + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + never + + + true + never + + default + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + never + + + true + never + + default + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + never + + + true + never + + default + + + + + + jboss-public-maven-repository + JBoss Public Maven Repository + https://repository.jboss.org/nexus/content/groups/public/ + + true + + + true + + + + redhat-ga-maven-repository + Red Hat GA Maven Repository + https://maven.repository.redhat.com/ga/ + + true + + + true + + + + redhat-ea-maven-repository + Red Hat Early Access Maven Repository + https://maven.repository.redhat.com/earlyaccess/all/ + + true + + + true + + + + + + + + + org.jboss.bom + jboss-eap-ee-with-tools + ${version.server.bom} + pom + import + + + org.jboss.bom.eap + jboss-javaee-6.0-with-hibernate + 6.4.0.GA + pom + import + + + + + + + + + jakarta.enterprise + jakarta.enterprise.cdi-api + provided + + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + jar + + + org.jboss.arquillian.container + arquillian-container-test-api + test + jar + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + test + + + org.wildfly.arquillian + wildfly-arquillian-common + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + test + + + + + + arq-remote + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version.failsafe.plugin} + + + **/HelloWorldServletIT + + + **/managed/* + + + + + + integration-test + + + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java new file mode 100644 index 00000000..28918dd8 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java @@ -0,0 +1,31 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +/** + * A simple CDI service which is able to say hello to someone + * + * @author Pete Muir + * + */ +public class HelloService { + + String createHelloMessage(String name) { + return "Hello " + name + "!"; + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java new file mode 100644 index 00000000..3246685a --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual + * contributors by the @authors tag. See the copyright.txt in the + * distribution for a full listing of individual contributors. + * + * 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.helloworld; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.inject.Inject; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet + * @HttpServlet}. The {@link HelloService} is injected by CDI. + *

+ * + * @author Pete Muir + * + */ +@SuppressWarnings("serial") +@WebServlet("/HelloWorld") +public class HelloWorldServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Inject + HelloService helloService; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

" + helloService.createHelloMessage("World") + "

"); + writer.println(PAGE_FOOTER); + writer.close(); + } + +} diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/WEB-INF/beans.xml b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 00000000..4b8daeb2 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,23 @@ + + + + diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/index.html b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/index.html new file mode 100644 index 00000000..eb15de32 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/main/webapp/index.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java new file mode 100644 index 00000000..39507d19 --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/HelloWorldServletIT.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 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.helloworld; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpClient.Redirect; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.time.Duration; +import java.util.Optional; +import org.junit.Test; + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +public class HelloWorldServletIT { + + protected URI getHTTPEndpoint() { + String host = getServerHost(); + if (host == null) { + host = "http://localhost:8080/helloworld"; + } + try { + return new URI(host + "/HelloWorld"); + } catch (URISyntaxException ex) { + throw new RuntimeException(ex); + } + } + + private String getServerHost() { + String host = System.getenv("SERVER_HOST"); + if (host == null) { + host = System.getProperty("server.host"); + } + return host; + } + + @Test + public void testHelloWorld() throws IOException, InterruptedException { + HttpClient client = HttpClient.newBuilder() + .followRedirects(Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + HttpRequest request = HttpRequest.newBuilder() + .uri(getHTTPEndpoint()) + .GET() + .build(); + HttpResponse response = client.send(request, BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + Optional contentType = response.headers().firstValue("Content-Type"); + assertTrue(contentType.isPresent()); + assertEquals("text/html;charset=ISO-8859-1", contentType.get()); + String[] content = response.body().split(getLineSeparator()); + assertEquals(3, content.length); + assertEquals("helloworld", content[0].trim()); + assertEquals("

Hello World!

", content[1].trim()); + assertEquals("", content[2].trim()); + } + + protected String getLineSeparator() { + return"\n"; + } +} diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java new file mode 100644 index 00000000..d03fef8c --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/java/org/jboss/as/quickstarts/helloworld/managed/ManagedHelloWorldServletIT.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.helloworld.managed; + +import java.net.URI; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ContainerResource; +import org.jboss.as.arquillian.container.ManagementClient; +import org.jboss.as.quickstarts.helloworld.HelloWorldServletIT; +import org.junit.runner.RunWith; + + +/** + * + * @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc. + */ +@RunWith(Arquillian.class) +@RunAsClient +public class ManagedHelloWorldServletIT extends HelloWorldServletIT { + @ContainerResource + private ManagementClient managementClient; + + @Override + protected URI getHTTPEndpoint() { + return managementClient.getWebUri().resolve("/HelloWorld"); + } + + @Override + protected String getLineSeparator() { + return System.lineSeparator(); + } +} diff --git a/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/resources/arquillian.xml b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/resources/arquillian.xml new file mode 100644 index 00000000..31d4c3cc --- /dev/null +++ b/resources/projects/jboss-eap-by-jboss-javaee-6.0/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/test/apis/component_recognizer_test.go b/test/apis/component_recognizer_test.go index bee75fc8..12b2ddbf 100644 --- a/test/apis/component_recognizer_test.go +++ b/test/apis/component_recognizer_test.go @@ -92,8 +92,28 @@ func TestPortDetectionGoFiber(t *testing.T) { } // component detection: java -func TestComponentDetectionOnJBossEAP(t *testing.T) { - isComponentsInProject(t, "jboss-eap", 1, "java", "jboss-eap") +func TestComponentDetectionOnJBossEAPByEAPMavenPlugin(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-eap-maven-plugin", 1, "java", "jboss-eap-by-eap-maven-plugin") +} + +func TestComponentDetectionOnJBossEAPByEAPRuntimeArtifacts(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-eap-runtime-artifacts", 1, "java", "jboss-eap-by-eap-runtime-artifacts") +} + +func TestComponentDetectionOnJBossEAPByJBossEAPJakartaee8(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-jboss-eap-jakartaee8", 1, "java", "jboss-eap-by-jboss-eap-jakartaee8") +} + +func TestComponentDetectionOnJBossEAPByJBossEAPJavaee8(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-jboss-eap-javaee8", 1, "java", "jboss-eap-by-jboss-eap-javaee8") +} + +func TestComponentDetectionOnJBossEAPByJBossEAPJavaee7(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-jboss-eap-javaee7", 1, "java", "jboss-eap-by-jboss-eap-javaee7") +} + +func TestComponentDetectionOnJBossEAPByJBossJavaee6(t *testing.T) { + isComponentsInProject(t, "jboss-eap-by-jboss-javaee-6.0", 1, "java", "jboss-eap-by-jboss-javaee-6.0") } func TestComponentDetectionOnMicronaut(t *testing.T) { @@ -122,7 +142,7 @@ func TestComponentDetectionOnWildFly(t *testing.T) { // port detection: java func TestPortDetectionJavaJBossEAP(t *testing.T) { - testPortDetectionInProject(t, "jboss-eap", []int{8380}) + testPortDetectionInProject(t, "jboss-eap-by-eap-maven-plugin", []int{8380}) } func TestPortDetectionJavaMicronaut(t *testing.T) { @@ -419,7 +439,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) { func TestComponentDetectionMultiProjects(t *testing.T) { components := getComponentsFromTestProject(t, "") - nComps := 70 + nComps := 76 if len(components) != nComps { t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components))) } From 51c2b441df20f78b76f21aa4091713a58a774672 Mon Sep 17 00:00:00 2001 From: HaoZhang Date: Tue, 9 Dec 2025 20:04:20 +0800 Subject: [PATCH 2/2] fix conflict Signed-off-by: HaoZhang --- test/apis/component_recognizer_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/apis/component_recognizer_test.go b/test/apis/component_recognizer_test.go index 12b2ddbf..f8d8a6ca 100644 --- a/test/apis/component_recognizer_test.go +++ b/test/apis/component_recognizer_test.go @@ -132,6 +132,10 @@ func TestComponentDetectionOnSpring(t *testing.T) { isComponentsInProject(t, "spring", 1, "java", "spring") } +func TestComponentDetectionOnSpringCloud(t *testing.T) { + isComponentsInProject(t, "spring-cloud", 1, "java", "spring-cloud") +} + func TestComponentDetectionOnVertx(t *testing.T) { isComponentsInProject(t, "vertx", 1, "java", "http-vertx") }