org.apache.activemq.command.ActiveMQTextMessage

Here are the examples of the java api class org.apache.activemq.command.ActiveMQTextMessage taken from open source projects.

1. StoreQueueCursorNoDuplicateTest#getMessage()

View license
private ActiveMQTextMessage getMessage(int i) throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    MessageId id = new MessageId(mesageIdRoot + i);
    id.setBrokerSequenceId(i);
    id.setProducerSequenceId(i);
    message.setMessageId(id);
    message.setDestination(destination);
    message.setPersistent(true);
    message.setResponseRequired(true);
    message.setText("Msg:" + i + " " + text);
    assertEquals(message.getMessageId().getProducerSequenceId(), i);
    return message;
}

2. StoreQueueCursorOrderTest#getMessage()

View license
private ActiveMQTextMessage getMessage(int i) throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    MessageId id = new MessageId(mesageIdRoot + i);
    id.setBrokerSequenceId(i);
    id.setProducerSequenceId(i);
    message.setMessageId(id);
    message.setDestination(destination);
    message.setPersistent(true);
    message.setResponseRequired(true);
    message.setText("Msg:" + i + " " + text);
    assertEquals(message.getMessageId().getProducerSequenceId(), i);
    return message;
}

3. FailoverTransportBrokerTest#createMessage()

View license
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
    message.setDestination(destination);
    message.setPersistent(false);
    try {
        message.setText("Test Message Payload.");
    } catch (MessageNotWriteableException e) {
    }
    return message;
}

4. FanoutTransportBrokerTest#createMessage()

View license
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
    message.setDestination(destination);
    message.setPersistent(false);
    try {
        message.setText("Test Message Payload.");
    } catch (MessageNotWriteableException e) {
    }
    return message;
}

5. BrokerTestSupport#createMessage()

View license
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
    message.setDestination(destination);
    message.setPersistent(false);
    try {
        message.setText("Test Message Payload.");
    } catch (MessageNotWriteableException e) {
    }
    return message;
}

6. BrokerNetworkWithStuckMessagesTest#createMessage()

View license
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator));
    message.setDestination(destination);
    message.setPersistent(false);
    try {
        message.setText("Test Message Payload.");
    } catch (MessageNotWriteableException e) {
    }
    return message;
}

7. NumberRangesWhileMarshallingTest#testMaxFrameSize()

View license
public void testMaxFrameSize() throws Exception {
    OpenWireFormat wf = new OpenWireFormat();
    wf.setMaxFrameSize(10);
    ActiveMQTextMessage msg = new ActiveMQTextMessage();
    msg.setText("This is a test");
    writeObject(msg);
    ds.writeInt(endOfStreamMarker);
    // now lets read from the stream
    ds.close();
    ByteArrayInputStream in = new ByteArrayInputStream(buffer.toByteArray());
    DataInputStream dis = new DataInputStream(in);
    try {
        wf.unmarshal(dis);
    } catch (IOException ioe) {
        return;
    }
    fail("Should fail because of the large frame size");
}

8. MessageCompressionTest#testTextMessageCompressionOpenWireToActiveMQ()

View license
@Test
public void testTextMessageCompressionOpenWireToActiveMQ() throws Exception {
    sendOpenWireTextMessage(TEXT);
    ActiveMQTextMessage message = receiveAMQTextMessage();
    int compressedSize = message.getContent().getLength();
    sendOpenWireTextMessage(TEXT, false);
    message = receiveAMQTextMessage();
    int unCompressedSize = message.getContent().getLength();
    assertTrue("expected: compressed Size '" + compressedSize + "' < unCompressedSize '" + unCompressedSize + "'", compressedSize < unCompressedSize);
}

9. CompressionOverNetworkTest#testTextMessageCompression()

View license
@Test
public void testTextMessageCompression() throws Exception {
    MessageConsumer consumer1 = remoteSession.createConsumer(included);
    MessageProducer producer = localSession.createProducer(included);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    waitForConsumerRegistration(localBroker, 1, included);
    StringBuilder payload = new StringBuilder("test-");
    for (int i = 0; i < 100; ++i) {
        payload.append(UUID.randomUUID().toString());
    }
    Message test = localSession.createTextMessage(payload.toString());
    producer.send(test);
    Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
    assertNotNull(msg);
    ActiveMQTextMessage message = (ActiveMQTextMessage) msg;
    assertTrue(message.isCompressed());
    assertEquals(payload.toString(), message.getText());
}

