Refine search
@Test public void testProxyWithCollectionMatrixParams() throws Exception { BookStore proxy = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class); List<String> params = new ArrayList<>(); params.add("12"); params.add("3"); Book book = proxy.getBookByMatrixListParams(params); assertEquals(123L, book.getId()); }
@Test public void testCheckBookClientErrorResponse() { String baseAddress = "http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress, BookStoreJaxrsJaxws.class, Collections.singletonList(new DummyResponseExceptionMapper())); Response response = proxy.checkBook(100L); assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatus()); }
@Test public void testPostNullGetEmptyCollectionProxy() throws Exception { String endpointAddress = "http://localhost:" + PORT; BookStore bs = JAXRSClientFactory.create(endpointAddress, BookStore.class); List<Book> books = bs.postBookGetCollection(null); assertNotNull(books); assertEquals(0, books.size()); }
@Test public void testGetBookFromResponseWithProxy() throws Exception { BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class); Response r = bs.getGenericResponseBook("123"); assertEquals(200, r.getStatus()); Book book = r.readEntity(Book.class); assertEquals(123L, book.getId()); }
@Test public void testGetSuperBookCollectionProxy() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, Collections.singletonList(new JacksonJsonProvider())); List<SuperBook> books = proxy.getSuperBookCollectionJson(); assertEquals(999L, books.get(0).getId()); }
@Test public void testGetSuperBookProxy() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, BookStoreSpring.class, Collections.singletonList(new JacksonJsonProvider())); SuperBook book = proxy.getSuperBookJson(); assertEquals(999L, book.getId()); }
@Test public void testEchoBookElementWildcard() throws Exception { BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class); JAXBElement<? super Book> element = store.echoBookElementWildcard( new JAXBElement<Book>(new QName("", "Book"), Book.class, new Book("CXF", 123L))); Book book = (Book)element.getValue(); assertEquals(123L, book.getId()); assertEquals("CXF", book.getName()); }
@Test public void testEchoBookElement() throws Exception { BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class); JAXBElement<Book> element = store.echoBookElement(new JAXBElement<Book>(new QName("", "Book"), Book.class, new Book("CXF", 123L))); Book book = element.getValue(); assertEquals(123L, book.getId()); assertEquals("CXF", book.getName()); }
@Test public void testEchoGenericSuperBookCollectionProxy() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/webapp/custombus/genericstore"; GenericBookStoreSpring proxy = JAXRSClientFactory.create(endpointAddress, GenericBookStoreSpring.class, Collections.singletonList(new JacksonJsonProvider())); List<SuperBook> books = proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super", 124L, true))); assertEquals(124L, books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }
@Test public void testProxyServerInFaultDirectDispatch() throws Exception { BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, "true"); WebClient.getConfig(localProxy).getInFaultInterceptors().add(new TestFaultInInterceptor()); Response r = localProxy.infault2(); assertEquals(500, r.getStatus()); }