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 a 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);