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