Creating the queue through an Arquillian test case

We can also add and remove the queue through an Arquillian test case:

@RunWith(Arquillian.class)
@ServerSetup(MessagingResourcesSetupTask.class)
public class MessageTestCase {
...
private static final String QUEUE_NAME = "gps_coordinates";
private static final String QUEUE_LOOKUP = "java:/jms/queue/GPS";
static class MessagingResourcesSetupTask implements ServerSetupTask {
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
getInstance(managementClient.getControllerClient()).createJmsQueue(QUEUE_NAME, QUEUE_LOOKUP);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
getInstance(managementClient.getControllerClient()).removeJmsQueue(QUEUE_NAME);
}
}
...
}

The org.jboss.as.arquillian.api.ServerSetup Arquillian annotation lets us use an external setup manager used to install or remove new components inside WildFly. In this case, we are installing the queue declared with two variables--QUEUE_NAME and QUEUE_LOOKUP.

When the test ends, the tearDown method will be started automatically, and it will remove the installed queue.

To use Arquillian, it's important to add the WildFly test suite dependency in your pom.xml project:

...
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-testsuite-shared</artifactId>
<version>10.1.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
...

We will find the created queue in the standalone-full.xml, as follows:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
...
<jms-queue name="gps_coordinates" entries="java:/jms/queue/GPS"/>
...
</server>
</subsystem>

JMS is available in the standalone-full configuration. By default, WildFly supports four standalone configurations. They can be found in the standalone/configuration directory:

  • standalone.xml: It supports all components except the messaging and CORBA/IIOP
  • standalone-full.xml: It supports all components
  • standalone-ha.xml: It supports all components except the messaging and CORBA/IIOP with the enabled cluster
  • standalone-full-ha.xml: It supports all components with the enabled cluster

To start WildFly with the chosen configuration, simply add a -c with the configuration in the standalone.sh script. Here's a sample to start the standalone full configuration:

./standalone.sh -c standalone-full.xml
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.20.57