use of org.eclipse.microprofile.rest.client.RestClientBuilder in project wildfly-swarm by wildfly-swarm.
the class RestClientDelegateBean method create.
@Override
public Object create(CreationalContext<Object> creationalContext) {
RestClientBuilder builder = RestClientBuilder.newBuilder();
String baseUrl = getBaseUrl();
try {
return builder.baseUrl(new URL(baseUrl)).build(proxyType);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("The value of URL was invalid " + baseUrl);
}
}
use of org.eclipse.microprofile.rest.client.RestClientBuilder in project Payara by payara.
the class PersonControllerClientHelper method getBasicPersonControllerClient.
public static PersonControllerClient getBasicPersonControllerClient(URL deploymentUrl, String username, String password) {
try {
RestClientBuilder builder = RestClientBuilder.newBuilder();
builder.register(HttpAuthenticationFeature.basic(username, password));
PersonControllerClient client = builder.baseUrl(new URL(deploymentUrl.toURI().toString() + "resources/")).build(PersonControllerClient.class);
return client;
} catch (URISyntaxException | MalformedURLException ex) {
throw new IllegalStateException(ex);
}
}
use of org.eclipse.microprofile.rest.client.RestClientBuilder in project Payara by payara.
the class PersonControllerClientHelper method getPersonControllerClient.
public static PersonControllerClient getPersonControllerClient(URL deploymentUrl, String username, String password) {
try {
RestClientBuilder builder = RestClientBuilder.newBuilder();
builder.register((ClientRequestFilter) context -> {
context.getHeaders().add("username", DEFAULT_USER);
context.getHeaders().add("password", DEFAULT_PASSWORD);
});
PersonControllerClient client = builder.baseUrl(new URL(deploymentUrl.toURI().toString() + "resources/")).build(PersonControllerClient.class);
return client;
} catch (URISyntaxException | MalformedURLException ex) {
throw new IllegalStateException(ex);
}
}
use of org.eclipse.microprofile.rest.client.RestClientBuilder in project cxf by apache.
the class CxfTypeSafeClientBuilderTest method testConfigMethods.
@Test
public void testConfigMethods() {
RestClientBuilder builder = RestClientBuilder.newBuilder();
assertEquals("y", builder.property("x", "y").getConfiguration().getProperty("x"));
assertTrue(builder.register(HighPriorityMBW.class).getConfiguration().isRegistered(HighPriorityMBW.class));
HighPriorityMBW mbw = new HighPriorityMBW(1);
assertTrue(builder.register(mbw).getConfiguration().isRegistered(mbw));
}
use of org.eclipse.microprofile.rest.client.RestClientBuilder in project cxf by apache.
the class CxfTypeSafeClientBuilderTest method testConfigPriorityOverrides.
@Test
public void testConfigPriorityOverrides() throws Exception {
RestClientBuilder builder = RestClientBuilder.newBuilder();
builder.property("microprofile.rest.client.disable.default.mapper", true);
// annotation priority of 10
builder.register(HighPriorityClientReqFilter.class);
builder.register(LowPriorityClientReqFilter.class, 5);
// overriding priority to be 5 (preferred)
assertTrue(builder.getConfiguration().isRegistered(LowPriorityClientReqFilter.class));
MyClient c = builder.baseUrl(new URL("http://localhost/null")).build(MyClient.class);
Response r = c.get();
assertEquals("low", r.readEntity(String.class));
}
Aggregations