use of org.apache.cxf.microprofile.client.mock.MyClient in project cxf by apache.
the class CxfTypeSafeClientBuilderTest method testCanInvokeDefaultInterfaceMethodsWithException.
@Test(expected = IOException.class)
public void testCanInvokeDefaultInterfaceMethodsWithException() throws Exception {
MyClient client = RestClientBuilder.newBuilder().register(InvokedMethodClientRequestFilter.class).baseUri(new URI("http://localhost:8080/neverUsed")).build(MyClient.class);
client.myDefaultMethod(true);
Assert.fail("Should have thrown IOException");
}
use of org.apache.cxf.microprofile.client.mock.MyClient in project cxf by apache.
the class CxfTypeSafeClientBuilderTest method testCanInvokeDefaultInterfaceMethods.
@Test
public void testCanInvokeDefaultInterfaceMethods() throws Exception {
MyClient client = RestClientBuilder.newBuilder().register(InvokedMethodClientRequestFilter.class).baseUri(new URI("http://localhost:8080/neverUsed")).build(MyClient.class);
assertEquals("defaultValue", client.myDefaultMethod(false));
}
use of org.apache.cxf.microprofile.client.mock.MyClient 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));
}
use of org.apache.cxf.microprofile.client.mock.MyClient 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)));
}
use of org.apache.cxf.microprofile.client.mock.MyClient 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)));
}
Aggregations