1 18 package org.apache.activemq.proxy; 19 20 import javax.jms.DeliveryMode ; 21 22 import org.apache.activemq.broker.StubConnection; 23 import org.apache.activemq.command.ActiveMQDestination; 24 import org.apache.activemq.command.ConnectionInfo; 25 import org.apache.activemq.command.ConsumerInfo; 26 import org.apache.activemq.command.Message; 27 import org.apache.activemq.command.ProducerInfo; 28 import org.apache.activemq.command.SessionInfo; 29 30 import junit.framework.Test; 31 32 33 public class ProxyConnectorTest extends ProxyTestSupport { 34 35 public static Test suite() { 36 return suite(ProxyConnectorTest.class); 37 } 38 39 public static void main(String [] args) { 40 junit.textui.TestRunner.run(suite()); 41 } 42 43 public ActiveMQDestination destination; 44 public byte destinationType; 45 public int deliveryMode; 46 47 public void setUp() throws Exception { 48 super.setAutoFail(true); 49 super.setUp(); 50 } 51 52 public void initCombosForTestSendAndConsume() { 53 addCombinationValues( "deliveryMode", new Object []{ 54 new Integer (DeliveryMode.NON_PERSISTENT), 55 new Integer (DeliveryMode.PERSISTENT) 56 } ); 57 addCombinationValues( "destinationType", new Object []{ 58 new Byte (ActiveMQDestination.TOPIC_TYPE), 59 } ); 60 } 61 public void testSendAndConsume() throws Exception { 62 63 StubConnection connection1 = createProxyConnection(); 65 ConnectionInfo connectionInfo1 = createConnectionInfo(); 66 SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1); 67 ProducerInfo producerInfo = createProducerInfo(sessionInfo1); 68 connection1.send(connectionInfo1); 69 connection1.send(sessionInfo1); 70 connection1.send(producerInfo); 71 72 destination = createDestinationInfo(connection1, connectionInfo1, destinationType); 73 ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination); 74 connection1.send(consumerInfo1); 75 76 StubConnection connection2 = createRemoteProxyConnection(); 78 ConnectionInfo connectionInfo2 = createConnectionInfo(); 79 SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2); 80 connection2.send(connectionInfo2); 81 connection2.send(sessionInfo2); 82 83 ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination); 84 connection2.send(consumerInfo2); 85 86 try { 89 Thread.sleep(1000); 90 } catch (Exception e) { 91 e.printStackTrace(); 92 } 93 94 connection1.request(createMessage(producerInfo, destination, deliveryMode)); 96 97 Message m; 99 m = receiveMessage(connection1); 100 assertNotNull(m); 101 assertNoMessagesLeft(connection1); 102 103 m = receiveMessage(connection2); 104 assertNotNull(m); 105 assertNoMessagesLeft(connection2); 106 107 } 108 109 110 } 111 | Popular Tags |