-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-15405] Test for the MP Reactive Messaging AMQP Connnector
- Loading branch information
Showing
13 changed files
with
513 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2022 Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. | ||
~ | ||
~ 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. | ||
~ | ||
--> | ||
|
||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.wildfly.cloud-tests</groupId> | ||
<artifactId>wildfly-cloud-test-images</artifactId> | ||
<version>1.0.0.Alpha3-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>image-microprofile-reactive-messaging-amqp</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.wildfly.plugins</groupId> | ||
<artifactId>wildfly-maven-plugin</artifactId> | ||
<configuration> | ||
<layers> | ||
<layer>cloud-server</layer> | ||
<layer>microprofile-reactive-messaging-amqp</layer> | ||
</layers> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Needed until https://github.com/dekorateio/dekorate/issues/1000 is fixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2022 Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. | ||
~ | ||
~ 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. | ||
~ | ||
--> | ||
|
||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.wildfly.cloud-tests</groupId> | ||
<artifactId>wildfly-cloud-tests-microprofile-reactive-messaging</artifactId> | ||
<version>1.0.0.Alpha3-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>wildfly-cloud-tests-microprofile-reactive-messaging-amqp</artifactId> | ||
<packaging>war</packaging> | ||
|
||
<properties> | ||
<wildfly.cloud.test.base.image.name>wildfly-cloud-test-image/image-microprofile-reactive-messaging-amqp:latest</wildfly.cloud.test.base.image.name> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>image-microprofile-reactive-messaging-amqp</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.microprofile.reactive.messaging</groupId> | ||
<artifactId>microprofile-reactive-messaging-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
40 changes: 40 additions & 0 deletions
40
...wildfly/test/cloud/microprofile/reactive/messaging/amqp/ReactiveMessagingWithAmqpApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* 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.wildfly.test.cloud.microprofile.reactive.messaging.amqp; | ||
|
||
import static io.dekorate.kubernetes.annotation.ImagePullPolicy.Always; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
import io.dekorate.kubernetes.annotation.Env; | ||
import io.dekorate.kubernetes.annotation.KubernetesApplication; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Kabir Khan</a> | ||
*/ | ||
@KubernetesApplication( | ||
envVars = { | ||
@Env(name = "AMQP_HOST", value= "artemis") | ||
}, | ||
imagePullPolicy = Always) | ||
@ApplicationPath("") | ||
public class ReactiveMessagingWithAmqpApp extends Application { | ||
} |
67 changes: 67 additions & 0 deletions
67
...ildfly/test/cloud/microprofile/reactive/messaging/amqp/ReactiveMessagingWithAmqpBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* 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.wildfly.test.cloud.microprofile.reactive.messaging.amqp; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Channel; | ||
import org.eclipse.microprofile.reactive.messaging.Emitter; | ||
import org.eclipse.microprofile.reactive.messaging.Incoming; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Kabir Khan</a> | ||
*/ | ||
@ApplicationScoped | ||
public class ReactiveMessagingWithAmqpBean { | ||
@Inject | ||
@Channel("to-amqp") | ||
private Emitter<String> emitter; | ||
|
||
private List<String> received = new ArrayList<>(); | ||
|
||
private boolean seenOne; | ||
|
||
@Incoming("from-amqp") | ||
public void receive(String value) { | ||
System.out.println("Received: " + value); | ||
if (value.equals("one")) { | ||
if (seenOne) { | ||
// Avoid adding duplicate 'one' entries since the test might send more than one. See the comment there | ||
System.out.println("'one' already in list. Skipping"); | ||
return; | ||
} | ||
seenOne = true; | ||
} | ||
received.add(value); | ||
} | ||
|
||
void send(String value) { | ||
System.out.println("Sending: " + value); | ||
emitter.send(value); | ||
} | ||
|
||
public List<String> getReceived() { | ||
return received; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...ly/test/cloud/microprofile/reactive/messaging/amqp/ReactiveMessagingWithAmqpEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023 Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. | ||
* | ||
* 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.wildfly.test.cloud.microprofile.reactive.messaging.amqp; | ||
|
||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Kabir Khan</a> | ||
*/ | ||
@Path("") | ||
public class ReactiveMessagingWithAmqpEndpoint { | ||
@Inject | ||
ReactiveMessagingWithAmqpBean bean; | ||
|
||
@POST | ||
@Path("{value}") | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
public Response send(@PathParam("value") String value) { | ||
bean.send(value); | ||
return Response.ok().build(); | ||
} | ||
|
||
@GET | ||
@Produces(APPLICATION_JSON) | ||
public List<String> getHelloWorldJSON() { | ||
return bean.getReceived(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...rofile/reactive-messaging/amqp/src/main/resources/META-INF/microprofile-config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# JBoss, Home of Professional Open Source. | ||
# Copyright 2022 Red Hat, Inc., and individual contributors | ||
# as indicated by the @author tags. | ||
# | ||
# 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. | ||
# | ||
# | ||
|
||
amqp-port=5672 | ||
amqp-username=artemis | ||
amqp-password=artemis | ||
amqp-use-ssl=false | ||
|
||
mp.messaging.outgoing.to-amqp.connector=smallrye-amqp | ||
mp.messaging.outgoing.to-amqp.address=test | ||
|
||
mp.messaging.incoming.from-amqp.connector=smallrye-amqp | ||
mp.messaging.incoming.from-amqp.address=test | ||
|
57 changes: 57 additions & 0 deletions
57
tests/microprofile/reactive-messaging/amqp/src/test/container/artemis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: artemis | ||
labels: | ||
app: artemis | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: artemis | ||
template: | ||
metadata: | ||
labels: | ||
app: artemis | ||
spec: | ||
containers: | ||
- name: artemis | ||
image: quay.io/artemiscloud/activemq-artemis-broker-kubernetes:1.0.23 | ||
env: | ||
- name: AMQ_USER | ||
value: artemis | ||
- name: AMQ_PASSWORD | ||
value: artemis | ||
- name: AMQ_DATA_DIR | ||
value: /home/jboss/data | ||
# - name: AMQ_EXTRA_ARGS | ||
# value: "--http-host 0.0.0.0 " | ||
- name: SCRIPT_DEBUG | ||
value: "true" | ||
ports: | ||
- containerPort: 5672 | ||
- containerPort: 8161 | ||
- containerPort: 61613 | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: artemis | ||
spec: | ||
selector: | ||
app: artemis | ||
ports: | ||
- protocol: TCP | ||
port: 5672 | ||
targetPort: 5672 | ||
name: amqp | ||
- protocol: TCP | ||
port: 8161 | ||
targetPort: 8161 | ||
name: http | ||
- protocol: TCP | ||
port: 61616 | ||
targetPort: 61613 | ||
name: all |
Oops, something went wrong.