use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testGetBookSubresourceParamExtensions2.
@Test
public void testGetBookSubresourceParamExtensions2() throws Exception {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class);
WebClient.getConfig(proxy).getOutInterceptors().add(new LoggingOutInterceptor());
BookSubresource bs = proxy.getBookSubresource("139");
BookBean bean = new BookBean("CXF Rocks", 139L);
bean.getComments().put(1L, "Good");
bean.getComments().put(2L, "Good");
BookBean b = bs.getTheBookQueryBean(bean);
assertEquals(139, b.getId());
assertEquals("CXF Rocks", b.getName());
}
use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testGetUnqualifiedBookSoap.
@Test
public void testGetUnqualifiedBookSoap() throws Exception {
String wsdlAddress = "http://localhost:" + PORT + "/test/services/soap-transform/bookservice?wsdl";
BookSoapService service = new BookSoapService(new URL(wsdlAddress), new QName("http://books.com", "BookService"));
BookStoreJaxrsJaxws store = service.getBookPort();
TransformOutInterceptor out = new TransformOutInterceptor();
Map<String, String> mapOut = new HashMap<>();
// Book content (id, name) is unqualified, thus the following works
// because JAXB will report
// - {http://jaxws.jaxrs.systest.cxf.apache.org/}Book
// - id
// - name
// and only the qualified top-level Book tag gets matched by the following
// mapping
mapOut.put("{http://jaxws.jaxrs.systest.cxf.apache.org/}*", "*");
out.setOutTransformElements(mapOut);
TransformInInterceptor in = new TransformInInterceptor();
Map<String, String> mapIn = new HashMap<>();
// mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
// won't work for a case where a totally unqualified getBookResponse needs to be
// qualified such that only the top-level getBookResponse is processed because of '*'.
// Such a mapping would work nicely if we had say a package-info making both
// Book id & name qualified; otherwise we need to choose what tag we need to qualify
// mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
// works too if the schema validation is disabled
mapIn.put("getBookResponse", "{http://jaxws.jaxrs.systest.cxf.apache.org/}getBookResponse");
in.setInTransformElements(mapIn);
Client cl = ClientProxy.getClient(store);
((HTTPConduit) cl.getConduit()).getClient().setReceiveTimeout(10000000);
cl.getInInterceptors().add(in);
cl.getOutInterceptors().add(out);
Book book = store.getBook(new Long(123));
assertEquals("id is wrong", book.getId(), 123);
}
Aggregations