Search in sources :

Example 36 with ActiveMQBuffer

use of org.apache.activemq.artemis.api.core.ActiveMQBuffer 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 37 with ActiveMQBuffer

use of org.apache.activemq.artemis.api.core.ActiveMQBuffer 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 38 with ActiveMQBuffer

use of org.apache.activemq.artemis.api.core.ActiveMQBuffer 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 39 with ActiveMQBuffer

use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.

the class DiscoveryStayAliveTest method sendBadData.

private static void sendBadData(BroadcastEndpointFactory factoryEndpoint) throws Exception {
    BroadcastEndpoint endpoint = factoryEndpoint.createBroadcastEndpoint();
    ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(500);
    buffer.writeString("This is a test1!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    buffer.writeString("This is a test2!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    byte[] bytes = new byte[buffer.writerIndex()];
    buffer.readBytes(bytes);
    // messing up with the string!!!
    for (int i = bytes.length - 10; i < bytes.length; i++) {
        bytes[i] = 0;
    }
    endpoint.openBroadcaster();
    endpoint.broadcast(bytes);
    endpoint.close(true);
}
Also used : BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) BroadcastEndpoint(org.apache.activemq.artemis.api.core.BroadcastEndpoint) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 40 with ActiveMQBuffer

use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.

the class LargeMessageBufferTest method testReadData.

@Test
public void testReadData() throws Exception {
    ActiveMQBuffer dynamic = ActiveMQBuffers.dynamicBuffer(1);
    String str1 = RandomUtil.randomString();
    String str2 = RandomUtil.randomString();
    double d1 = RandomUtil.randomDouble();
    float f1 = RandomUtil.randomFloat();
    dynamic.writeUTF(str1);
    dynamic.writeString(str2);
    dynamic.writeDouble(d1);
    dynamic.writeFloat(f1);
    LargeMessageControllerImpl readBuffer = splitBuffer(3, dynamic.toByteBuffer().array());
    Assert.assertEquals(str1, readBuffer.readUTF());
    Assert.assertEquals(str2, readBuffer.readString());
    Assert.assertEquals(d1, readBuffer.readDouble(), 0.000001);
    Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001);
}
Also used : LargeMessageControllerImpl(org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Aggregations

ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)150 Test (org.junit.Test)81 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)49 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)44 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)39 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)38 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)35 ByteBuffer (java.nio.ByteBuffer)34 Configuration (org.apache.activemq.artemis.core.config.Configuration)34 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)27 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)25 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)25 ArrayList (java.util.ArrayList)21 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)21 Queue (org.apache.activemq.artemis.core.server.Queue)18 HashMap (java.util.HashMap)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)15 RecordInfo (org.apache.activemq.artemis.core.journal.RecordInfo)15 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)14