use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRS20HttpsBookTest method testGetBook.
@Test
public void testGetBook() throws Exception {
ClientBuilder builder = ClientBuilder.newBuilder();
try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", this.getClass())) {
KeyStore trustStore = loadStore(keystore, "password");
builder.trustStore(trustStore);
}
builder.hostnameVerifier(new AllowAllHostnameVerifier());
try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Morpit.jks", this.getClass())) {
KeyStore keyStore = loadStore(keystore, "password");
builder.keyStore(keyStore, "password");
}
Client client = builder.build();
client.register(new LoggingFeature());
WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
assertEquals(123, b.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRS20HttpsBookTest method testGetBookSslContext.
@Test
public void testGetBookSslContext() throws Exception {
ClientBuilder builder = ClientBuilder.newBuilder();
SSLContext sslContext = createSSLContext();
builder.sslContext(sslContext);
builder.hostnameVerifier(new AllowAllHostnameVerifier());
Client client = builder.build();
WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
assertEquals(123, b.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSHttpsBookTest method doTestGetBook123ProxyFromSpring.
private void doTestGetBook123ProxyFromSpring(String cfgFile) throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { cfgFile });
Object bean = ctx.getBean("bookService.proxyFactory");
assertNotNull(bean);
JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
Bus bus = cfb.getBus();
ClientLifeCycleManager manager = bus.getExtension(ClientLifeCycleManager.class);
TestClientLifeCycleListener listener = new TestClientLifeCycleListener();
manager.registerListener(listener);
BookStore bs = cfb.create(BookStore.class);
assertNotNull(listener.getEp());
assertEquals("{http://service.rs}BookService", listener.getEp().getEndpointInfo().getName().toString());
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);
ctx.close();
}
use of org.apache.cxf.systest.jaxrs.Book 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.Book 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());
}
Aggregations