1 17 package org.apache.activemq.transport.tcp; 18 19 import org.apache.activemq.ActiveMQConnectionFactory; 20 import org.apache.activemq.EmbeddedBrokerTestSupport; 21 import org.apache.activemq.broker.BrokerService; 22 23 import javax.jms.Connection ; 24 import javax.jms.JMSException ; 25 26 29 public class TransportUriTest extends EmbeddedBrokerTestSupport { 30 31 private String postfix = "?tcpNoDelay=true&keepAlive=true"; 32 private Connection connection; 33 34 public void testUriOptionsWork() throws Exception { 35 String uri = bindAddress + postfix; 36 38 connection = new ActiveMQConnectionFactory(uri).createConnection(); 39 connection.start(); 40 } 41 42 public void testBadVersionNumberDoesNotWork() throws Exception { 43 String uri = bindAddress + postfix + "&minmumWireFormatVersion=65535"; 44 46 try { 47 connection = new ActiveMQConnectionFactory(uri).createConnection(); 48 connection.start(); 49 fail("Should have thrown an exception!"); 50 } 51 catch (Exception expected) { 52 } 53 } 54 55 56 public void testBadPropertyNameFails() throws Exception { 57 String uri = bindAddress + postfix + "&cheese=abc"; 58 60 try { 61 connection = new ActiveMQConnectionFactory(uri).createConnection(); 62 connection.start(); 63 fail("Should have thrown an exception!"); 64 } 65 catch (Exception expected) { 66 } 67 } 68 69 70 protected void setUp() throws Exception { 71 bindAddress = "tcp://localhost:6161"; 72 super.setUp(); 73 } 74 75 protected void tearDown() throws Exception { 76 if (connection != null) { 77 try { 78 connection.close(); 79 } 80 catch (JMSException e) { 81 e.printStackTrace(); 82 } 83 } 84 super.tearDown(); 85 } 86 87 protected BrokerService createBroker() throws Exception { 88 BrokerService answer = new BrokerService(); 89 answer.setUseJmx(false); 90 answer.setPersistent(isPersistent()); 91 answer.addConnector(bindAddress); 92 return answer; 93 } 94 } 95 | Popular Tags |