Java Code Examples for org.eclipse.microprofile.rest.client.RestClientBuilder#baseUrl()

The following examples show how to use org.eclipse.microprofile.rest.client.RestClientBuilder#baseUrl() . 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: ProvidesRestClientBuilderTest.java    From microprofile-rest-client with Apache License 2.0 6 votes vote down vote up
@Test
public void testLastBaseUriOrBaseUrlCallWins() throws Exception {
    RestClientBuilder builder = RestClientBuilder.newBuilder();
    builder = builder.register(ReturnWithURLRequestFilter.class);

    builder = builder.baseUri(new URI("http://localhost:8080/wrong1"));
    builder = builder.baseUrl(new URL("http://localhost:8080/right1"));
    SimpleGetApi client = builder.build(SimpleGetApi.class);
    assertEquals(client.executeGet().readEntity(String.class), "GET http://localhost:8080/right1");

    builder = builder.baseUrl(new URL("http://localhost:8080/wrong2"));
    builder = builder.baseUri(new URI("http://localhost:8080/wrong2b"));
    builder = builder.baseUri(new URI("http://localhost:8080/right2"));
    client = builder.build(SimpleGetApi.class);
    assertEquals(client.executeGet().readEntity(String.class), "GET http://localhost:8080/right2");
}
 
Example 2
Source File: ValidatorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static RestClientBuilder newBuilder() {
    RestClientBuilder builder = RestClientBuilder.newBuilder();
    try {
        builder = builder.baseUrl(new URL("http://localhost:8080/test"));
    } catch (MalformedURLException e) {
        fail("MalformedURL - bad testcase");
    }
    return builder;
}