本文整理了Java中org.apache.cxf.jaxrs.client.WebClient.path()
方法的一些代码示例,展示了WebClient.path()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.path()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.client.WebClient
类名称:WebClient
方法名:path
[英]Updates the current URI path
[中]更新当前URI路径
代码示例来源:origin: apache/cxf
/**
* Updates the current URI path with path segment which may contain template variables
* @param path new relative path segment
* @param values template variable values
* @return updated WebClient
*/
public WebClient path(String path, Object... values) {
URI u = new UriBuilderImpl().uri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
getState().setTemplates(getTemplateParametersMap(new URITemplate(path), Arrays.asList(values)));
return path(u.getRawPath());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetIntroChapterFromSelectedBook2() {
String address = "http://localhost:" + PORT + "/bookstore/";
WebClient wc = WebClient.create(address);
wc.path("books[id=le=123]").path("chapter");
wc.accept("application/xml");
Chapter chapter = wc.get(Chapter.class);
assertEquals("chapter 1", chapter.getTitle());
}
代码示例来源:origin: apache/cxf
@org.junit.Test
public void testGetKeys() throws Exception {
URL busFile = OIDCFlowTest.class.getResource("client.xml");
String address = "https://localhost:" + port + "/services/";
WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(),
"alice", "security", busFile.toString());
client.accept("application/json");
client.path("keys/");
Response response = client.get();
JsonWebKeys jsonWebKeys = response.readEntity(JsonWebKeys.class);
assertEquals(1, jsonWebKeys.getKeys().size());
}
代码示例来源:origin: apache/cxf
@Test(expected = InternalServerErrorException.class)
public void testUnknownParameter() throws Exception {
WebClient wc = WebClient.create("http://localhost:" + PORT);
wc.path("users/search/name==alice%3Bage==40").get(User.class);
}
代码示例来源:origin: apache/cxf
@Test
public void testResponseHasBeenReceivedWhenQueringBook() {
Response r = createWebClient("/bookstore/books").path("1").get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());
Book book = r.readEntity(Book.class);
assertEquals("1", book.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookAsyncStageAsyncResponse() throws Exception {
String address = "http://localhost:" + PORT + "/completable/booksAsync";
WebClient wc = createWebClient(address);
CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
Book book = stage.toCompletableFuture().join();
assertEquals(123L, book.getId());
}
@Test
代码示例来源:origin: apache/cxf
protected WebClient createWebClient(final String url) {
final List< ? > providers = Arrays.asList(new JacksonJsonProvider());
final WebClient wc = WebClient
.create("http://localhost:" + getPort(), providers)
.path(getContextPath())
.path(url)
.accept(MediaType.APPLICATION_JSON);
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
return wc;
}
代码示例来源:origin: apache/cxf
@Test
public void testBookWithSpace() throws Exception {
WebClient client = WebClient.create("http://localhost:" + PORT + "/bookstore/").path("the books/123");
Book book = client.get(Book.class);
assertEquals(123L, book.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testWebClientDirectDispatch() throws Exception {
WebClient localClient = WebClient.create("local://books");
WebClient.getConfig(localClient).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
localClient.path("bookstore/books/123");
Book book = localClient.get(Book.class);
assertEquals(123L, book.getId());
}
代码示例来源:origin: apache/cxf
private void doTestGetBook123WebClient(String configFile) throws Exception {
WebClient client = WebClient.create("https://localhost:" + PORT, configFile);
assertEquals("https://localhost:" + PORT, client.getBaseURI().toString());
client.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b = client.get(Book.class);
assertEquals(123, b.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testWebClientUnwrapBookWithXslt() throws Exception {
XSLTJaxbProvider<Book> provider = new XSLTJaxbProvider<>();
provider.setInTemplate("classpath:/org/apache/cxf/systest/jaxrs/resources/unwrapbook.xsl");
WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/wrapper",
Collections.singletonList(provider));
wc.path("{id}", 123);
Book book = wc.get(Book.class);
assertNotNull(book);
assertEquals(123L, book.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBook123WebClientResponse() throws Exception {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
WebClient client = WebClient.create(baseAddress);
client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b = readBook((InputStream)client.get().getEntity());
assertEquals(123, b.getId());
assertEquals("CXF in Action", b.getName());
}
代码示例来源:origin: apache/cxf
private void doTestUseParamBeanWebClient(String address) {
WebClient wc = WebClient.create(address);
wc.path("100").query("id_2", "20").query("id3", "3").query("id4", "123");
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testSearchUser() throws Exception {
WebClient wc = WebClient.create("http://localhost:" + PORT);
User user = wc.path("users/search/name==alice").get(User.class);
Assert.assertEquals("alice", user.getName());
Assert.assertEquals("smith", user.getSurname());
}
代码示例来源:origin: apache/cxf
@Test
public void testSearchUserWildcardAllowed() throws Exception {
WebClient wc = WebClient.create("http://localhost:" + PORT2);
User user = wc.path("users/search/name==a*").get(User.class);
Assert.assertEquals("alice", user.getName());
Assert.assertEquals("smith", user.getSurname());
}
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBook123WebClient() throws Exception {
String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
WebClient client = WebClient.create(baseAddress);
client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
Book b = client.get(Book.class);
assertEquals(123, b.getId());
assertEquals("CXF in Action", b.getName());
}
代码示例来源:origin: apache/cxf
@Test
public void testWebClientPipedDispatch() throws Exception {
WebClient localClient = WebClient.create("local://books");
localClient.accept("text/xml");
localClient.path("bookstore/books");
Book book = localClient.type("application/xml").post(new Book("New", 124L), Book.class);
assertEquals(124L, book.getId());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookSubresourceWebClientParamExtensions() throws Exception {
WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
Book bean = new Book("CXF Rocks", 139L);
Form form = new Form();
form.param("name", "CXF Rocks").param("id", Long.toString(139L));
Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
assertEquals(139, b.getId());
assertEquals("CXF Rocks", b.getName());
}
代码示例来源:origin: apache/cxf
@Test
public void testGetBookXSLTXml() throws Exception {
String endpointAddress =
"http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt";
WebClient wc = WebClient.create(endpointAddress);
wc.accept("application/xml").path(666).matrix("name2", 2).query("name", "Action - ");
Book b = wc.get(Book.class);
assertEquals(666, b.getId());
assertEquals("CXF in Action - 2", b.getName());
}
代码示例来源:origin: apache/cxf
@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());
}
内容来源于网络,如有侵权,请联系作者删除!