10. CompressionOverNetworkTest#testCompressedOverCompressedNetwork()

View license
@Test
public void testCompressedOverCompressedNetwork() throws Exception {
    ActiveMQConnection localAmqConnection = (ActiveMQConnection) localConnection;
    localAmqConnection.setUseCompression(true);
    MessageConsumer consumer1 = remoteSession.createConsumer(included);
    MessageProducer producer = localSession.createProducer(included);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    waitForConsumerRegistration(localBroker, 1, included);
    StringBuilder payload = new StringBuilder("test-");
    for (int i = 0; i < 100; ++i) {
        payload.append(UUID.randomUUID().toString());
    }
    Message test = localSession.createTextMessage(payload.toString());
    producer.send(test);
    Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
    assertNotNull(msg);
    ActiveMQTextMessage message = (ActiveMQTextMessage) msg;
    assertTrue(message.isCompressed());
    assertEquals(payload.toString(), message.getText());
}

11. MessageCompressionTest#testTextMessageCompressionActiveMQ()

View license
@Test
public void testTextMessageCompressionActiveMQ() throws Exception {
    sendAMQTextMessage(TEXT);
    ActiveMQTextMessage message = receiveAMQTextMessage();
    int compressedSize = message.getContent().getLength();
    sendAMQTextMessage(TEXT, false);
    message = receiveAMQTextMessage();
    int unCompressedSize = message.getContent().getLength();
    assertTrue("expected: compressed Size '" + compressedSize + "' < unCompressedSize '" + unCompressedSize + "'", compressedSize < unCompressedSize);
}

12. StoreQueueCursorOrderTest#testSetBatchWithFuture()

View license
@Test
public void testSetBatchWithFuture() throws Exception {
    final int count = 4;
    final Message[] messages = new Message[count];
    final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
    final ConsumerInfo consumerInfo = new ConsumerInfo();
    final DestinationStatistics destinationStatistics = new DestinationStatistics();
    consumerInfo.setExclusive(true);
    final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);
    queueMessageStore.start();
    queueMessageStore.registerIndexListener(null);
    QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
    SystemUsage systemUsage = new SystemUsage();
    // ensure memory limit is reached
    systemUsage.getMemoryUsage().setLimit(messageBytesSize * (count + 6));
    underTest.setSystemUsage(systemUsage);
    underTest.setEnableAudit(false);
    underTest.start();
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    ActiveMQTextMessage msg = getMessage(0);
    messages[0] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    final ActiveMQTextMessage msgRef = msg;
    FutureTask<Long> future0 = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
            msgRef.getMessageId().setFutureOrSequenceLong(0L);
        }
    }, 0L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future0);
    underTest.addMessageLast(msg);
    Executors.newSingleThreadExecutor().submit(future0);
    msg = getMessage(1);
    messages[3] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    final ActiveMQTextMessage msgRef1 = msg;
    FutureTask<Long> future1 = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
            msgRef1.getMessageId().setFutureOrSequenceLong(3L);
        }
    }, 3L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future1);
    underTest.addMessageLast(msg);
    msg = getMessage(2);
    messages[1] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(1L);
    underTest.addMessageLast(msg);
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    // out of order future
    Executors.newSingleThreadExecutor().submit(future1);
    // sync add to flip cache
    msg = getMessage(3);
    messages[2] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(3L);
    underTest.addMessageLast(msg);
    assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
    assertEquals("setBatch set", 2L, queueMessageStore.batch.get());
    int dequeueCount = 0;
    underTest.setMaxBatchSize(count);
    underTest.reset();
    while (underTest.hasNext() && dequeueCount < count) {
        MessageReference ref = underTest.next();
        ref.decrementReferenceCount();
        underTest.remove();
        LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
        assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
    }
    underTest.release();
    assertEquals(count, dequeueCount);
}

