Search in sources :

Example 1 with BufferHandler

use of org.apache.activemq.artemis.spi.core.remoting.BufferHandler in project activemq-artemis by apache.

the class NettyConnectorTest method testBadProtocol.

@Test
public void testBadProtocol() throws Exception {
    BufferHandler handler = new BufferHandler() {

        @Override
        public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
        }
    };
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
    params.put(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME, "myBadProtocol");
    NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()));
    connector.start();
    Assert.assertTrue(connector.isStarted());
    Assert.assertNull(connector.createConnection());
    connector.close();
    Assert.assertFalse(connector.isStarted());
}
Also used : HashMap(java.util.HashMap) NettyConnector(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector) BufferHandler(org.apache.activemq.artemis.spi.core.remoting.BufferHandler) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 2 with BufferHandler

use of org.apache.activemq.artemis.spi.core.remoting.BufferHandler in project activemq-artemis by apache.

the class NettyConnectorTest method testJavaSystemPropertyOverrides.

@Test
public void testJavaSystemPropertyOverrides() throws Exception {
    BufferHandler handler = new BufferHandler() {

        @Override
        public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
        }
    };
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
    params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "bad path");
    params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "bad password");
    params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "bad path");
    params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, "bad password");
    NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()));
    System.setProperty(NettyConnector.JAVAX_KEYSTORE_PATH_PROP_NAME, "client-side-keystore.jks");
    System.setProperty(NettyConnector.JAVAX_KEYSTORE_PASSWORD_PROP_NAME, "secureexample");
    System.setProperty(NettyConnector.JAVAX_TRUSTSTORE_PATH_PROP_NAME, "client-side-truststore.jks");
    System.setProperty(NettyConnector.JAVAX_TRUSTSTORE_PASSWORD_PROP_NAME, "secureexample");
    connector.start();
    Assert.assertTrue(connector.isStarted());
    connector.close();
    Assert.assertFalse(connector.isStarted());
}
Also used : HashMap(java.util.HashMap) NettyConnector(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector) BufferHandler(org.apache.activemq.artemis.spi.core.remoting.BufferHandler) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 3 with BufferHandler

use of org.apache.activemq.artemis.spi.core.remoting.BufferHandler in project activemq-artemis by apache.

the class NettyConnectorTest method testBadCipherSuite.

@Test
public void testBadCipherSuite() throws Exception {
    BufferHandler handler = new BufferHandler() {

        @Override
        public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
        }
    };
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
    params.put(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME, "myBadCipherSuite");
    NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()));
    connector.start();
    Assert.assertTrue(connector.isStarted());
    Assert.assertNull(connector.createConnection());
    connector.close();
    Assert.assertFalse(connector.isStarted());
}
Also used : HashMap(java.util.HashMap) NettyConnector(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector) BufferHandler(org.apache.activemq.artemis.spi.core.remoting.BufferHandler) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 4 with BufferHandler

use of org.apache.activemq.artemis.spi.core.remoting.BufferHandler in project activemq-artemis by apache.

the class NettyConnectorTest method testStartStop.

@Test
public void testStartStop() throws Exception {
    BufferHandler handler = new BufferHandler() {

        @Override
        public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
        }
    };
    Map<String, Object> params = new HashMap<>();
    NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory()));
    connector.start();
    Assert.assertTrue(connector.isStarted());
    connector.close();
    Assert.assertFalse(connector.isStarted());
}
Also used : HashMap(java.util.HashMap) NettyConnector(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector) BufferHandler(org.apache.activemq.artemis.spi.core.remoting.BufferHandler) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 5 with BufferHandler

use of org.apache.activemq.artemis.spi.core.remoting.BufferHandler in project activemq-artemis by apache.

the class NettyAcceptorTest method testStartStop.

@Test
public void testStartStop() throws Exception {
    BufferHandler handler = new BufferHandler() {

        @Override
        public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
        }
    };
    Map<String, Object> params = new HashMap<>();
    ServerConnectionLifeCycleListener listener = new ServerConnectionLifeCycleListener() {

        @Override
        public void connectionException(final Object connectionID, final ActiveMQException me) {
        }

        @Override
        public void connectionDestroyed(final Object connectionID) {
        }

        @Override
        public void connectionCreated(final ActiveMQComponent component, final Connection connection, final ProtocolManager protocol) {
        }

        @Override
        public void connectionReadyForWrites(Object connectionID, boolean ready) {
        }
    };
    pool2 = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory());
    NettyAcceptor acceptor = new NettyAcceptor("netty", null, params, handler, listener, pool2, new HashMap<String, ProtocolManager>());
    addActiveMQComponent(acceptor);
    acceptor.start();
    Assert.assertTrue(acceptor.isStarted());
    acceptor.stop();
    Assert.assertFalse(acceptor.isStarted());
    ActiveMQTestBase.checkFreePort(TransportConstants.DEFAULT_PORT);
    acceptor.start();
    Assert.assertTrue(acceptor.isStarted());
    acceptor.stop();
    Assert.assertFalse(acceptor.isStarted());
    ActiveMQTestBase.checkFreePort(TransportConstants.DEFAULT_PORT);
    pool2.shutdown();
    pool2.awaitTermination(1, TimeUnit.SECONDS);
}
Also used : ActiveMQComponent(org.apache.activemq.artemis.core.server.ActiveMQComponent) HashMap(java.util.HashMap) NettyAcceptor(org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor) Connection(org.apache.activemq.artemis.spi.core.remoting.Connection) ServerConnectionLifeCycleListener(org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener) BufferHandler(org.apache.activemq.artemis.spi.core.remoting.BufferHandler) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ProtocolManager(org.apache.activemq.artemis.spi.core.protocol.ProtocolManager) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)8 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)8 BufferHandler (org.apache.activemq.artemis.spi.core.remoting.BufferHandler)8 Test (org.junit.Test)8 NettyConnector (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector)6 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2 NettyAcceptor (org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor)2 ActiveMQComponent (org.apache.activemq.artemis.core.server.ActiveMQComponent)2 ProtocolManager (org.apache.activemq.artemis.spi.core.protocol.ProtocolManager)2 Connection (org.apache.activemq.artemis.spi.core.remoting.Connection)2 ServerConnectionLifeCycleListener (org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener)2 NettyAcceptorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory)1 Acceptor (org.apache.activemq.artemis.spi.core.remoting.Acceptor)1