Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 78820 invoked from network); 29 May 2007 11:16:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 May 2007 11:16:48 -0000 Received: (qmail 48186 invoked by uid 500); 29 May 2007 11:14:58 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 48142 invoked by uid 500); 29 May 2007 11:14:58 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 48126 invoked by uid 99); 29 May 2007 11:14:57 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 04:14:57 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 04:14:50 -0700 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Hszen-0003r5-Qf for users@activemq.apache.org; Tue, 29 May 2007 04:14:29 -0700 Message-ID: <10852036.post@talk.nabble.com> Date: Tue, 29 May 2007 04:14:29 -0700 (PDT) From: Carfield Yim To: users@activemq.apache.org Subject: Re: Question about unit test with activemq In-Reply-To: <7b3355cb0705280619p4765e5f3u318a556e2f38ad7e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: carfield@carfield.com.hk References: <7b3355cb0705260757t643a45f1u19edbb901c1efc74@mail.gmail.com> <10831734.post@talk.nabble.com> <7b3355cb0705280619p4765e5f3u318a556e2f38ad7e@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org bsnyder wrote: > > Well you wanted to send a message through the broker and assert it. > This requires that you start up the broker, create a session, create a > connection, send the message and assert it. That's why I suggested > that you look at the testReceiveMessageWithConsumer() method as one > example to follow. Below is this method: > The reason that I don't want to do that is I don't really need to create a session and consumer detail myself, spring will handle it. I would like to make the test using similar functioniltiy of spring to make thing simple. Here is my simple util class of doing so, it may not really elegant but it work for me, see if anyone interested to reuse that public class TestJmsTemplate extends JmsTemplate102 { public final JmsQueueSender sender = new JmsQueueSender(); public TestJmsTemplate() throws JMSException { super(new ActiveMQConnectionFactory("vm://localhost"), false); final ActiveMQQueue activeMQQueue = new ActiveMQQueue("queue"); sender.setJt(this); sender.setQueue(activeMQQueue); } public void assertMessage(final String text) throws JMSException { final Message m = receive(sender.getQueue()); assertNotNull(m); assertEquals(text, ((TextMessage) m).getText()); } } public class JmsQueueSender { private JmsTemplate jt; private Queue queue; public void simpleSend(final String input) { jt.send(queue, new MessageCreator() { public Message createMessage(Session session) throws JMSException { return session.createTextMessage(input); } }); } public void setQueue(Queue q) { queue = q; } public void setJt(JmsTemplate jt) { this.jt = jt; } public Queue getQueue() { return queue; } } -- View this message in context: http://www.nabble.com/Question-about-unit-test-with-activemq-tf3820428s2354.html#a10852036 Sent from the ActiveMQ - User mailing list archive at Nabble.com.