diff --git a/boms/common-expansion/pom.xml b/boms/common-expansion/pom.xml index 4deaa00c8c03..ffd5d3728b13 100644 --- a/boms/common-expansion/pom.xml +++ b/boms/common-expansion/pom.xml @@ -959,6 +959,17 @@ + + io.smallrye.reactive + smallrye-reactive-messaging-in-memory + ${version.io.smallrye.smallrye-reactive-messaging} + + + * + * + + + io.vertx diff --git a/galleon-pack/galleon-shared/pom.xml b/galleon-pack/galleon-shared/pom.xml index d26b697ee4d0..584557e7dd48 100644 --- a/galleon-pack/galleon-shared/pom.xml +++ b/galleon-pack/galleon-shared/pom.xml @@ -332,7 +332,6 @@ - io.smallrye.reactive mutiny-reactive-streams-operators @@ -454,6 +453,17 @@ + + io.smallrye.reactive + smallrye-reactive-messaging-in-memory + + + * + * + + + + io.vertx vertx-core diff --git a/galleon-pack/galleon-shared/src/main/resources/layers/standalone/microprofile-reactive-messaging-inmemory/layer-spec.xml b/galleon-pack/galleon-shared/src/main/resources/layers/standalone/microprofile-reactive-messaging-inmemory/layer-spec.xml new file mode 100644 index 000000000000..707e0cec8623 --- /dev/null +++ b/galleon-pack/galleon-shared/src/main/resources/layers/standalone/microprofile-reactive-messaging-inmemory/layer-spec.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/module.xml b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/module.xml new file mode 100644 index 000000000000..e6debc9d563b --- /dev/null +++ b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/module.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/main/module.xml b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/main/module.xml index 0fa9bc9d69d9..7ca6fb9f5c8f 100644 --- a/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/main/module.xml +++ b/galleon-pack/galleon-shared/src/main/resources/modules/system/layers/base/io/smallrye/reactive/messaging/connector/main/module.xml @@ -33,6 +33,7 @@ + diff --git a/galleon-pack/galleon-shared/src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/content/modules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/resources/META-INF/beans.xml b/galleon-pack/galleon-shared/src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/content/modules/system/layers/base/io/smallrye/reactive/messaging/connector/inmemory/main/resources/META-INF/beans.xml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/galleon-pack/galleon-shared/src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/package.xml b/galleon-pack/galleon-shared/src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/package.xml new file mode 100644 index 000000000000..b1a02e30667a --- /dev/null +++ b/galleon-pack/galleon-shared/src/main/resources/packages/io.smallrye.reactive.messaging.connector.inmemory/package.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/microprofile/reactive-messaging-smallrye/inmemory/pom.xml b/microprofile/reactive-messaging-smallrye/inmemory/pom.xml new file mode 100644 index 000000000000..bc23850ac146 --- /dev/null +++ b/microprofile/reactive-messaging-smallrye/inmemory/pom.xml @@ -0,0 +1,95 @@ + + + + + 4.0.0 + + org.wildfly + wildfly-microprofile-reactive-messaging-parent + + 29.0.0.Beta1-SNAPSHOT + + + + wildfly-microprofile-reactive-messaging-inmemory + WildFly: MicroProfile Reactive Messaging In-Memory + + + + + io.smallrye.reactive + smallrye-reactive-messaging-in-memory + ${version.io.smallrye.smallrye-reactive-messaging} + + + io.smallrye.reactive + mutiny-zero-flow-adapters + ${version.io.smallrye.smallrye-mutiny-zero} + + + io.smallrye.reactive + mutiny-zero + ${version.io.smallrye.smallrye-mutiny-zero} + + + + org.eclipse.microprofile.config + microprofile-config-api + + + org.jboss.logging + jboss-logging-annotations + + + org.jboss.logging + jboss-logging-processor + + provided + true + + + org.jboss.msc + jboss-msc + + + org.wildfly.core + wildfly-server + + + ${full.maven.groupId} + wildfly-microprofile-reactive-messaging-common + + + ${full.maven.groupId} + wildfly-microprofile-reactive-messaging-config + + + diff --git a/testsuite/integration/microprofile/pom.xml b/testsuite/integration/microprofile/pom.xml index 498d67c64072..2ebe11c4c7c3 100644 --- a/testsuite/integration/microprofile/pom.xml +++ b/testsuite/integration/microprofile/pom.xml @@ -210,6 +210,14 @@ test + + + io.smallrye.reactive + smallrye-reactive-messaging-in-memory + ${version.io.smallrye.smallrye-reactive-messaging} + test + + io.smallrye.reactive diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/InMemoryBean.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/InMemoryBean.java new file mode 100644 index 000000000000..e13ace4ed1c7 --- /dev/null +++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/InMemoryBean.java @@ -0,0 +1,53 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.wildfly.test.integration.microprofile.reactive.messaging.inmemory; + +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; + +@ApplicationScoped +public class InMemoryBean { + + private String message; + + @Inject + @Channel("to-inmemory") + Emitter outgoingEmitter; + + @Incoming("from-inmemory") + public void incoming(String message) { + this.message = message; + } + + public void outgoing(String payload) { + outgoingEmitter.send(payload); + } + + public String getMessage() { + return message; + } + +} diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/ReactiveMessagingInMemoryTestCase.java b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/ReactiveMessagingInMemoryTestCase.java new file mode 100644 index 000000000000..cae34ec6da91 --- /dev/null +++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/ReactiveMessagingInMemoryTestCase.java @@ -0,0 +1,90 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2023, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.wildfly.test.integration.microprofile.reactive.messaging.inmemory; + +import io.smallrye.reactive.messaging.memory.InMemoryConnector; +import jakarta.enterprise.inject.Any; +import jakarta.inject.Inject; +import org.eclipse.microprofile.reactive.messaging.Message; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.arquillian.api.ServerSetup; +import org.jboss.as.test.shared.CLIServerSetupTask; +import org.jboss.as.test.shared.TimeoutUtil; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.wildfly.test.integration.microprofile.reactive.EnableReactiveExtensionsSetupTask; + +import java.util.List; +import java.util.PropertyPermission; + +import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; + +/** + * Run with + * mvn clean install -DallTests -pl testsuite/integration/microprofile -Dtest=ReactiveMessagingInMemoryUserApiTestCase + */ +@RunWith(Arquillian.class) +@ServerSetup({EnableReactiveExtensionsSetupTask.class}) +public class ReactiveMessagingInMemoryTestCase { + + @Inject + InMemoryBean inMemoryBean; + + @Inject + @Any + InMemoryConnector connector; + + @Deployment + public static WebArchive getDeployment() { + + return ShrinkWrap.create(WebArchive.class, "reactive-messaging-connector-inmemory.war") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") + .addPackage(ReactiveMessagingInMemoryTestCase.class.getPackage()) + .addClasses(EnableReactiveExtensionsSetupTask.class, CLIServerSetupTask.class) + .addAsWebInfResource(ReactiveMessagingInMemoryTestCase.class.getPackage(), "microprofile-config.properties", "classes/META-INF/microprofile-config.properties") + .addClass(TimeoutUtil.class) + .addAsManifestResource(createPermissionsXmlAsset( + new PropertyPermission(TimeoutUtil.FACTOR_SYS_PROP, "read") + ), "permissions.xml"); + } + + @Test + public void testIncomingMessageSendFromInMemoryConnector() throws InterruptedException { + connector.source("from-inmemory").send("IncomingTestMessage"); + Assert.assertEquals("IncomingTestMessage",inMemoryBean.getMessage()); + } + + @Test + public void testOutgoingMessageReceivedByInMemoryConnector() throws InterruptedException { + inMemoryBean.outgoing("OutgoingTestMessage"); + List> messages = connector.sink("to-inmemory").received(); + Assert.assertEquals(1,messages.size()); + Assert.assertEquals("OutgoingTestMessage",messages.get(0).getPayload()); + } + +} diff --git a/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/microprofile-config.properties b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/microprofile-config.properties new file mode 100644 index 000000000000..7cd872910a3f --- /dev/null +++ b/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/microprofile/reactive/messaging/inmemory/microprofile-config.properties @@ -0,0 +1,21 @@ +# +# Copyright 2023 Red Hat, Inc. +# +# 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. +# + +########################################################################################## +# Config for InMemoryBean +mp.messaging.outgoing.to-inmemory.connector=smallrye-in-memory +mp.messaging.incoming.from-inmemory.connector=smallrye-in-memory +