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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations