Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-19465] spring-resteasy Quickstarts should have a root webpage similar to helloworld #938

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Joshua Wilson
*
*/
@Path("/")
@Path("main")
public class HelloSpringResource {

@Autowired
Expand All @@ -51,16 +51,17 @@ public class HelloSpringResource {
public Response getDefault(@Context UriInfo uriInfo) {
String baseURI = uriInfo.getBaseUri().toString();
if (!baseURI.endsWith("/")) baseURI += '/';
String msg = "Hello. <br> Please try <a href='"+baseURI+"hello?name=yourname'>spring-resteasy/hello?name=yourname</a>"
+ "<br> Or try <a href='"+baseURI+"basic'>spring-resteasy/basic</a>"
+ "<br> Or try <a href='"+baseURI+"queryParam?param=query'>spring-resteasy/queryParam?param=query</a>"
+ "<br> Or try <a href='"+baseURI+"matrixParam;param=matrix'>spring-resteasy/matrixParam;param=matrix</a>"
+ "<br> Or try <a href='"+baseURI+"uriParam/789'>spring-resteasy/uriParam/789</a>"
+ "<br> Or try <a href='"+baseURI+"locating/hello?name=yourname'>spring-resteasy/locating/hello?name=yourname</a>"
+ "<br> Or try <a href='"+baseURI+"locating/basic'>spring-resteasy/locating/basic</a>"
+ "<br> Or try <a href='"+baseURI+"locating/queryParam?param=query'>spring-resteasy/locating/queryParam?param=query</a>"
+ "<br> Or try <a href='"+baseURI+"locating/matrixParam;param=matrix'>spring-resteasy/locating/matrixParam;param=matrix</a>"
+ "<br> Or try <a href='"+baseURI+"locating/uriParam/789'>spring-resteasy/locating/uriParam/789</a>";
baseURI = baseURI + "main/";
String msg = "Hello. <br> Please try <a href='"+baseURI+"hello?name=yourname'>spring-resteasy/main/hello?name=yourname</a>"
+ "<br> Or try <a href='"+baseURI+"basic'>spring-resteasy/main/basic</a>"
+ "<br> Or try <a href='"+baseURI+"queryParam?param=query'>spring-resteasy/main/queryParam?param=query</a>"
+ "<br> Or try <a href='"+baseURI+"matrixParam;param=matrix'>spring-resteasy/main/matrixParam;param=matrix</a>"
+ "<br> Or try <a href='"+baseURI+"uriParam/789'>spring-resteasy/main/uriParam/789</a>"
+ "<br> Or try <a href='"+baseURI+"locating/hello?name=yourname'>spring-resteasy/main/locating/hello?name=yourname</a>"
+ "<br> Or try <a href='"+baseURI+"locating/basic'>spring-resteasy/main/locating/basic</a>"
+ "<br> Or try <a href='"+baseURI+"locating/queryParam?param=query'>spring-resteasy/main/locating/queryParam?param=query</a>"
+ "<br> Or try <a href='"+baseURI+"locating/matrixParam;param=matrix'>spring-resteasy/main/locating/matrixParam;param=matrix</a>"
+ "<br> Or try <a href='"+baseURI+"locating/uriParam/789'>spring-resteasy/main/locating/uriParam/789</a>";
System.out.println("getDefault()");
return Response.ok(msg).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* @author <a href="mailto:[email protected]">Bill Burke</a>
*/
@Path("/")
@Path("main")
public class LocatingResource {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jboss.as.quickstarts.resteasyspring;

import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.UriInfo;

@Path("/")
public class RootResource {

@GET
@Produces("text/html")
public String getRootResponse(@Context UriInfo uriInfo) {
String baseURI = uriInfo.getBaseUri().toString();
if (!baseURI.endsWith("/")) baseURI += '/';
baseURI = baseURI + "main/";
String responsemsg = "Hello There! Welcome to WildFly!" +
"<br>Spring-resteasy quickstart has been deployed and running successfully. " +
"<br>You can find the available operations <a href='"+baseURI+"'>here</a> or in the included README file.";
return responsemsg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<context:annotation-config />

<!-- JAX-RS basic resource -->
<bean id="RootResource" class="org.jboss.as.quickstarts.resteasyspring.RootResource" />

<!-- JAX-RS main resource -->
<bean id="HelloSpringResource" class="org.jboss.as.quickstarts.resteasyspring.HelloSpringResource" />

<!-- An example bean -->
Expand Down
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";

@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";

@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;
}
}
3 changes: 3 additions & 0 deletions spring-resteasy/src/test/resources/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<context:annotation-config />

<!-- JAX-RS basic resource -->
<bean id="RootResource" class="org.jboss.as.quickstarts.resteasyspring.RootResource" />

<!-- JAX-RS main resource -->
<bean id="HelloSpringResource" class="org.jboss.as.quickstarts.resteasyspring.HelloSpringResource" />

<!-- An example bean -->
Expand Down
Loading