Java Code Examples for org.apache.cxf.jaxrs.client.JAXRSClientFactory#fromClient()
The following examples show how to use
org.apache.cxf.jaxrs.client.JAXRSClientFactory#fromClient() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRSMultithreadedClientTest.java From cxf with Apache License 2.0 | 7 votes |
private void runProxies(BookStore proxy, int numberOfClients, boolean threadSafe, boolean stateCanBeChanged) throws Exception { ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); CountDownLatch startSignal = new CountDownLatch(1); CountDownLatch doneSignal = new CountDownLatch(numberOfClients); for (int i = 1; i <= numberOfClients; i++) { // here we do a double copy : from proxy to web client and back to proxy BookStore bs = !threadSafe ? JAXRSClientFactory.fromClient( WebClient.fromClient(WebClient.client(proxy)), BookStore.class) : proxy; String bookName = stateCanBeChanged ? Integer.toString(i) : "TheBook"; String bookHeader = stateCanBeChanged ? "value" + i : "CustomValue"; executor.execute(new RootProxyWorker(bs, bookName, bookHeader, startSignal, doneSignal, stateCanBeChanged)); } startSignal.countDown(); doneSignal.await(60, TimeUnit.SECONDS); executor.shutdownNow(); assertEquals("Not all invocations have completed", 0, doneSignal.getCount()); }
Example 2
Source File: JAXRSSoapBookTest.java From cxf with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: ForgeClient.java From fabric8-forge with Apache License 2.0 | 5 votes |
/** * Creates a JAXRS web client for the given JAXRS client */ protected <T> T createWebClient(Class<T> clientType) { List<Object> providers = WebClients.createProviders(); String queryString = "?secret=" + secret + "&secretNamespace=" + secretNamespace + "&kubeUserName=" + kubeUserName; String commandsAddress = URLUtils.pathJoin(this.address, "/api/forge" + queryString); WebClient webClient = WebClient.create(commandsAddress, providers); disableSslChecks(webClient); HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(connectionTimeoutMillis); httpClientPolicy.setReceiveTimeout(connectionTimeoutMillis); conduit.setClient(httpClientPolicy); return JAXRSClientFactory.fromClient(webClient, clientType); }
Example 4
Source File: JAXRSHttpsBookTest.java From cxf with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: JAXRSSoapBookTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testGetBookSubresourceWebClientProxy2() throws Exception { WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest/bookstore") .path("/books/378"); client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE); BookSubresource proxy = JAXRSClientFactory.fromClient(client, BookSubresource.class); Book b = proxy.getTheBook2("CXF ", "in ", "Acti", "on ", "- 3", "7", "8"); assertEquals(378, b.getId()); assertEquals("CXF in Action - 378", b.getName()); }