Skip to content

Commit

Permalink
[WFLY-19465]spring-resteasy Quickstarts should have a root webpage si…
Browse files Browse the repository at this point in the history
…milar to helloworld
  • Loading branch information
sudeshnas93 committed Jun 26, 2024
1 parent 741125f commit 98fc367
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 32 deletions.
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 @@ -50,17 +50,18 @@ public class HelloSpringResource {
@Produces("text/html")
public Response getDefault(@Context UriInfo uriInfo) {
String baseURI = uriInfo.getBaseUri().toString();
baseURI = baseURI + "main";
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>";
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,16 @@
package org.jboss.as.quickstarts.resteasyspring;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

@Path("/")
public class RootResource {

@GET
@Produces("text/html")
public String getRootResponse() {
String responsemsg = "Hello There! Welcome to WildFly! <br> Spring-resteasy quickstart has been deployed and running successfully. <br> You can find the available operations 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

0 comments on commit 98fc367

Please sign in to comment.