public static byte[] randomBytes() { return RandomUtil.randomString().getBytes(); }
public static char randomChar() { return RandomUtil.randomString().charAt(0); }
public static SimpleString randomSimpleString() { return new SimpleString(RandomUtil.randomString()); }
protected ClientSession createTransactionalSession(final ClientSessionFactory sf) throws Exception { ClientSession session = sf.createSession(false, false, false); session.addMetaData("someData", RandomUtil.randomString()); session.addMetaData("someData2", RandomUtil.randomString()); return session; }
private static void failure(final Validators.Validator validator, final Object value) { try { validator.validate(RandomUtil.randomString(), value); Assert.fail(validator + " must not validate " + value); } catch (IllegalArgumentException e) { } }
@Test public void testFromAddressWithInvalidPrefix() throws Exception { String invalidPrefix = "junk"; String destinationName = RandomUtil.randomString(); String address = invalidPrefix + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Destination); }
protected void doTestL(final ClientSessionFactory sf) throws Exception { final int numSessions = 100; for (int i = 0; i < numSessions; i++) { ClientSession session = sf.createSession(false, false, false); session.addMetaData("data", RandomUtil.randomString()); session.close(); } }
@Test public void testNOT_NULL_OR_EMPTY() throws Exception { ValidatorsTest.failure(Validators.NOT_NULL_OR_EMPTY, null); ValidatorsTest.failure(Validators.NOT_NULL_OR_EMPTY, ""); ValidatorsTest.success(Validators.NOT_NULL_OR_EMPTY, RandomUtil.randomString()); }
@Test public void testUTF() throws Exception { String str = RandomUtil.randomString(); wrapper.writeUTF(str); Assert.assertEquals(str, wrapper.readUTF()); }
@Test public void testFromAddressWithQueueAddressPrefix() throws Exception { String destinationName = RandomUtil.randomString(); String address = QUEUE_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Queue); Assert.assertEquals(destinationName, ((Queue) destination).getQueueName()); }
@Test public void testFromAddressWithTopicAddressPrefix() throws Exception { String destinationName = RandomUtil.randomString(); String address = TOPIC_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); Assert.assertTrue(destination instanceof Topic); Assert.assertEquals(destinationName, ((Topic) destination).getTopicName()); }
@Test public void testGetStringFromString() throws Exception { String value = RandomUtil.randomString(); ActiveMQMapMessage message = new ActiveMQMapMessage(); message.setString(itemName, value); Assert.assertEquals(value, message.getString(itemName)); }
@Test public void testReadObjectFromString() throws Exception { String value = RandomUtil.randomString(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeString(value); message.reset(); Assert.assertEquals(value, message.readObject()); }
@Test public void testEquals() throws Exception { String destinationName = RandomUtil.randomString(); String address = QUEUE_QUALIFIED_PREFIX + destinationName; ActiveMQDestination destination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); ActiveMQDestination sameDestination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address); ActiveMQDestination differentDestination = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address + RandomUtil.randomString()); Assert.assertFalse(destination.equals(null)); Assert.assertTrue(destination.equals(destination)); Assert.assertTrue(destination.equals(sameDestination)); Assert.assertFalse(destination.equals(differentDestination)); }
@Test public void testReadStringFromString() throws Exception { String value = RandomUtil.randomString(); ActiveMQStreamMessage message = new ActiveMQStreamMessage(); message.writeString(value); message.reset(); Assert.assertEquals(value, message.readString()); }
@Test public void testJOURNAL_TYPE() throws Exception { for (JournalType type : JournalType.values()) { ValidatorsTest.success(Validators.JOURNAL_TYPE, type.toString()); } ValidatorsTest.failure(Validators.JOURNAL_TYPE, null); ValidatorsTest.failure(Validators.JOURNAL_TYPE, ""); ValidatorsTest.failure(Validators.JOURNAL_TYPE, RandomUtil.randomString()); }
@Test public void testSendMessageToNonExistentTopicUsingExplicitDefaultRouting() throws Exception { String nonExistentTopic = RandomUtil.randomString(); server.getAddressSettingsRepository().addMatch(nonExistentTopic, new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST)); sendMessageToNonExistentTopic(getTopicPrefix(), nonExistentTopic, null); }
@Test public void testSendMessageToNonExistentQueueUsingExplicitDefaultRouting() throws Exception { String nonExistentQueue = RandomUtil.randomString(); server.getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST)); sendMessageToNonExistentQueue(getQueuePrefix(), nonExistentQueue, null); }
@Test public void testSizeofNullableString() throws Exception { Assert.assertEquals(1, SimpleString.sizeofNullableString(null)); Assert.assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString(""))); SimpleString str = new SimpleString(RandomUtil.randomString()); Assert.assertEquals(1 + DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofNullableString(str)); }
@Test public void testSetDeadLetterAddress() throws Exception { SimpleString address = RandomUtil.randomSimpleString(); SimpleString queue = RandomUtil.randomSimpleString(); String deadLetterAddress = RandomUtil.randomString(); session.createQueue(address, RoutingType.MULTICAST, queue, null, durable); QueueControl queueControl = createManagementControl(address, queue); AddressSettings addressSettings = new AddressSettings().setDeadLetterAddress(new SimpleString(deadLetterAddress)); server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings); Assert.assertEquals(deadLetterAddress, queueControl.getDeadLetterAddress()); session.deleteQueue(queue); }