13. StoreQueueCursorOrderTest#testSetBatchWithOrderedFutureCurrentFuture()

View license
@Test
public void testSetBatchWithOrderedFutureCurrentFuture() throws Exception {
    final int count = 2;
    final Message[] messages = new Message[count];
    final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
    final ConsumerInfo consumerInfo = new ConsumerInfo();
    final DestinationStatistics destinationStatistics = new DestinationStatistics();
    consumerInfo.setExclusive(true);
    final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);
    queueMessageStore.start();
    queueMessageStore.registerIndexListener(null);
    QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
    SystemUsage systemUsage = new SystemUsage();
    // ensure memory limit is reached
    systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
    underTest.setSystemUsage(systemUsage);
    underTest.setEnableAudit(false);
    underTest.start();
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    ActiveMQTextMessage msg = getMessage(0);
    messages[0] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    final ActiveMQTextMessage msgRef = msg;
    FutureTask<Long> future = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
            msgRef.getMessageId().setFutureOrSequenceLong(0L);
        }
    }, 0L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future);
    Executors.newSingleThreadExecutor().submit(future);
    underTest.addMessageLast(msg);
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    // second message will flip the cache but will be stored before the future task
    msg = getMessage(1);
    messages[1] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    final ActiveMQTextMessage msgRe2f = msg;
    FutureTask<Long> future2 = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
            msgRe2f.getMessageId().setFutureOrSequenceLong(1L);
        }
    }, 1L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future2);
    Executors.newSingleThreadExecutor().submit(future2);
    underTest.addMessageLast(msg);
    assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
    assertEquals("setBatch set", 1L, queueMessageStore.batch.get());
    int dequeueCount = 0;
    underTest.setMaxBatchSize(2);
    underTest.reset();
    while (underTest.hasNext() && dequeueCount < count) {
        MessageReference ref = underTest.next();
        ref.decrementReferenceCount();
        underTest.remove();
        LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
        assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
    }
    underTest.release();
    assertEquals(count, dequeueCount);
}

14. QueueDuplicatesFromStoreTest#getMessage()

View license
private Message getMessage(int i) throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(mesageIdRoot + i));
    message.setDestination(destination);
    message.setPersistent(true);
    message.setResponseRequired(true);
    message.setText("Msg:" + i + " " + text);
    assertEquals(message.getMessageId().getProducerSequenceId(), i);
    return message;
}

15. QueueOptimizedDispatchExceptionTest#getMessage()

View license
private Message getMessage(int i) throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setMessageId(new MessageId(mesageIdRoot + i));
    message.setDestination(destination);
    message.setPersistent(false);
    message.setResponseRequired(true);
    message.setText("Msg:" + i + " " + text);
    assertEquals(message.getMessageId().getProducerSequenceId(), i);
    return message;
}

16. StoreQueueCursorOrderTest#testNoSetBatchWithUnOrderedFutureCurrentSync()

View license
@Test
public void testNoSetBatchWithUnOrderedFutureCurrentSync() throws Exception {
    final int count = 2;
    final Message[] messages = new Message[count];
    final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
    final ConsumerInfo consumerInfo = new ConsumerInfo();
    final DestinationStatistics destinationStatistics = new DestinationStatistics();
    consumerInfo.setExclusive(true);
    final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);
    queueMessageStore.start();
    queueMessageStore.registerIndexListener(null);
    QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
    SystemUsage systemUsage = new SystemUsage();
    // ensure memory limit is reached
    systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
    underTest.setSystemUsage(systemUsage);
    underTest.setEnableAudit(false);
    underTest.start();
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    ActiveMQTextMessage msg = getMessage(0);
    messages[1] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    final ActiveMQTextMessage msgRef = msg;
    FutureTask<Long> future = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
            msgRef.getMessageId().setFutureOrSequenceLong(1L);
        }
    }, 1L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future);
    Executors.newSingleThreadExecutor().submit(future);
    underTest.addMessageLast(msg);
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    // second message will flip the cache but will be stored before the future task
    msg = getMessage(1);
    messages[0] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(1L);
    underTest.addMessageLast(msg);
    assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
    assertEquals("setBatch unset", 0L, queueMessageStore.batch.get());
    int dequeueCount = 0;
    underTest.setMaxBatchSize(2);
    underTest.reset();
    while (underTest.hasNext() && dequeueCount < count) {
        MessageReference ref = underTest.next();
        ref.decrementReferenceCount();
        underTest.remove();
        LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
        assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
    }
    underTest.release();
    assertEquals(count, dequeueCount);
}

