use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class XMLStreamDataReaderTest method testReadWrapper.
@Test
public void testReadWrapper() throws Exception {
JAXBDataBinding db = getDataBinding(GreetMe.class);
reader = getTestReader("../resources/GreetMeDocLiteralReq.xml");
assertNotNull(reader);
DataReader<XMLStreamReader> dr = db.createReader(XMLStreamReader.class);
assertNotNull(dr);
Object val = dr.read(reader);
assertNotNull(val);
assertTrue(val instanceof GreetMe);
assertEquals("TestSOAPInputPMessage", ((GreetMe) val).getRequestType());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteWithContextualNamespaceDecls.
@Test
public void testWriteWithContextualNamespaceDecls() throws Exception {
JAXBDataBinding db = getTestWriterFactory(GreetMe.class);
Map<String, String> nspref = new HashMap<>();
nspref.put("http://apache.org/hello_world_soap_http/types", "x");
db.setNamespaceMap(nspref);
db.setContextualNamespaceMap(nspref);
// use the output stream instead of XMLStreamWriter to test
DataWriter<OutputStream> dw = db.createWriter(OutputStream.class);
assertNotNull(dw);
GreetMe val = new GreetMe();
val.setRequestType("Hello");
dw.write(val, baos);
String xstr = new String(baos.toByteArray());
// there should be no namespace decls
if (!db.getContext().getClass().getName().contains("eclipse")) {
// bug in eclipse moxy
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=421463
assertEquals("<x:greetMe><x:requestType>Hello</x:requestType></x:greetMe>", xstr);
}
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteWithNamespacePrefixMapping.
@Test
public void testWriteWithNamespacePrefixMapping() throws Exception {
JAXBDataBinding db = getTestWriterFactory(GreetMe.class);
Map<String, String> nspref = new HashMap<>();
nspref.put("http://apache.org/hello_world_soap_http/types", "x");
db.setNamespaceMap(nspref);
// use the output stream instead of XMLStreamWriter to test
DataWriter<OutputStream> dw = db.createWriter(OutputStream.class);
assertNotNull(dw);
GreetMe val = new GreetMe();
val.setRequestType("Hello");
dw.write(val, baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
StaxUtils.toNextElement(reader);
QName qname = reader.getName();
assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMe"), qname);
assertEquals("x", qname.getPrefix());
assertEquals(1, reader.getNamespaceCount());
assertEquals("http://apache.org/hello_world_soap_http/types", reader.getNamespaceURI(0));
assertEquals("x", reader.getNamespacePrefix(0));
StaxUtils.nextEvent(reader);
StaxUtils.toNextElement(reader);
qname = reader.getName();
assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"), qname);
assertEquals("x", qname.getPrefix());
StaxUtils.nextEvent(reader);
StaxUtils.toNextText(reader);
assertEquals("Hello", reader.getText());
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class DispatchClientServerTest method testJAXBObjectPAYLOADWithFeature.
@Test
public void testJAXBObjectPAYLOADWithFeature() throws Exception {
createBus("org/apache/cxf/systest/dispatch/client-config.xml");
BusFactory.setThreadDefaultBus(bus);
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
String endpointUrl = "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort";
Service service = Service.create(wsdl, SERVICE_NAME);
service.addPort(PORT_NAME, bindingId, endpointUrl);
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
String expected = "Hello Jeeves";
GreetMe greetMe = new GreetMe();
greetMe.setRequestType("Jeeves");
Object response = disp.invoke(greetMe);
assertNotNull(response);
String responseValue = ((GreetMeResponse) response).getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue));
assertEquals("Feature should be applied", 1, TestDispatchFeature.getCount());
assertEquals("Feature based interceptors should be added", 1, TestDispatchFeature.getCount());
assertEquals("Feature based In interceptors has be added to in chain.", 1, TestDispatchFeature.getInInterceptorCount());
assertEquals("Feature based interceptors has to be added to out chain.", 1, TestDispatchFeature.getOutInterceptorCount());
bus.shutdown(true);
}
use of org.apache.hello_world_soap_http.types.GreetMe in project cxf by apache.
the class DispatchClientServerTest method doJAXBPayload.
private void doJAXBPayload(Dispatch<Object> disp) throws Exception {
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
String expected = "Hello Jeeves";
GreetMe greetMe = new GreetMe();
greetMe.setRequestType("Jeeves");
Object response = disp.invoke(greetMe);
assertNotNull(response);
String responseValue = ((GreetMeResponse) response).getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue));
// Test oneway
disp.invokeOneWay(greetMe);
// Test async polling
Response<Object> response2 = disp.invokeAsync(greetMe);
assertNotNull(response2);
GreetMeResponse greetMeResponse = (GreetMeResponse) response2.get();
String responseValue2 = greetMeResponse.getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue2));
// Test async callback
TestJAXBHandler tjbh = new TestJAXBHandler();
Future<?> fd = disp.invokeAsync(greetMe, tjbh);
assertNotNull(fd);
waitForFuture(fd);
String responseValue3 = ((GreetMeResponse) tjbh.getResponse()).getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue3));
org.apache.hello_world_soap_http.types.TestDocLitFault fr = new org.apache.hello_world_soap_http.types.TestDocLitFault();
fr.setFaultType(BadRecordLitFault.class.getSimpleName());
tjbh = new TestJAXBHandler();
fd = disp.invokeAsync(fr, tjbh);
waitForFuture(fd);
try {
fd.get();
fail("did not get expected exception");
} catch (ExecutionException ex) {
// expected
}
GreetMeLater later = new GreetMeLater();
later.setRequestType(1000);
HTTPClientPolicy pol = new HTTPClientPolicy();
pol.setReceiveTimeout(100);
disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
Response<Object> o = disp.invokeAsync(later);
try {
o.get(10, TimeUnit.SECONDS);
fail("Should have gotten a SocketTimeoutException");
} catch (ExecutionException ex) {
assertTrue(ex.getCause() instanceof SocketTimeoutException);
}
later.setRequestType(20000);
pol.setReceiveTimeout(20000);
disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
o = disp.invokeAsync(later);
try {
o.get(100, TimeUnit.MILLISECONDS);
fail("Should have gotten a SocketTimeoutException");
} catch (TimeoutException ex) {
// ignore - expected
}
}
Aggregations