use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSHttpsBookTest method testCustomVerbProxyFromSpringWildcard.
@Test
public void testCustomVerbProxyFromSpringWildcard() throws Exception {
if (System.getProperty("java.version").startsWith("9")) {
// CXF-7270
return;
}
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { CLIENT_CONFIG_FILE3 });
Object bean = ctx.getBean("bookService.proxyFactory");
assertNotNull(bean);
JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
BookStore bs = cfb.create(BookStore.class);
WebClient.getConfig(bs).getRequestContext().put("use.httpurlconnection.method.reflection", true);
// CXF RS Client code will set this property to true if the http verb is unknown
// and this property is not already set. The async conduit is loaded in the tests module
// but we do want to test HTTPUrlConnection reflection hence we set this property to false
WebClient.getConfig(bs).getRequestContext().put("use.async.http.conduit", false);
Book book = bs.retrieveBook(new Book("Retrieve", 123L));
assertEquals("Retrieve", book.getName());
ctx.close();
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSHttpsBookTest method doTestGetBook123WebClient.
private void doTestGetBook123WebClient(String configFile) throws Exception {
WebClient client = WebClient.create("https://localhost:" + PORT, configFile);
assertEquals("https://localhost:" + PORT, client.getBaseURI().toString());
client.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b = client.get(Book.class);
assertEquals(123, b.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJaasSecurityTest method testJaasFilterWebClientAuthorizationPolicy2.
@Test
public void testJaasFilterWebClientAuthorizationPolicy2() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123";
WebClient wc = WebClient.create(endpointAddress, "bob", "bobspassword", null);
// WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
wc.accept("application/xml");
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSJaasSecurityTest method testJaasFilterWebClientAuthorizationPolicy.
@Test
public void testJaasFilterWebClientAuthorizationPolicy() throws Exception {
String endpointAddress = "http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123";
WebClient wc = WebClient.create(endpointAddress);
AuthorizationPolicy pol = new AuthorizationPolicy();
pol.setUserName("bob");
pol.setPassword("bobspassword");
WebClient.getConfig(wc).getHttpConduit().setAuthorization(pol);
wc.accept("application/xml");
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());
}
use of org.apache.cxf.systest.jaxrs.Book in project cxf by apache.
the class JAXRSSpringSecurityClassTest method readBook.
private Book readBook(InputStream is) throws Exception {
JAXBContext c = JAXBContext.newInstance(new Class[] { Book.class });
Unmarshaller u = c.createUnmarshaller();
return (Book) u.unmarshal(is);
}
Aggregations