17. StoreQueueCursorOrderTest#testSetBatch()

View license
@Test
public void testSetBatch() throws Exception {
    final int count = 3;
    final Message[] messages = new Message[count];
    final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
    final ConsumerInfo consumerInfo = new ConsumerInfo();
    final DestinationStatistics destinationStatistics = new DestinationStatistics();
    consumerInfo.setExclusive(true);
    final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);
    queueMessageStore.start();
    queueMessageStore.registerIndexListener(null);
    QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
    SystemUsage systemUsage = new SystemUsage();
    // ensure memory limit is reached
    systemUsage.getMemoryUsage().setLimit(messageBytesSize * 5);
    underTest.setSystemUsage(systemUsage);
    underTest.setEnableAudit(false);
    underTest.start();
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    ActiveMQTextMessage msg = getMessage(0);
    messages[0] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(0L);
    underTest.addMessageLast(msg);
    msg = getMessage(1);
    messages[1] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(1L);
    underTest.addMessageLast(msg);
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    msg = getMessage(2);
    messages[2] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(2L);
    underTest.addMessageLast(msg);
    assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
    assertEquals("setBatch set", 2L, queueMessageStore.batch.get());
    int dequeueCount = 0;
    underTest.setMaxBatchSize(2);
    underTest.reset();
    while (underTest.hasNext() && dequeueCount < count) {
        MessageReference ref = underTest.next();
        ref.decrementReferenceCount();
        underTest.remove();
        LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
        assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
    }
    underTest.release();
    assertEquals(count, dequeueCount);
}

18. StoreQueueCursorOrderTest#tesBlockedFuture()

View license
@Test
public void tesBlockedFuture() throws Exception {
    final int count = 2;
    final Message[] messages = new Message[count];
    final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
    final ConsumerInfo consumerInfo = new ConsumerInfo();
    final DestinationStatistics destinationStatistics = new DestinationStatistics();
    consumerInfo.setExclusive(true);
    final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);
    queueMessageStore.start();
    queueMessageStore.registerIndexListener(null);
    QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
    SystemUsage systemUsage = new SystemUsage();
    // ensure memory limit is reached
    systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
    underTest.setSystemUsage(systemUsage);
    underTest.setEnableAudit(false);
    underTest.start();
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    ActiveMQTextMessage msg = getMessage(0);
    messages[1] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.setRecievedByDFBridge(true);
    FutureTask<Long> future = new FutureTask<Long>(new Runnable() {

        @Override
        public void run() {
        }
    }, 2L) {
    };
    msg.getMessageId().setFutureOrSequenceLong(future);
    underTest.addMessageLast(msg);
    assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());
    // second message will flip the cache but will be stored before the future task
    msg = getMessage(1);
    messages[0] = msg;
    msg.setMemoryUsage(systemUsage.getMemoryUsage());
    msg.getMessageId().setFutureOrSequenceLong(1L);
    underTest.addMessageLast(msg);
    assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
    assertEquals("setBatch unset", 0L, queueMessageStore.batch.get());
    int dequeueCount = 0;
    underTest.setMaxBatchSize(2);
    underTest.reset();
    while (underTest.hasNext() && dequeueCount < count) {
        MessageReference ref = underTest.next();
        ref.decrementReferenceCount();
        underTest.remove();
        LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
        assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
    }
    underTest.release();
    assertEquals(count, dequeueCount);
}

19. UdpTestSupport#assertSendTextMessage()

