Skip to content

Commit

Permalink
[WFLY-19435] microprofile-reactive-messaging-kafka Quickstarts should…
Browse files Browse the repository at this point in the history
… have a root webpage similar to helloworld
  • Loading branch information
sudeshnas93 committed Jun 25, 2024
1 parent 01313ed commit bc95f67
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
12 changes: 6 additions & 6 deletions microprofile-reactive-messaging-kafka/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ package org.wildfly.quickstarts.microprofile.reactive.messaging;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
@ApplicationPath("/")
@ApplicationPath("/rest")
public class JaxRsApplication extends Application {
}
Expand Down Expand Up @@ -1525,7 +1525,7 @@ Then we get another section where it is using the randomised order
In both parts of the log we see that all messages reach the `logAllMessages()` method, while only `Hello` and `Kafka` reach the `receiveFromKafka()` method which saves them to the RDBMS.
To inspect what was stored in the database, go to http://localhost:8080/microprofile-reactive-messaging-kafka/db in your browser and you should see something like:
To inspect what was stored in the database, go to http://localhost:8080/microprofile-reactive-messaging-kafka/rest/db in your browser and you should see something like:
[source, options="nowrap"]
----
Expand All @@ -1539,15 +1539,15 @@ The timestamps of the entries in the browser match the ones we saw in the server
=== Interaction with User Initiated Code
With the application still running, open two terminal windows. Enter the following `curl` command in both of them
```
$curl -N http://localhost:8080/microprofile-reactive-messaging-kafka/user
$curl -N http://localhost:8080/microprofile-reactive-messaging-kafka/rest/user
```
The `-N` option keeps the connection open, so we receive data as it becomes available on the publisher.
In a third terminal window enter the commands:
```
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/user/one
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/user/two
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/user/three
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/rest/user/one
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/rest/user/two
$curl -X POST http://localhost:8080/microprofile-reactive-messaging-kafka/rest/user/three
```
In the first two terminal windows you should see these entries appear as they are posted:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/")
@ApplicationPath("/rest")
public class JaxRsApplication extends Application {
}
27 changes: 27 additions & 0 deletions microprofile-reactive-messaging-kafka/src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
JBoss, Home of Professional Open Source
Copyright 2024, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.
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.
-->
<!DOCTYPE html>
<html>
<title>microprofile-reactive-messaging-kafka</title>
<body>
<div style="text-align:center">

<h1>Hello There! Welcome to WildFly!</h1>
<h2>The microprofile-reactive-messaging-kafka quickstart application has been deployed and running successfully.</h2>

</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private boolean checkResponse(CloseableHttpResponse response, boolean fail) thro
return false;
}

Assert.assertNotEquals("Expected to find 'Hello' on line 0 of:\n" + lines, -1, lines.get(0).indexOf("Hello"));
Assert.assertNotEquals("Expected to find 'Kafka' on line 1 of:\n" + lines, -1, lines.get(1).indexOf("Kafka"));
Assert.assertNotEquals("Expected to find 'Hello' on line 0 of:\n" + lines, -1, lines.get(1).indexOf("Hello"));
Assert.assertNotEquals("Expected to find 'Kafka' on line 1 of:\n" + lines, -1, lines.get(2).indexOf("Kafka"));
for (int i = 2; i < lines.size(); i++) {
Assert.assertNotEquals(
"Expected to find 'Hello' or 'Kafka' on line " + i +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class TestUtils {
static final String DEFAULT_SERVER_HOST = "http://localhost:8080/microprofile-reactive-messaging-kafka";
static final String API_PATH = "/rest";

static String getServerHost() {
String serverHost = System.getenv("SERVER_HOST");
Expand All @@ -11,6 +12,6 @@ static String getServerHost() {
if (serverHost == null) {
serverHost = DEFAULT_SERVER_HOST;
}
return serverHost;
return serverHost + API_PATH;
}
}

0 comments on commit bc95f67

Please sign in to comment.