Search in sources :

Example 11 with BookStoreJaxrsJaxws

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<Object>();
    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));
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) Test(org.junit.Test)

Example 12 with BookStoreJaxrsJaxws

use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.

the class JAXRSSoapBookTest method testGetBookSoap.

@Test
public void testGetBookSoap() throws Exception {
    String wsdlAddress = "http://localhost:" + PORT + "/test/services/soap/bookservice?wsdl";
    URL wsdlUrl = new URL(wsdlAddress);
    BookSoapService service = new BookSoapService(wsdlUrl, new QName("http://books.com", "BookService"));
    BookStoreJaxrsJaxws store = service.getBookPort();
    Book book = store.getBook(new Long(123));
    assertEquals("id is wrong", book.getId(), 123);
}
Also used : BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) BookSoapService(org.apache.cxf.systest.jaxrs.jaxws.BookSoapService) QName(javax.xml.namespace.QName) URL(java.net.URL) Test(org.junit.Test)

Example 13 with BookStoreJaxrsJaxws

use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.

the class JAXRSSoapBookTest method testPostGetBookFastinfosetProxyInterceptors.

@Test
public void testPostGetBookFastinfosetProxyInterceptors() throws Exception {
    JAXBElementProvider<Object> p = new JAXBElementProvider<Object>();
    p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset"));
    p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset"));
    BookStoreJaxrsJaxws client = JAXRSClientFactory.create("http://localhost:" + PORT + "/test/services/rest5", BookStoreSoapRestFastInfoset3.class, Collections.singletonList(p));
    Book b = new Book("CXF", 1L);
    // Just to make sure it is enforced
    Map<String, Object> props = WebClient.getConfig(client).getRequestContext();
    props.put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE);
    Book b2 = client.addFastinfoBook(b);
    assertEquals(b2.getName(), b.getName());
    assertEquals(b2.getId(), b.getId());
    checkFiInterceptors(WebClient.getConfig(client));
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) Test(org.junit.Test)

Example 14 with BookStoreJaxrsJaxws

use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.

the class JAXRSSoapBookTest method testGetBookSubresourceWebClientProxyBean.

@Test
public void testGetBookSubresourceWebClientProxyBean() throws Exception {
    WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
    client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE, MediaType.TEXT_XML_TYPE);
    BookStoreJaxrsJaxws proxy = JAXRSClientFactory.fromClient(client, BookStoreJaxrsJaxws.class, true);
    doTestSubresource(proxy);
    BookStoreJaxrsJaxws proxy2 = JAXRSClientFactory.fromClient(WebClient.client(proxy), BookStoreJaxrsJaxws.class);
    doTestSubresource(proxy2);
}
Also used : BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 15 with BookStoreJaxrsJaxws

use of org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws in project cxf by apache.

the class JAXRSSoapBookTest method testGetBookSubresourceClientNoProduces.

@Test
public void testGetBookSubresourceClientNoProduces() throws Exception {
    String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
    BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class);
    BookSubresource bs = proxy.getBookSubresource("125");
    Book b = bs.getTheBookNoProduces();
    assertEquals(125, b.getId());
    assertEquals("CXF in Action", b.getName());
}
Also used : BookStoreJaxrsJaxws(org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws) Test(org.junit.Test)

Aggregations

BookStoreJaxrsJaxws (org.apache.cxf.systest.jaxrs.jaxws.BookStoreJaxrsJaxws)22 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)3 AbstractFeature (org.apache.cxf.feature.AbstractFeature)3 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)3 URL (java.net.URL)2 NotFoundException (javax.ws.rs.NotFoundException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 QName (javax.xml.namespace.QName)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)2 BookSoapService (org.apache.cxf.systest.jaxrs.jaxws.BookSoapService)2 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 Client (org.apache.cxf.endpoint.Client)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 TransformInInterceptor (org.apache.cxf.interceptor.transform.TransformInInterceptor)1 TransformOutInterceptor (org.apache.cxf.interceptor.transform.TransformOutInterceptor)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1