Skip to content

Commit

Permalink
AQ messaging example update (#100)
Browse files Browse the repository at this point in the history
* AQ messaging example update
* Run tests on random ports
  • Loading branch information
danielkec authored Dec 4, 2024
1 parent d433b18 commit 1d4a9d7
Show file tree
Hide file tree
Showing 23 changed files with 401 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public static void main(String[] args) {
LogConfig.configureRuntime();

// Prepare routing for the server
WebServer server = setupServer(WebServer.builder());
WebServer server = setupServer(WebServer.builder())
.build()
.start();

System.out.println("WEB server is up! http://localhost:" + server.port() + "/");
}

static WebServer setupServer(WebServerConfig.Builder builder) {
static WebServerConfig.Builder setupServer(WebServerConfig.Builder builder) {
// By default, this will pick up application.yaml from the classpath
Config config = Config.global();

Expand All @@ -68,8 +70,6 @@ static WebServer setupServer(WebServerConfig.Builder builder) {
return builder
.config(config.get("server"))
.addFeature(observe)
.routing(routing -> routing.register("/db", new PokemonService(dbClient)))
.build()
.start();
.routing(routing -> routing.register("/db", new PokemonService(dbClient)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ abstract class AbstractPokemonServiceTest {
private static WebClient client;

static void beforeAll() {
server = JdbcExampleMain.setupServer(WebServer.builder());
server = JdbcExampleMain.setupServer(WebServer.builder())
.port(-1)
.build()
.start();

client = WebClient.create(config -> config.baseUri("http://localhost:" + server.port())
.addMediaSupport(JsonpSupport.create()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ static WebServer startServer() {
// load logging configuration
LogConfig.configureRuntime();

WebServer server = setupServer(WebServer.builder());
WebServer server = setupServer(WebServer.builder())
.build()
.start();

System.out.println("WEB server is up! http://localhost:" + server.port() + "/");
return server;
}

static WebServer setupServer(WebServerConfig.Builder builder) {
static WebServerConfig.Builder setupServer(WebServerConfig.Builder builder) {
// By default, this will pick up application.yaml from the classpath
Config config = Config.create();

return builder.routing(routing -> routing(routing, config))
.config(config.get("server"))
.build()
.start();
.config(config.get("server"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public class MainIT {
static void beforeAll() {
String url = String.format("mongodb://127.0.0.1:%s/pokemon", container.getMappedPort(27017));
System.setProperty(CONNECTION_URL_KEY, url);
server = MongoDbExampleMain.setupServer(WebServer.builder());
server = MongoDbExampleMain.setupServer(WebServer.builder())
.port(-1)
.build()
.start();

client = WebClient.create(config -> config.baseUri("http://localhost:" + server.port())
.addMediaSupport(JsonbSupport.create(Config.create()))
.addMediaSupport(JsonpSupport.create()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ private static void startServer() {
Config config = mongo ? Config.create(ConfigSources.classpath(MONGO_CFG)) : Config.create();
Config.global(config);

WebServer server = setupServer(WebServer.builder());
WebServer server = setupServer(WebServer.builder())
.build()
.start();

System.out.println("WEB server is up! http://localhost:" + server.port() + "/");
}

static WebServer setupServer(WebServerConfig.Builder builder) {
static WebServerConfig.Builder setupServer(WebServerConfig.Builder builder) {

Config config = Config.global();
// Client services are added through a service loader - see mongoDB example for explicit services
Expand All @@ -94,9 +96,7 @@ static WebServer setupServer(WebServerConfig.Builder builder) {
.build();
return builder.config(config.get("server"))
.addFeature(observe)
.routing(Main::routing)
.build()
.start();
.routing(Main::routing);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ abstract class AbstractPokemonServiceTest {
private static WebClient client;

static void beforeAll() {
server = Main.setupServer(WebServer.builder());
server = Main.setupServer(WebServer.builder())
.port(-1)
.build()
.start();

client = WebClient.create(config -> config.baseUri("http://localhost:" + server.port())
.addMediaSupport(JsonpSupport.create()));
}
Expand Down
8 changes: 1 addition & 7 deletions examples/messaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ docker run --name='activemq' --rm -p 61616:61616 -p 8161:8161 rmohr/activemq
### Test Oracle database
* Start ActiveMQ server locally:
```shell
cd ./docker/oracle-aq-18-xe
cd ./docker/oracle-aq
./buildAndRun.sh
```

For stopping Oracle database container use:
```shell
cd ./docker/oracle-aq-18-xe
./stopAndClean.sh
```

## Helidon SE Reactive Messaging with Kafka Example
For demonstration of Helidon SE Messaging with Kafka connector,
continue to [Kafka with WebSocket SE Example](kafka-websocket-se/README.md)
Expand Down
102 changes: 0 additions & 102 deletions examples/messaging/docker/oracle-aq-18-xe/buildAndRun.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM container-registry.oracle.com/database/express:latest

FROM oracle/database:18.4.0-xe as base


COPY init.sql /docker-entrypoint-initdb.d/setup/
ENV "ORACLE_PWD"="frank"
ENV "ORACLE_ALLOW_REMOTE"="true"
ENV "ORACLE_SID"="XE"
ENV "PORT"="1521"
COPY ["init.sql","/opt/oracle/scripts/startup/"]
EXPOSE 1521
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

docker stop oracle-aq-example
docker container rm oracle-aq-example
docker image rm helidon/oracle-aq-example:latest
IMAGE_NAME=helidon/oracle-aq-example
CONTAINER_NAME=oracle-aq-example

docker build -t ${IMAGE_NAME} . -f Dockerfile
docker run -p 1521:1521 --rm --name ${CONTAINER_NAME} ${IMAGE_NAME}
74 changes: 71 additions & 3 deletions examples/messaging/oracle-aq-websocket-mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.applications</groupId>
Expand All @@ -34,7 +34,7 @@
<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile</artifactId>
<artifactId>helidon-microprofile-core</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.messaging</groupId>
Expand All @@ -53,12 +53,59 @@
<groupId>io.helidon.microprofile.websocket</groupId>
<artifactId>helidon-microprofile-websocket</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.logging</groupId>
<artifactId>helidon-logging-jul</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.messaging.mock</groupId>
<artifactId>helidon-messaging-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -72,6 +119,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<executions>
<execution>
<id>make-index</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 1d4a9d7

Please sign in to comment.