public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
public static long randomPositiveLong() { return Math.abs(RandomUtil.randomLong()); }
@Test public void testWriteObjectWithLong() throws Exception { doWriteObjectWithType(RandomUtil.randomLong(), new TypeReader() { @Override public Object readType(final ActiveMQStreamMessage message) throws Exception { return message.readLong(); } }); }
@Test public void testSetObjectFromLong() throws Exception { doTestSetObject(RandomUtil.randomLong()); }
@Test public void testGetLongFromString() throws Exception { long value = RandomUtil.randomLong(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setString(itemName, Long.toString(value)); Assert.assertEquals(value, message.getLong(itemName)); }
@Test public void testGetStringFromLong() throws Exception { long value = RandomUtil.randomLong(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setLong(itemName, value); Assert.assertEquals(Long.toString(value), message.getString(itemName)); }
@Test public void testLong() throws Exception { long l = RandomUtil.randomLong(); wrapper.writeLong(l); Assert.assertEquals(l, wrapper.readLong()); }
@Test public void testReadLongFromString() throws Exception { long value = RandomUtil.randomLong(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeString(Long.toString(value)); message.reset(); Assert.assertEquals(value, message.readLong()); }
@Test public void testReadStringFromLong() throws Exception { long value = RandomUtil.randomLong(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeLong(value); message.reset(); Assert.assertEquals(Long.toString(value), message.readString()); }
@Test public void testGetLongFromLong() throws Exception { long value = RandomUtil.randomLong(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setLong(itemName, value); Assert.assertEquals(value, message.getLong(itemName)); }
@Test public void testReadObjectFromLong() throws Exception { long value = RandomUtil.randomLong(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeLong(value); message.reset(); Assert.assertEquals(value, message.readObject()); }
@Test public void testReadLongFromLong() throws Exception { long value = RandomUtil.randomLong(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeLong(value); message.reset(); Assert.assertEquals(value, message.readLong()); }
@Test public void testAddRemoveConsumer() throws Exception { final long id = RandomUtil.randomLong(); final SimpleString address = RandomUtil.randomSimpleString(); final SimpleString uniqueName = RandomUtil.randomSimpleString(); final SimpleString routingName = RandomUtil.randomSimpleString(); final Long remoteQueueID = RandomUtil.randomLong(); final SimpleString filterString = new SimpleString("A>B"); final Queue storeAndForwardQueue = new FakeQueue(null); final SimpleString bridgeName = RandomUtil.randomSimpleString(); final int distance = 0; RemoteQueueBindingImpl binding = new RemoteQueueBindingImpl(id, address, uniqueName, routingName, remoteQueueID, filterString, storeAndForwardQueue, bridgeName, distance, MessageLoadBalancingType.ON_DEMAND); for (int i = 0; i < 100; i++) { binding.addConsumer(new SimpleString("B" + i + "<A")); } assertEquals(100, binding.getFilters().size()); for (int i = 0; i < 100; i++) { binding.removeConsumer(new SimpleString("B" + i + "<A")); } assertEquals(0, binding.getFilters().size()); } }
@Test public void testAddAndRemoveMessages() { long id1 = RandomUtil.randomLong(); long id2 = RandomUtil.randomLong(); PageTransactionInfo trans = new PageTransactionInfoImpl(id2); trans.setRecordID(id1); // anything between 2 and 100 int nr1 = RandomUtil.randomPositiveInt() % 98 + 2; for (int i = 0; i < nr1; i++) { trans.increment(1, 0); } Assert.assertEquals(nr1, trans.getNumberOfMessages()); ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(trans.getEncodeSize()); trans.encode(buffer); PageTransactionInfo trans2 = new PageTransactionInfoImpl(id1); trans2.decode(buffer); Assert.assertEquals(id2, trans2.getTransactionID()); Assert.assertEquals(nr1, trans2.getNumberOfMessages()); }
@Test public void testTypedProperties() throws Exception { SimpleString longKey = RandomUtil.randomSimpleString(); long longValue = RandomUtil.randomLong(); SimpleString simpleStringKey = RandomUtil.randomSimpleString(); SimpleString simpleStringValue = RandomUtil.randomSimpleString(); TypedProperties otherProps = new TypedProperties(); otherProps.putLongProperty(longKey, longValue); otherProps.putSimpleStringProperty(simpleStringKey, simpleStringValue); props.putTypedProperties(otherProps); long ll = props.getLongProperty(longKey); Assert.assertEquals(longValue, ll); SimpleString ss = props.getSimpleStringProperty(simpleStringKey); Assert.assertEquals(simpleStringValue, ss); }