@Test
public void testConnectionsWithinSpring() throws Exception {
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext(
new String[] {"/org/apache/cxf/systest/jms/JMSClients.xml"});
String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
broker.updateWsdl((Bus)ctx.getBean("cxf"), wsdlString2);
HelloWorldPortType greeter = (HelloWorldPortType)ctx.getBean("jmsRPCClient");
assertNotNull(greeter);
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
try {
for (int idx = 0; idx < 5; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = response1 + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
try {
greeter.testRpcLitFault("BadRecordLitFault");
fail("Should have thrown BadRecoedLitFault");
} catch (BadRecordLitFault ex) {
assertNotNull(ex.getFaultInfo());
}
try {
greeter.testRpcLitFault("NoSuchCodeLitFault");
fail("Should have thrown NoSuchCodeLitFault exception");
} catch (NoSuchCodeLitFault nslf) {
assertNotNull(nslf.getFaultInfo());
assertNotNull(nslf.getFaultInfo().getCode());
}
}
} catch (UndeclaredThrowableException ex) {
throw (Exception)ex.getCause();
}
HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort)ctx.getBean("jmsQueueOneWayServiceClient");
assertNotNull(greeter1);
try {
greeter1.greetMeOneWay("hello");
} catch (Exception ex) {
fail("There should not throw the exception" + ex);
}
ctx.close();
BusFactory.setDefaultBus(getBus());
BusFactory.setThreadDefaultBus(getBus());
}