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..12ce2b4756 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 @@ -15,6 +15,7 @@ */ package org.jboss.as.quickstarts.mail; +import org.apache.hc.client5.http.classic.methods.HttpGet; import org.junit.Test; import java.io.IOException; @@ -26,6 +27,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. @@ -38,15 +40,9 @@ public class BasicRuntimeIT { @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; - } + HttpGet httpGet = new HttpGet(getServerHost()); 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..4ce0856035 --- /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 API_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 + API_PATH; + } +}