Skip to content

Commit

Permalink
Finished basic integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Wagner committed Jul 5, 2023
1 parent 3a39dde commit 0fd3195
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 256 deletions.
8 changes: 8 additions & 0 deletions testsuite/integration/microprofile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@
<scope>test</scope>
</dependency>

<!-- MicroProfile Reactive Messaging In-Memory Connector Test Dependencies -->
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-in-memory</artifactId>
<version>${version.io.smallrye.smallrye-reactive-messaging}</version>
<scope>test</scope>
</dependency>

<!-- MicroProfile Reactive Messaging Kafka Connector Test Dependencies -->
<dependency>
<groupId>io.smallrye.reactive</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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<String> 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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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<? extends Message<Object>> messages = connector.sink("to-inmemory").received();
Assert.assertEquals(1,messages.size());
Assert.assertEquals("OutgoingTestMessage",messages.get(0).getPayload());
}

}
Loading

0 comments on commit 0fd3195

Please sign in to comment.