use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testCheckBookClientException.
@Test(expected = NotFoundException.class)
public void testCheckBookClientException() {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class, Collections.singletonList(new NotFoundResponseExceptionMapper()));
proxy.checkBook(100L);
}
use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testAddGetBook123Client.
@Test
public void testAddGetBook123Client() throws Exception {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class);
Book b = new Book();
b.setId(124);
b.setName("CXF in Action - 2");
Book b2 = proxy.addBook(b);
assertNotSame(b, b2);
assertEquals(124, b2.getId());
assertEquals("CXF in Action - 2", b2.getName());
}
use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testClientFaultOutInterceptor.
@Test
public void testClientFaultOutInterceptor() throws Exception {
// testing faults created by client out interceptor chain handled correctly
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(baseAddress);
bean.setResourceClass(BookStoreJaxrsJaxws.class);
final boolean addBadOutInterceptor = true;
TestFeature testFeature = new TestFeature(addBadOutInterceptor);
List<AbstractFeature> features = new ArrayList<>();
features.add(testFeature);
bean.setFeatures(features);
BookStoreJaxrsJaxws proxy = (BookStoreJaxrsJaxws) bean.create();
try {
// 321 is special case - causes error code of 525
proxy.getBook(Long.valueOf("123"));
fail("Method should have thrown an exception");
} catch (Exception e) {
assertTrue("Out Interceptor not invoked", testFeature.handleMessageOnOutInterceptorCalled());
assertFalse("In Interceptor not invoked", testFeature.handleMessageOnInInterceptorCalled());
assertTrue("Wrong exception caught", "fault from bad interceptor".equals(e.getCause().getMessage()));
assertTrue("Client In Fault In Interceptor was invoked", testFeature.faultInInterceptorCalled());
}
}
use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testPostGetBookFastinfosetProxy.
@Test
public void testPostGetBookFastinfosetProxy() throws Exception {
JAXBElementProvider<Object> p = new JAXBElementProvider<>();
p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset"));
p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset"));
BookStoreJaxrsJaxws client = JAXRSClientFactory.create("http://localhost:" + PORT + "/test/services/rest4", BookStoreSoapRestFastInfoset2.class, Collections.singletonList(p));
Book b = new Book("CXF", 1L);
Book b2 = client.addFastinfoBook(b);
assertEquals(b2.getName(), b.getName());
assertEquals(b2.getId(), b.getId());
checkFiInterceptors(WebClient.getConfig(client));
}
use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.
the class JAXRSSoapBookTest method testGetBookSubresourceClientFormParam.
@Test
public void testGetBookSubresourceClientFormParam() throws Exception {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class);
BookSubresource bs = proxy.getBookSubresource("679");
List<String> parts = new ArrayList<>();
parts.add("CXF in Action - ");
parts.add(Integer.toString(679));
Book b = bs.getTheBook3("679", parts);
assertEquals(679, b.getId());
assertEquals("CXF in Action - 679", b.getName());
}
Aggregations