@Test public void testGetBookFastinfoset() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset2"); bean.getInInterceptors().add(new FIStaxInInterceptor()); JAXBElementProvider<?> p = new JAXBElementProvider<>(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); bean.setProvider(p); Map<String, Object> props = new HashMap<>(); props.put(FIStaxInInterceptor.FI_GET_SUPPORTED, Boolean.TRUE); bean.setProperties(props); WebClient client = bean.createWebClient(); Book b = client.accept("application/fastinfoset").get(Book.class); assertEquals("CXF2", b.getName()); assertEquals(2L, b.getId()); }
@Test public void testPostGetBookFastinfosetProxy() throws Exception { JAXBElementProvider<Object> p = new JAXBElementProvider<>(); 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)); }
@Test public void testPostGetBookFastinfosetProxyInterceptors() throws Exception { JAXBElementProvider<Object> p = new JAXBElementProvider<>(); 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)); }
@Test public void testPostGetBookFastinfoset() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset"); bean.getOutInterceptors().add(new FIStaxOutInterceptor()); bean.getInInterceptors().add(new FIStaxInInterceptor()); JAXBElementProvider<?> p = new JAXBElementProvider<>(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset")); bean.setProvider(p); Map<String, Object> props = new HashMap<>(); props.put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE); bean.setProperties(props); WebClient client = bean.createWebClient(); Book b = new Book("CXF", 1L); Book b2 = client.type("application/fastinfoset").accept("application/fastinfoset") .post(b, Book.class); assertEquals(b2.getName(), b.getName()); assertEquals(b2.getId(), b.getId()); }