use of org.apache.cxf.systest.jaxrs.BookStore in project cxf by apache.
the class JAXRSHttpsBookTest method testGetBook123WebClientToProxy.
@Test
public void testGetBook123WebClientToProxy() throws Exception {
WebClient wc = WebClient.create("https://localhost:" + PORT, CLIENT_CONFIG_FILE1);
wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b = wc.get(Book.class);
assertEquals(123, b.getId());
wc.back(true);
BookStore bs = JAXRSClientFactory.fromClient(wc, BookStore.class);
Book b2 = bs.getSecureBook("123");
assertEquals(b2.getId(), 123);
}
use of org.apache.cxf.systest.jaxrs.BookStore in project cxf by apache.
the class JAXRSHttpsBookTest method testGetBook123ProxyToWebClient.
@Test
public void testGetBook123ProxyToWebClient() throws Exception {
BookStore bs = JAXRSClientFactory.create("https://localhost:" + PORT, BookStore.class, CLIENT_CONFIG_FILE1);
Book b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
WebClient wc = WebClient.fromClient(WebClient.client(bs));
wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b2 = wc.get(Book.class);
assertEquals(123, b2.getId());
}
use of org.apache.cxf.systest.jaxrs.BookStore in project cxf by apache.
the class JAXRSHttpsBookTest method doTestGetBook123Proxy.
private void doTestGetBook123Proxy(String configFile) throws Exception {
BookStore bs = JAXRSClientFactory.create("https://localhost:" + PORT, BookStore.class, configFile);
// just to verify the interface call goes through CGLIB proxy too
assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
Book b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
b = bs.getSecureBook("123");
assertEquals(b.getId(), 123);
}
use of org.apache.cxf.systest.jaxrs.BookStore in project cxf by apache.
the class JAXRSHttpsBookTest method testGetBook123ProxyFromSpringWildcard.
@Test
public void testGetBook123ProxyFromSpringWildcard() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { CLIENT_CONFIG_FILE4 });
Object bean = ctx.getBean("bookService.proxyFactory");
assertNotNull(bean);
JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
BookStore bs = cfb.create(BookStore.class);
assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
WebClient wc = WebClient.fromClient(WebClient.client(bs));
assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
wc.accept("application/xml");
wc.path("bookstore/securebooks/123");
TheBook b = wc.get(TheBook.class);
assertEquals(b.getId(), 123);
b = wc.get(TheBook.class);
assertEquals(b.getId(), 123);
ctx.close();
}
use of org.apache.cxf.systest.jaxrs.BookStore in project cxf by apache.
the class CircuitBreakerFailoverTest method testSequentialStrategyUnavailableAlternatives.
@Test(expected = FailoverFailedException.class)
public void testSequentialStrategyUnavailableAlternatives() throws Exception {
FailoverFeature feature = getFeature(false, "http://localhost:" + NON_PORT + "/non-existent", "http://localhost:" + NON_PORT + "/non-existent2");
final BookStore bookStore = getBookStore("http://localhost:" + NON_PORT + "/non-existent", feature);
// Second iteration should not call any URL as all targets are not available.
for (int i = 0; i < 2; ++i) {
try {
bookStore.getBook(1);
fail("Exception expected");
} catch (ProcessingException ex) {
if (ex.getCause() instanceof FailoverFailedException) {
throw (FailoverFailedException) ex.getCause();
}
}
}
}
Aggregations