Skip to content

Commit

Permalink
Add support to the embedded broker an such to pass extra params to th…
Browse files Browse the repository at this point in the history
…e broker url to work around AMQ-3879 to try and make the tests more reliable.

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1371778 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Aug 10, 2012
1 parent 0b9abc2 commit 672b8d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {

@BeforeClass
public static void startServers() throws Exception {
broker = new EmbeddedJMSBrokerLauncher("vm://JMSClientServerTest");
broker = new EmbeddedJMSBrokerLauncher("vm://JMSClientServerTest?jms.watchTopicAdvisories=false");
launchServer(broker);
launchServer(new Server(broker));
createStaticBus();
Expand Down Expand Up @@ -1203,7 +1203,7 @@ private void specNoWsdlService(String messageType) throws Exception {
+ "?jndiInitialContextFactory"
+ "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
+ broker.getBrokerURL();
+ broker.getEncodedBrokerURL();
if (messageType != null) {
address = address + "&messageType=" + messageType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ protected void run() {
+ "?jndiInitialContextFactory"
+ "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
+ broker.getBrokerURL();
+ broker.getEncodedBrokerURL();
Endpoint.publish(address1, spec1);

Object spec2 = new GreeterSpecWithPortError();
String address2 = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue5"
+ "?jndiInitialContextFactory"
+ "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
+ broker.getBrokerURL();
+ broker.getEncodedBrokerURL();
Endpoint.publish(address2, spec2);

initNoWsdlServer();
Expand All @@ -113,7 +113,7 @@ private void initNoWsdlServer() {
+ "?jndiInitialContextFactory"
+ "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
+ broker.getBrokerURL();
+ broker.getEncodedBrokerURL();
Hello implementor = new HelloImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(Hello.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void run() {
factory.setTransportId("http://cxf.apache.org/transports/jms");
factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceHttpPort"));
factory.setAddress(ADDRESS + broker.getBrokerURL());
factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
factory.setServiceBean(new SwAServiceImpl());
factory.create().start();
} catch (Exception e) {
Expand All @@ -67,7 +67,7 @@ protected void run() {

@BeforeClass
public static void startServers() throws Exception {
broker = new EmbeddedJMSBrokerLauncher("vm://ClientServerSwaTest");
broker = new EmbeddedJMSBrokerLauncher("vm://ClientServerSwaTest?jms.watchTopicAdvisories=false");
System.setProperty("EmbeddedBrokerURL", broker.getBrokerURL());
launchServer(broker);
launchServer(new Server());
Expand All @@ -84,7 +84,7 @@ public void testSwa() throws Exception {
factory.setTransportId("http://cxf.apache.org/transports/jms");
factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceHttpPort"));
factory.setAddress(ADDRESS + broker.getBrokerURL());
factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
SwAService port = factory.create(SwAService.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,36 @@ public EmbeddedJMSBrokerLauncher(String url) {
public String getBrokerURL() {
return brokerUrl1;
}
public String getEncodedBrokerURL() {
StringBuilder b = new StringBuilder(brokerUrl1.length());
for (int x = 0; x < brokerUrl1.length(); x++) {
char c = brokerUrl1.charAt(x);
switch (c) {
case '?':
b.append("%3F");
break;
default:
b.append(c);
}
}
return b.toString();
}
public void updateWsdl(Bus b, String wsdlLocation) {
updateWsdlExtensors(b, wsdlLocation, brokerUrl1);
updateWsdlExtensors(b, wsdlLocation, brokerUrl1, getEncodedBrokerURL());
}

public static void updateWsdlExtensors(Bus bus,
String wsdlLocation) {
updateWsdlExtensors(bus, wsdlLocation, "tcp://localhost:" + PORT);
updateWsdlExtensors(bus, wsdlLocation, "tcp://localhost:" + PORT, null);
}
public static void updateWsdlExtensors(Bus bus,
String wsdlLocation,
String url) {
String url,
String encodedUrl) {
try {
if (encodedUrl == null) {
encodedUrl = url;
}
if (bus == null) {
bus = BusFactory.getThreadDefaultBus();
}
Expand All @@ -85,7 +103,7 @@ public static void updateWsdlExtensors(Bus bus,
if (idx != -1) {
int idx2 = add.indexOf("&", idx);
add = add.substring(0, idx)
+ "jndiURL=" + url
+ "jndiURL=" + encodedUrl
+ (idx2 == -1 ? "" : add.substring(idx2));
((SOAPAddress)e).setLocationURI(add);
}
Expand Down

0 comments on commit 672b8d4

Please sign in to comment.