Search in sources :

Example 1 with EnhancedServer

use of org.wildfly.swarm.messaging.EnhancedServer in project wildfly-swarm by wildfly-swarm.

the class RemoteConnectionCustomizerTest method testIfRemoteConnection.

@Test
public void testIfRemoteConnection() {
    this.fraction.server("default", (server) -> {
        server.remoteConnection("postoffice");
    });
    this.customizer.customize();
    EnhancedServer server = (EnhancedServer) this.fraction.subresources().servers().get(0);
    assertThat(server.remoteConnections()).hasSize(1);
    assertThat(server.subresources().pooledConnectionFactories()).hasSize(1);
    PooledConnectionFactory connectionFactory = server.subresources().pooledConnectionFactories().get(0);
    assertThat(connectionFactory.getKey()).isEqualTo("postoffice");
    assertThat(connectionFactory.entries()).containsExactly("java:/jms/postoffice");
    assertThat(server.subresources().remoteConnectors()).hasSize(1);
    RemoteConnector remoteConnector = server.subresources().remoteConnectors().get(0);
    assertThat(remoteConnector.getKey()).isEqualTo("postoffice");
    assertThat(remoteConnector.socketBinding()).isEqualTo("postoffice");
}
Also used : EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) RemoteConnector(org.wildfly.swarm.config.messaging.activemq.server.RemoteConnector) PooledConnectionFactory(org.wildfly.swarm.config.messaging.activemq.server.PooledConnectionFactory) Test(org.junit.Test)

Example 2 with EnhancedServer

use of org.wildfly.swarm.messaging.EnhancedServer in project wildfly-swarm by wildfly-swarm.

the class RemoteConnectionInstallingCustomizerTest method testIfMqNameSet.

@Test
public void testIfMqNameSet() {
    customizer.name.set("postoffice");
    customizer.customize();
    assertThat(fraction.subresources().servers()).hasSize(1);
    EnhancedServer server = (EnhancedServer) fraction.subresources().server("default");
    assertThat(server).isNotNull();
    assertThat(server.remoteConnections()).hasSize(1);
    RemoteConnection connection = server.remoteConnections().get(0);
    assertThat(connection.name()).isEqualTo("postoffice");
    assertThat(connection.host()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_HOST);
    assertThat(connection.port()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_PORT);
    assertThat(connection.jndiName()).isEqualTo("java:/jms/postoffice");
}
Also used : EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) RemoteConnection(org.wildfly.swarm.messaging.RemoteConnection) Test(org.junit.Test)

Example 3 with EnhancedServer

use of org.wildfly.swarm.messaging.EnhancedServer in project wildfly-swarm by wildfly-swarm.

the class RemoteConnectionInstallingCustomizerTest method testIfRemoteFlagSet.

@Test
public void testIfRemoteFlagSet() {
    customizer.enabled.set(true);
    customizer.customize();
    assertThat(fraction.subresources().servers()).hasSize(1);
    EnhancedServer server = (EnhancedServer) fraction.subresources().server("default");
    assertThat(server).isNotNull();
    assertThat(server.remoteConnections()).hasSize(1);
    RemoteConnection connection = server.remoteConnections().get(0);
    assertThat(connection.name()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_MQ_NAME);
    assertThat(connection.host()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_HOST);
    assertThat(connection.port()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_PORT);
    assertThat(connection.jndiName()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_JNDI_NAME);
}
Also used : EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) RemoteConnection(org.wildfly.swarm.messaging.RemoteConnection) Test(org.junit.Test)

Example 4 with EnhancedServer

use of org.wildfly.swarm.messaging.EnhancedServer in project wildfly-swarm by wildfly-swarm.

the class RemoteConnectionSocketBindingCustomizer method customize.

@Override
public void customize() {
    List<Server> servers = fraction.subresources().servers();
    servers.stream().filter(e -> e instanceof EnhancedServer).forEach(server -> {
        ((EnhancedServer) server).remoteConnections().forEach(connection -> {
            OutboundSocketBinding binding = new OutboundSocketBinding(connection.name());
            binding.remoteHost(connection.host()).remotePort(connection.port());
            group.outboundSocketBinding(binding);
        });
    });
}
Also used : Inject(javax.inject.Inject) List(java.util.List) SocketBindingGroup(org.wildfly.swarm.spi.api.SocketBindingGroup) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding) Server(org.wildfly.swarm.config.messaging.activemq.Server) Customizer(org.wildfly.swarm.spi.api.Customizer) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Post(org.wildfly.swarm.spi.runtime.annotations.Post) Any(javax.enterprise.inject.Any) Named(javax.inject.Named) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) MessagingFraction(org.wildfly.swarm.messaging.MessagingFraction) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) Server(org.wildfly.swarm.config.messaging.activemq.Server) EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) OutboundSocketBinding(org.wildfly.swarm.spi.api.OutboundSocketBinding)

Example 5 with EnhancedServer

use of org.wildfly.swarm.messaging.EnhancedServer in project wildfly-swarm by wildfly-swarm.

the class RemoteConnectionInstallingCustomizerTest method testIfJndiNameSet.

@Test
public void testIfJndiNameSet() {
    customizer.jndiName.set("java:/jms/iliketacos");
    customizer.customize();
    assertThat(fraction.subresources().servers()).hasSize(1);
    EnhancedServer server = (EnhancedServer) fraction.subresources().server("default");
    assertThat(server).isNotNull();
    assertThat(server.remoteConnections()).hasSize(1);
    RemoteConnection connection = server.remoteConnections().get(0);
    assertThat(connection.name()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_MQ_NAME);
    assertThat(connection.host()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_HOST);
    assertThat(connection.port()).isEqualTo(MessagingProperties.DEFAULT_REMOTE_PORT);
    assertThat(connection.jndiName()).isEqualTo("java:/jms/iliketacos");
}
Also used : EnhancedServer(org.wildfly.swarm.messaging.EnhancedServer) RemoteConnection(org.wildfly.swarm.messaging.RemoteConnection) Test(org.junit.Test)

Aggregations

EnhancedServer (org.wildfly.swarm.messaging.EnhancedServer)7 Test (org.junit.Test)6 RemoteConnection (org.wildfly.swarm.messaging.RemoteConnection)5 List (java.util.List)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Any (javax.enterprise.inject.Any)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 Server (org.wildfly.swarm.config.messaging.activemq.Server)1 PooledConnectionFactory (org.wildfly.swarm.config.messaging.activemq.server.PooledConnectionFactory)1 RemoteConnector (org.wildfly.swarm.config.messaging.activemq.server.RemoteConnector)1 MessagingFraction (org.wildfly.swarm.messaging.MessagingFraction)1 Customizer (org.wildfly.swarm.spi.api.Customizer)1 OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)1 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)1 Post (org.wildfly.swarm.spi.runtime.annotations.Post)1