use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class CxfSoapMessageProviderTest method testSOAPMessageModeDocLit.
@Test
public void testSOAPMessageModeDocLit() throws Exception {
JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
fromHandler.reset();
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
String response1 = new String("TestSOAPOutputPMessage");
String response2 = new String("Bonjour");
try {
Greeter greeter = service.getPort(portName, Greeter.class);
((BindingProvider) greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port + "/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
for (int idx = 0; idx < 2; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
assertEquals(response1, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
assertEquals("Can't get the right message count", fromHandler.getMessageCount(), 8);
assertEquals("Can't get the right fault count", fromHandler.getFaultCount(), 0);
//From CXF 2.2.7 the soap handler's getHeader() method will not be called if the SOAP message don't have headers
//assertEquals("Can't get the right headers count", fromHandler.getGetHeadersCount(), 4);
}
use of org.apache.hello_world_soap_http.Greeter in project camel by apache.
the class CxfOneWayRouteTest method testInvokingOneWayServiceFromCXFClient.
@Test
public void testInvokingOneWayServiceFromCXFClient() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedFileExists("target/camel-file/cxf-oneway-route");
Greeter client = getCXFClient();
client.greetMeOneWay("lemac");
// may need to wait until the oneway call completes
long waitUntil = System.currentTimeMillis() + 10000;
while (!bindingDone && System.currentTimeMillis() < waitUntil) {
Thread.sleep(1000);
}
assertMockEndpointsSatisfied();
assertNull("exception occured: " + bindingException, bindingException);
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testTimeoutConfigutation.
@Test
public void testTimeoutConfigutation() throws Exception {
SOAPService service = new SOAPService();
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
((javax.xml.ws.BindingProvider) greeter).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "1");
try {
greeter.greetMe("test");
// remove fail() check to let this test pass in the powerful machine
} catch (Throwable ex) {
Object cause = null;
if (ex.getCause() != null) {
cause = ex.getCause();
}
assertTrue("Timeout cause is expected", cause instanceof java.net.SocketTimeoutException);
}
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testAsyncDiscardProxy.
@Test
public void testAsyncDiscardProxy() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
assertNotNull(service);
updateAddressPort(greeter, PORT);
Response<GreetMeLaterResponse> r1 = greeter.greetMeLaterAsync(3000);
greeter = null;
service = null;
System.gc();
System.gc();
System.gc();
assertEquals("Hello, finally!", r1.get().getResponseType());
}
use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.
the class ClientServerTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
SOAPService service = new SOAPService();
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
try {
greeter.greetMe("test");
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals("Bonjour", reply);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> responseContext = bp.getResponseContext();
Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
assertEquals(200, responseCode.intValue());
}
Aggregations