1 package argeo
.slc
.activemq
.selector
;
3 import javax
.jms
.Connection
;
4 import javax
.jms
.ConnectionFactory
;
5 import javax
.jms
.MessageConsumer
;
6 import javax
.jms
.MessageProducer
;
7 import javax
.jms
.Queue
;
8 import javax
.jms
.Session
;
9 import javax
.jms
.TextMessage
;
11 import junit
.framework
.TestCase
;
13 import org
.apache
.activemq
.ActiveMQConnectionFactory
;
14 import org
.apache
.activemq
.broker
.BrokerService
;
16 public class SelectorTest
extends AbstractActiveMqTest
{
17 // private final static Log log = LogFactory.getLog(SelectorTest.class);
19 protected BrokerService broker
;
20 protected String connectorStr
= "vm://localhost";
22 protected String propName
= "myFilter";
23 protected String propValue
= "myValue";
24 protected String txt
= "myText";
26 protected Session session
;
27 protected Queue queue
;
28 protected MessageProducer producer
;
30 public void testNoFilter() throws Exception
{
31 producer
.send(createMessage());
32 TextMessage receivedMsg
= (TextMessage
) session
.createConsumer(queue
)
34 assertMsg(receivedMsg
);
37 public void testFilterOk() throws Exception
{
38 producer
.send(createMessage());
39 MessageConsumer consumer
= session
.createConsumer(queue
, propName
40 + "='" + propValue
+ "'");
41 TextMessage receivedMsg
= (TextMessage
) consumer
.receive(2000);
42 assertMsg(receivedMsg
);
45 public void testFilterNok() throws Exception
{
46 producer
.send(createMessage());
47 MessageConsumer consumer
= session
.createConsumer(queue
, propName
49 TextMessage receivedMsg
= (TextMessage
) consumer
.receive(1000);
50 assertNull("Message reception should time out", receivedMsg
);
53 protected void setUp() throws Exception
{
54 broker
= new BrokerService();
55 broker
.setPersistent(false);
56 broker
.setUseJmx(false);
57 broker
.addConnector(connectorStr
);
63 protected void tearDown() throws Exception
{