Search in sources :

Example 6 with RestClientBuilder

use of org.eclipse.microprofile.rest.client.RestClientBuilder in project cxf by apache.

the class MicroProfileClientFactoryBeanTest method testCreateClientEnabledFeature.

@Test
@SuppressWarnings("unchecked")
public void testCreateClientEnabledFeature() throws Exception {
    final MicroProfileClientConfigurableImpl<RestClientBuilder> configurable = new MicroProfileClientConfigurableImpl<>(RestClientBuilder.newBuilder());
    final MicroProfileClientFactoryBean bean = new MicroProfileClientFactoryBean(configurable, "http://bar", MyClient.class, null, new TLSConfiguration());
    final SomeFeature feature = new SomeFeature(true);
    bean.setProvider(feature);
    assertTrue(bean.create() instanceof MyClient);
    assertTrue(configurable.getConfiguration().isRegistered(SomeFeature.class));
    assertTrue(configurable.getConfiguration().isRegistered(TestClientRequestFilter.class));
    assertTrue(configurable.getConfiguration().isEnabled(SomeFeature.class));
    assertThat((List<Object>) bean.getProviders(), hasItem(instanceOf(TestClientRequestFilter.class)));
}
Also used : TLSConfiguration(org.apache.cxf.jaxrs.client.spec.TLSConfiguration) MyClient(org.apache.cxf.microprofile.client.mock.MyClient) RestClientBuilder(org.eclipse.microprofile.rest.client.RestClientBuilder) TestClientRequestFilter(org.eclipse.microprofile.rest.client.tck.providers.TestClientRequestFilter) Test(org.junit.Test)

Example 7 with RestClientBuilder

use of org.eclipse.microprofile.rest.client.RestClientBuilder in project cxf by apache.

the class MicroProfileClientFactoryBeanTest method testCreateClientDisabledFeature.

@Test
@SuppressWarnings("unchecked")
public void testCreateClientDisabledFeature() throws Exception {
    final MicroProfileClientConfigurableImpl<RestClientBuilder> configurable = new MicroProfileClientConfigurableImpl<>(RestClientBuilder.newBuilder());
    final MicroProfileClientFactoryBean bean = new MicroProfileClientFactoryBean(configurable, "http://bar", MyClient.class, null, new TLSConfiguration());
    final SomeFeature feature = new SomeFeature(false);
    bean.setProvider(feature);
    assertTrue(bean.create() instanceof MyClient);
    assertTrue(configurable.getConfiguration().isRegistered(SomeFeature.class));
    assertTrue(configurable.getConfiguration().isRegistered(TestClientRequestFilter.class));
    assertFalse(configurable.getConfiguration().isEnabled(SomeFeature.class));
    assertThat((List<Object>) bean.getProviders(), hasItem(instanceOf(TestClientRequestFilter.class)));
}
Also used : TLSConfiguration(org.apache.cxf.jaxrs.client.spec.TLSConfiguration) MyClient(org.apache.cxf.microprofile.client.mock.MyClient) RestClientBuilder(org.eclipse.microprofile.rest.client.RestClientBuilder) TestClientRequestFilter(org.eclipse.microprofile.rest.client.tck.providers.TestClientRequestFilter) Test(org.junit.Test)

Aggregations

RestClientBuilder (org.eclipse.microprofile.rest.client.RestClientBuilder)7 URL (java.net.URL)4 Test (org.junit.Test)4 MalformedURLException (java.net.MalformedURLException)3 MyClient (org.apache.cxf.microprofile.client.mock.MyClient)3 URISyntaxException (java.net.URISyntaxException)2 TLSConfiguration (org.apache.cxf.jaxrs.client.spec.TLSConfiguration)2 TestClientRequestFilter (org.eclipse.microprofile.rest.client.tck.providers.TestClientRequestFilter)2 DEFAULT_PASSWORD (fish.payara.samples.dynamic.roles.common.AuthoritiesConstants.DEFAULT_PASSWORD)1 DEFAULT_USER (fish.payara.samples.dynamic.roles.common.AuthoritiesConstants.DEFAULT_USER)1 ClientRequestFilter (javax.ws.rs.client.ClientRequestFilter)1 Response (javax.ws.rs.core.Response)1 HighPriorityMBW (org.apache.cxf.microprofile.client.mock.HighPriorityMBW)1 LowPriorityClientReqFilter (org.apache.cxf.microprofile.client.mock.LowPriorityClientReqFilter)1