1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package org.apache.qpid.test.unit.message;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQHeadersExchange;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.url.AMQBindingURL;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.FieldTable;
import javax.jms.*;
/**
* @author Apache Software Foundation
*/
public class JMSDestinationTest extends TestCase
{
private static final Logger _logger = Logger.getLogger(JMSDestinationTest.class);
public String _connectionString = "vm://:1";
protected void setUp() throws Exception
{
super.setUp();
TransportConnection.createVMBroker(1);
}
protected void tearDown() throws Exception
{
super.tearDown();
TransportConnection.killAllVMBrokers();
}
public void testJMSDestination() throws Exception
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Queue queue = new AMQQueue("someQ", "someQ", false, true);
MessageConsumer consumer = consumerSession.createConsumer(queue);
Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageProducer producer = producerSession.createProducer(queue);
TextMessage sentMsg = producerSession.createTextMessage("hello");
assertNull(sentMsg.getJMSDestination());
producer.send(sentMsg);
assertEquals(sentMsg.getJMSDestination(), queue);
con2.close();
con.start();
TextMessage rm = (TextMessage) consumer.receive();
assertNotNull(rm);
assertEquals(rm.getJMSDestination(),queue);
con.close();
}
}
|