You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by cmdr <sp...@yahoo.fr> on 2010/06/17 23:17:53 UTC

spring jms test

Hi

Can someone explain me the reason why this test failed

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class SenderTest
{
	@Autowired
	private JmsTemplate jmsTemplate;

	@Test
	public void testSend() throws JMSException
	{
		jmsTemplate.send
		(
			new MessageCreator()
			{
				public Message createMessage(Session session) throws JMSException
				{
					return session.createTextMessage("hello");
				}
			}
		);
		
		Message message = jmsTemplate.receive();
		
		if (message instanceof TextMessage)
		{
			TextMessage textMessage = (TextMessage) message;
			Assert.assertEquals("The message received is not the right one", "hello",
textMessage.getText());
		}
		else
		{
			Assert.assertNotNull("The message is null", message);
			Assert.fail("The message is not a text message");
		}
	}
}

It fail with these activemq configurations
vm://localhost?broker.persistent=false
vm://localhost?broker.deleteAllMessagesOnStartup=true

bu work with this configuration
vm://localhost

I need a clean queue for my junit test, what is the right what to achieve
that

Regards


-- 
View this message in context: http://old.nabble.com/spring-jms-test-tp28919788p28919788.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.