@Test public void testWriteObjectWithDouble() throws Exception { doWriteObjectWithType(RandomUtil.randomDouble(), new TypeReader() { @Override public Object readType(final ActiveMQStreamMessage message) throws Exception { return message.readDouble(); } }); }
@Test public void testSetObjectFromDouble() throws Exception { doTestSetObject(RandomUtil.randomDouble()); }
private void populate(StringBuilder sb, BeanUtilsBean bean, ActiveMQConnectionFactory factory) throws IllegalAccessException, InvocationTargetException { PropertyDescriptor[] descriptors = bean.getPropertyUtils().getPropertyDescriptors(factory); for (PropertyDescriptor descriptor : descriptors) { if (descriptor.getWriteMethod() != null && descriptor.getReadMethod() != null) { if (descriptor.getPropertyType() == String.class) { String value = RandomUtil.randomString(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); } else if (descriptor.getPropertyType() == int.class) { int value = RandomUtil.randomPositiveInt(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); } else if (descriptor.getPropertyType() == long.class) { long value = RandomUtil.randomPositiveLong(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); } else if (descriptor.getPropertyType() == double.class) { double value = RandomUtil.randomDouble(); bean.setProperty(factory, descriptor.getName(), value); sb.append("&").append(descriptor.getName()).append("=").append(value); } } } }
value = RandomUtil.randomBoolean(); } else if (prop.getPropertyType() == Double.class || prop.getPropertyType() == Double.TYPE) { value = RandomUtil.randomDouble(); } else { System.out.println("Can't validate property of type " + prop.getPropertyType() + " on " + prop.getName());
@Test public void testGetDoubleFromString() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setString(itemName, Double.toString(value)); Assert.assertEquals(value, message.getDouble(itemName), 0.000001); }
@Test public void testDouble() throws Exception { double d = RandomUtil.randomDouble(); wrapper.writeDouble(d); Assert.assertEquals(d, wrapper.readDouble(), 0.000001); }
@Test public void testReadStringFromDouble() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeDouble(value); message.reset(); Assert.assertEquals(Double.toString(value), message.readString()); }
@Test public void testReadDoubleFromString() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeString(Double.toString(value)); message.reset(); Assert.assertEquals(value, message.readDouble(), 0.000001); }
@Test public void testGetDoubleFromDouble() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setDouble(itemName, value); Assert.assertEquals(value, message.getDouble(itemName), 0.000001); }
@Test public void testReadDoubleFromDouble() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeDouble(value); message.reset(); Assert.assertEquals(value, message.readDouble(), 0.000001); }
@Test public void testReadObjectFromDouble() throws Exception { double value = RandomUtil.randomDouble(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeDouble(value); message.reset(); Assert.assertEquals(value, message.readObject()); }
@Test public void testDoubleProperty() throws Exception { Double val = RandomUtil.randomDouble(); props.putDoubleProperty(key, val); Assert.assertEquals(val, props.getDoubleProperty(key)); Assert.assertEquals(new SimpleString(Double.toString(val)), props.getSimpleStringProperty(key)); props.putSimpleStringProperty(key, new SimpleString(Double.toString(val))); Assert.assertEquals(val, props.getDoubleProperty(key)); try { props.putBooleanProperty(key, RandomUtil.randomBoolean()); props.getDoubleProperty(key); Assert.fail(); } catch (ActiveMQPropertyConversionException e) { } try { props.getDoubleProperty(unknownKey); Assert.fail(); } catch (Exception e) { } }
@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); }
@Override @Before public void setUp() throws Exception { super.setUp(); Map<String, Object> acceptorParams = new HashMap<>(); acceptorParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1); TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); CoreQueueConfiguration sourceQueueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false); CoreQueueConfiguration targetQueueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false); List<String> connectors = new ArrayList<>(); connectors.add(connectorConfig.getName()); Configuration conf_1 = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addQueueConfiguration(targetQueueConfig); bridgeConfig = new BridgeConfiguration().setName(RandomUtil.randomString()).setQueueName(sourceQueueConfig.getName()).setForwardingAddress(targetQueueConfig.getAddress()).setRetryInterval(RandomUtil.randomPositiveLong()).setRetryIntervalMultiplier(RandomUtil.randomDouble()).setInitialConnectAttempts(RandomUtil.randomPositiveInt()).setReconnectAttempts(RandomUtil.randomPositiveInt()).setReconnectAttemptsOnSameNode(RandomUtil.randomPositiveInt()).setUseDuplicateDetection(RandomUtil.randomBoolean()).setConfirmationWindowSize(RandomUtil.randomPositiveInt()).setStaticConnectors(connectors).setPassword(CLUSTER_PASSWORD); Configuration conf_0 = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName())).addConnectorConfiguration(connectorConfig.getName(), connectorConfig).addQueueConfiguration(sourceQueueConfig).addBridgeConfiguration(bridgeConfig); server_1 = addServer(ActiveMQServers.newActiveMQServer(conf_1, MBeanServerFactory.createMBeanServer(), false)); addServer(server_1); server_1.start(); server_0 = addServer(ActiveMQServers.newActiveMQServer(conf_0, mbeanServer, false)); addServer(server_0); server_0.start(); }
@Override @Before public void setUp() throws Exception { super.setUp(); Map<String, Object> acceptorParams = new HashMap<>(); acceptorParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1); TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName(), acceptorParams, RandomUtil.randomString()); CoreQueueConfiguration sourceQueueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false); CoreQueueConfiguration targetQueueConfig = new CoreQueueConfiguration().setAddress(RandomUtil.randomString()).setName(RandomUtil.randomString()).setDurable(false); List<String> connectors = new ArrayList<>(); connectors.add(connectorConfig.getName()); bridgeConfig = new BridgeConfiguration().setName(RandomUtil.randomString()).setQueueName(sourceQueueConfig.getName()).setForwardingAddress(targetQueueConfig.getAddress()).setRetryInterval(RandomUtil.randomPositiveLong()).setRetryIntervalMultiplier(RandomUtil.randomDouble()).setInitialConnectAttempts(RandomUtil.randomPositiveInt()).setReconnectAttempts(RandomUtil.randomPositiveInt()).setReconnectAttemptsOnSameNode(RandomUtil.randomPositiveInt()).setUseDuplicateDetection(RandomUtil.randomBoolean()).setConfirmationWindowSize(RandomUtil.randomPositiveInt()).setStaticConnectors(connectors); Configuration conf_1 = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addQueueConfiguration(targetQueueConfig); Configuration conf_0 = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY)).addConnectorConfiguration(connectorConfig.getName(), connectorConfig).addQueueConfiguration(sourceQueueConfig).addBridgeConfiguration(bridgeConfig); server_1 = addServer(ActiveMQServers.newActiveMQServer(conf_1, MBeanServerFactory.createMBeanServer(), false)); server_1.start(); server_0 = addServer(ActiveMQServers.newActiveMQServer(conf_0, mbeanServer, false)); server_0.start(); }
@Test public void testReadDataOverCached() throws Exception { clearDataRecreateServerDirs(); 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(), getTestFile()); Assert.assertEquals(str1, readBuffer.readUTF()); Assert.assertEquals(str2, readBuffer.readString()); Assert.assertEquals(d1, readBuffer.readDouble(), 0.00000001); Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001); readBuffer.readerIndex(0); Assert.assertEquals(str1, readBuffer.readUTF()); Assert.assertEquals(str2, readBuffer.readString()); Assert.assertEquals(d1, readBuffer.readDouble(), 0.00000001); Assert.assertEquals(f1, readBuffer.readFloat(), 0.000001); readBuffer.close(); }
@Test public void testEncodeDecode() throws Exception { props.putByteProperty(RandomUtil.randomSimpleString(), RandomUtil.randomByte()); props.putBytesProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBytes()); props.putBytesProperty(RandomUtil.randomSimpleString(), null); props.putBooleanProperty(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean()); props.putShortProperty(RandomUtil.randomSimpleString(), RandomUtil.randomShort()); props.putIntProperty(RandomUtil.randomSimpleString(), RandomUtil.randomInt()); props.putLongProperty(RandomUtil.randomSimpleString(), RandomUtil.randomLong()); props.putFloatProperty(RandomUtil.randomSimpleString(), RandomUtil.randomFloat()); props.putDoubleProperty(RandomUtil.randomSimpleString(), RandomUtil.randomDouble()); props.putCharProperty(RandomUtil.randomSimpleString(), RandomUtil.randomChar()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString()); props.putSimpleStringProperty(RandomUtil.randomSimpleString(), null); SimpleString keyToRemove = RandomUtil.randomSimpleString(); props.putSimpleStringProperty(keyToRemove, RandomUtil.randomSimpleString()); ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); TypedProperties decodedProps = new TypedProperties(); decodedProps.decode(buffer.byteBuf()); TypedPropertiesTest.assertEqualsTypeProperties(props, decodedProps); buffer.clear(); // After removing a property, you should still be able to encode the Property props.removeProperty(keyToRemove); props.encode(buffer.byteBuf()); Assert.assertEquals(props.getEncodeSize(), buffer.writerIndex()); }
int threadPoolMaxSize = RandomUtil.randomPositiveInt(); long retryInterval = RandomUtil.randomPositiveLong(); double retryIntervalMultiplier = RandomUtil.randomDouble(); int reconnectAttempts = RandomUtil.randomPositiveInt(); factory.setClientID(clientID);
int threadPoolMaxSize = RandomUtil.randomPositiveInt(); long retryInterval = RandomUtil.randomPositiveLong(); double retryIntervalMultiplier = RandomUtil.randomDouble(); int reconnectAttempts = RandomUtil.randomPositiveInt(); TransportConfiguration[] tc = new TransportConfiguration[]{liveTC};
int threadPoolMaxSize = RandomUtil.randomPositiveInt(); long retryInterval = RandomUtil.randomPositiveLong(); double retryIntervalMultiplier = RandomUtil.randomDouble(); int reconnectAttempts = RandomUtil.randomPositiveInt(); cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);