View license
protected void assertSendTextMessage(ActiveMQDestination destination, String text) throws MessageNotWriteableException {
    large = true;
    ActiveMQTextMessage expected = new ActiveMQTextMessage();
    expected.setText(text);
    expected.setDestination(destination);
    try {
        LOG.info("About to send message of type: " + expected.getClass());
        producer.oneway(expected);
        // lets send a dummy command to ensure things don't block if we
        // discard the last one
        // keepalive does not have a commandId...
        // producer.oneway(new KeepAliveInfo());
        producer.oneway(new ProducerInfo());
        producer.oneway(new ProducerInfo());
        Command received = assertCommandReceived();
        assertTrue("Should have received an ActiveMQTextMessage but was: " + received, received instanceof ActiveMQTextMessage);
        ActiveMQTextMessage actual = (ActiveMQTextMessage) received;
        assertEquals("getDestination", expected.getDestination(), actual.getDestination());
        assertEquals("getText", expected.getText(), actual.getText());
        LOG.info("Received text message with: " + actual.getText().length() + " character(s)");
    } catch (Exception e) {
        LOG.info("Caught: " + e);
        e.printStackTrace();
        fail("Failed to send to transport: " + e);
    }
}

20. SelectorTest#testXPathSelectors()

Project: activemq-artemis
Source File: SelectorTest.java
View license
public void testXPathSelectors() throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setJMSType("xml");
    message.setText("<root><a key='first' num='1'/><b key='second' num='2'>b</b></root>");
    assertSelector(message, "XPATH 'root/a'", true);
    assertSelector(message, "XPATH '//root/b'", true);
    assertSelector(message, "XPATH 'root/c'", false);
    assertSelector(message, "XPATH '//root/b/text()=\"b\"'", true);
    assertSelector(message, "XPATH '//root/b=\"b\"'", true);
    assertSelector(message, "XPATH '//root/b=\"c\"'", false);
    assertSelector(message, "XPATH '//root/b!=\"c\"'", true);
    assertSelector(message, "XPATH '//root/*[@key=''second'']'", true);
    assertSelector(message, "XPATH '//root/*[@key=''third'']'", false);
    assertSelector(message, "XPATH '//root/a[@key=''first'']'", true);
    assertSelector(message, "XPATH '//root/a[@num=1]'", true);
    assertSelector(message, "XPATH '//root/a[@key=''second'']'", false);
    assertSelector(message, "XPATH '/root/*[@key=''first'' or @key=''third'']'", true);
    assertSelector(message, "XPATH '//root/*[@key=''third'' or @key=''forth'']'", false);
    assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''second'']'", true);
    assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''first'']'", false);
    assertSelector(message, "XPATH 'not(//root/a)'", false);
    assertSelector(message, "XPATH 'not(//root/c)'", true);
    assertSelector(message, "XPATH '//root/a[not(@key=''first'')]'", false);
    assertSelector(message, "XPATH '//root/a[not(not(@key=''first''))]'", true);
    assertSelector(message, "XPATH 'string(//root/b)'", true);
    assertSelector(message, "XPATH 'string(//root/a)'", false);
    assertSelector(message, "XPATH 'sum(//@num) < 10'", true);
    assertSelector(message, "XPATH 'sum(//@num) > 10'", false);
    assertSelector(message, "XPATH '//root/a[@num > 1]'", false);
    assertSelector(message, "XPATH '//root/b[@num > 1]'", true);
}

21. ActiveMQXAConnectionFactoryTest#testSessionCloseTransactionalSendReceive()

View license
public void testSessionCloseTransactionalSendReceive() throws Exception {
    ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory("vm://localhost?broker.persistent=false");
    XAConnection connection1 = (XAConnection) cf1.createConnection();
    connection1.start();
    XASession session = connection1.createXASession();
    XAResource resource = session.getXAResource();
    Destination dest = new ActiveMQQueue(getName());
    // publish a message
    Xid tid = createXid();
    resource.start(tid, XAResource.TMNOFLAGS);
    MessageProducer producer = session.createProducer(dest);
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setText(getName());
    producer.send(message);
    session.close();
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
    session = connection1.createXASession();
    MessageConsumer consumer = session.createConsumer(dest);
    tid = createXid();
    resource = session.getXAResource();
    resource.start(tid, XAResource.TMNOFLAGS);
    TextMessage receivedMessage = (TextMessage) consumer.receive(1000);
    session.close();
    assertNotNull(receivedMessage);
    assertEquals(getName(), receivedMessage.getText());
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
    session = connection1.createXASession();
    consumer = session.createConsumer(dest);
    tid = createXid();
    resource = session.getXAResource();
    resource.start(tid, XAResource.TMNOFLAGS);
    assertNull(consumer.receive(1000));
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
}

