protected String getCurrentEndpointAddress(Object client) { String currentBaseURI = WebClient.client(client).getBaseURI().toString(); String currentURI = WebClient.client(client).getCurrentURI().toString(); assertTrue(currentURI.startsWith(currentBaseURI)); return currentBaseURI; }
@Test public void testThatClientDiscoversServiceProperly() throws Exception { BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class, "org/apache/cxf/systest/jaxrs/discovery/jaxrs-http-client.xml"); assertEquals("http://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); BookWithValidation book = bs.getBook("123"); assertEquals(book.getId(), "123"); }
syncopeTopologyNode.setY(origY); final URI uri = WebClient.client(BaseRestClient.getSyncopeService()).getBaseURI(); syncopeTopologyNode.setHost(uri.getHost()); syncopeTopologyNode.setPort(uri.getPort());
private void doTestGetBook123Proxy(String configFile) throws Exception { BookStore bs = JAXRSClientFactory.create("https://localhost:" + PORT, BookStore.class, configFile); // just to verify the interface call goes through CGLIB proxy too assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); Book b = bs.getSecureBook("123"); assertEquals(b.getId(), 123); b = bs.getSecureBook("123"); assertEquals(b.getId(), 123); }
@Test public void testGetBook123ProxyFromSpringWildcard() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {CLIENT_CONFIG_FILE4}); Object bean = ctx.getBean("bookService.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean; BookStore bs = cfb.create(BookStore.class); assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); WebClient wc = WebClient.fromClient(WebClient.client(bs)); assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); wc.accept("application/xml"); wc.path("bookstore/securebooks/123"); TheBook b = wc.get(TheBook.class); assertEquals(b.getId(), 123); b = wc.get(TheBook.class); assertEquals(b.getId(), 123); ctx.close(); }
private void doTestGetBook123ProxyFromSpring(String cfgFile) throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {cfgFile}); Object bean = ctx.getBean("bookService.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean; Bus bus = cfb.getBus(); ClientLifeCycleManager manager = bus.getExtension(ClientLifeCycleManager.class); TestClientLifeCycleListener listener = new TestClientLifeCycleListener(); manager.registerListener(listener); BookStore bs = cfb.create(BookStore.class); assertNotNull(listener.getEp()); assertEquals("{http://service.rs}BookService", listener.getEp().getEndpointInfo().getName().toString()); assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); Book b = bs.getSecureBook("123"); assertEquals(b.getId(), 123); b = bs.getSecureBook("123"); assertEquals(b.getId(), 123); ctx.close(); }
private void doTestGetBook123Proxy(String configFile) throws Exception { BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class, configFile); WebClient.getConfig(bs).getOutInterceptors().add(new LoggingOutInterceptor()); SpnegoAuthSupplier authSupplier = new SpnegoAuthSupplier(); authSupplier.setServicePrincipalName("bob@service.ws.apache.org"); authSupplier.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE); WebClient.getConfig(bs).getHttpConduit().setAuthSupplier(authSupplier); // just to verify the interface call goes through CGLIB proxy too Assert.assertEquals("http://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString()); Book b = bs.getBook("123"); Assert.assertEquals(b.getId(), 123); b = bs.getBook("123"); Assert.assertEquals(b.getId(), 123); }