Search in sources :

Example 41 with Book

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();
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Book(org.apache.cxf.systest.jaxrs.Book) Test(org.junit.Test)

Example 42 with Book

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());
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient)

Example 43 with Book

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());
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 44 with Book

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());
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Book(org.apache.cxf.systest.jaxrs.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 45 with Book

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);
}
Also used : Book(org.apache.cxf.systest.jaxrs.Book) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

Book (org.apache.cxf.systest.jaxrs.Book)46 Test (org.junit.Test)31 WebClient (org.apache.cxf.jaxrs.client.WebClient)22 BookStore (org.apache.cxf.systest.jaxrs.BookStore)8 JMSBookStore (org.apache.cxf.systest.jaxrs.JMSBookStore)6 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)5 Response (javax.ws.rs.core.Response)4 ArrayList (java.util.ArrayList)3 BytesMessage (javax.jms.BytesMessage)3 JAXBContext (javax.xml.bind.JAXBContext)3 InputStream (java.io.InputStream)2 ExecutionException (java.util.concurrent.ExecutionException)2 MessageProducer (javax.jms.MessageProducer)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 NotFoundException (javax.ws.rs.NotFoundException)2 ProcessingException (javax.ws.rs.ProcessingException)2 Client (javax.ws.rs.client.Client)2 ClientBuilder (javax.ws.rs.client.ClientBuilder)2 WebTarget (javax.ws.rs.client.WebTarget)2 Form (javax.ws.rs.core.Form)2