22. DataFileGeneratorTestSupport#createMessage()

View license
protected Message createMessage(String string) throws Exception {
    ActiveMQTextMessage message = (ActiveMQTextMessage) ActiveMQTextMessageTest.SINGLETON.createObject();
    message.setText(string);
    return message;
}

23. ActiveMQXAConnectionFactoryTest#testCloseSendConnection()

View license
public void testCloseSendConnection() throws Exception {
    String brokerName = "closeSend";
    BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName));
    broker.start();
    broker.waitUntilStarted();
    ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
    XAConnection connection = (XAConnection) cf.createConnection();
    connection.start();
    XASession session = connection.createXASession();
    XAResource resource = session.getXAResource();
    Destination dest = new ActiveMQQueue(getName());
    // publish a message
    Xid tid = createXid();
    resource.start(tid, XAResource.TMNOFLAGS);
    MessageProducer producer = session.createProducer(dest);
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setText(getName());
    producer.send(message);
    connection.close();
    //comment out this check as it doesn't apply to artemis
    //assertTransactionGoneFromBroker(tid);
    broker.stop();
}

24. ActiveMQXAConnectionFactoryTest#testConsumerCloseTransactionalSendReceive()

View license
public void testConsumerCloseTransactionalSendReceive() throws Exception {
    ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory("vm://localhost?broker.persistent=false");
    XAConnection connection1 = (XAConnection) cf1.createConnection();
    connection1.start();
    XASession session = connection1.createXASession();
    XAResource resource = session.getXAResource();
    Destination dest = new ActiveMQQueue(getName());
    // publish a message
    Xid tid = createXid();
    resource.start(tid, XAResource.TMNOFLAGS);
    MessageProducer producer = session.createProducer(dest);
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setText(getName());
    producer.send(message);
    producer.close();
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
    session.close();
    session = connection1.createXASession();
    MessageConsumer consumer = session.createConsumer(dest);
    tid = createXid();
    resource = session.getXAResource();
    resource.start(tid, XAResource.TMNOFLAGS);
    TextMessage receivedMessage = (TextMessage) consumer.receive(1000);
    consumer.close();
    assertNotNull(receivedMessage);
    assertEquals(getName(), receivedMessage.getText());
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
    session = connection1.createXASession();
    consumer = session.createConsumer(dest);
    tid = createXid();
    resource = session.getXAResource();
    resource.start(tid, XAResource.TMNOFLAGS);
    assertNull(consumer.receive(1000));
    resource.end(tid, XAResource.TMSUCCESS);
    resource.commit(tid, true);
}

25. ActiveMQTextMessageTest#populateObject()

View license
@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ActiveMQTextMessage info = (ActiveMQTextMessage) object;
}

26. ActiveMQTextMessageTest#createObject()

View license
@Override
public Object createObject() throws Exception {
    ActiveMQTextMessage info = new ActiveMQTextMessage();
    populateObject(info);
    return info;
}

27. ActiveMQTextMessageTest#populateObject()

View license
@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ActiveMQTextMessage info = (ActiveMQTextMessage) object;
}

28. ActiveMQTextMessageTest#createObject()

View license
@Override
public Object createObject() throws Exception {
    ActiveMQTextMessage info = new ActiveMQTextMessage();
    populateObject(info);
    return info;
}

29. MessageCompressionTest#receiveAMQTextMessage()

View license
private ActiveMQTextMessage receiveAMQTextMessage() throws Exception {
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionURI);
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(getActiveMQQueue());
    ActiveMQTextMessage rc = (ActiveMQTextMessage) consumer.receive();
    connection.close();
    return rc;
}