Skip to content

Commit

Permalink
[WFLy-19465] refactoring the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeshnas93 committed Jun 26, 2024
1 parent f626adc commit f7f1046
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,18 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.jboss.as.quickstarts.resteasyspring.test.TestUtils.getServerHost;

/**
* The very basic runtime integration testing.
* @author liweinan
*/
public class BasicRuntimeIT {

private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy/main";

@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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.jboss.as.quickstarts.resteasyspring.test.TestUtils.getServerHost;

/**
* Basic unit tests for resteasy spring integration
Expand All @@ -42,18 +43,9 @@ public class ResteasySpringIT {

static URL url;

private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy/main";

@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 = URI.create(serverHost).toURL();
url = URI.create(getServerHost()).toURL();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -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.resteasyspring.test;

public class TestUtils {
static final String DEFAULT_SERVER_HOST = "http://localhost:8080/spring-resteasy";
static final String MAINPAGE_PATH = "/main";

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;
}
}

0 comments on commit f7f1046

Please sign in to comment.