From f65adc33d8a083dfa1aae6d71e051959a4ba4671 Mon Sep 17 00:00:00 2001 From: sudeshnas93 Date: Mon, 24 Jun 2024 04:22:23 +0530 Subject: [PATCH] [WFLY-19450] mail Quickstarts should have a root webpage similar to helloworld --- mail/src/main/webapp/index.html | 17 ++++++++-- .../as/quickstarts/mail/BasicRuntimeIT.java | 12 ++----- .../as/quickstarts/mail/MailTestCaseIT.java | 12 ++----- .../jboss/as/quickstarts/mail/TestUtils.java | 32 +++++++++++++++++++ 4 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 mail/src/test/java/org/jboss/as/quickstarts/mail/TestUtils.java diff --git a/mail/src/main/webapp/index.html b/mail/src/main/webapp/index.html index 0897d6b00e..e9579c69ab 100644 --- a/mail/src/main/webapp/index.html +++ b/mail/src/main/webapp/index.html @@ -1,6 +1,6 @@ + - + - + + mail + +
+ +

Hello There! Welcome to WildFly!

+

The mail quickstart application has been deployed and running successfully.

+ Access the mail application here + +
+ diff --git a/mail/src/test/java/org/jboss/as/quickstarts/mail/BasicRuntimeIT.java b/mail/src/test/java/org/jboss/as/quickstarts/mail/BasicRuntimeIT.java index 7a0f2ce380..1587436719 100644 --- a/mail/src/test/java/org/jboss/as/quickstarts/mail/BasicRuntimeIT.java +++ b/mail/src/test/java/org/jboss/as/quickstarts/mail/BasicRuntimeIT.java @@ -26,6 +26,7 @@ import java.time.Duration; import static org.junit.Assert.assertEquals; +import static org.jboss.as.quickstarts.mail.TestUtils.getServerHost; /** * The very basic runtime integration testing. @@ -34,19 +35,10 @@ */ public class BasicRuntimeIT { - private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/mail"; - @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)) + .uri(new URI(getServerHost())) .GET() .build(); final HttpClient client = HttpClient.newBuilder() diff --git a/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java b/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java index fde3fd784e..81a5cd74a9 100644 --- a/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java +++ b/mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCaseIT.java @@ -16,6 +16,8 @@ import org.openqa.selenium.support.ui.Wait; import org.openqa.selenium.support.ui.WebDriverWait; +import static org.jboss.as.quickstarts.mail.TestUtils.getServerHost; + import java.time.Duration; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -37,15 +39,7 @@ public void testSetup() { driver = new ChromeDriver(options); driver.manage().window().maximize(); - String serverHost = System.getenv("SERVER_HOST"); - if (serverHost == null) { - serverHost = System.getProperty("server.host"); - } - if (serverHost == null) { - serverHost = DEFAULT_SERVER_HOST; - } - - driver.get(serverHost); + driver.get(getServerHost()); driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500)); } diff --git a/mail/src/test/java/org/jboss/as/quickstarts/mail/TestUtils.java b/mail/src/test/java/org/jboss/as/quickstarts/mail/TestUtils.java new file mode 100644 index 0000000000..c1caad6e03 --- /dev/null +++ b/mail/src/test/java/org/jboss/as/quickstarts/mail/TestUtils.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 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.mail; + +public class TestUtils { + static final String DEFAULT_SERVER_HOST = "http://localhost:8080/mail"; + static final String MAINPAGE_PATH = "/home.jsf"; + + static String getServerHost() { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + return serverHost + MAINPAGE_PATH; + } +}