org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl Java Examples

The following examples show how to use org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl. 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: AbstractStoresTest.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * Configures and constructs a Resteasy client to use for calling the Alfresco Public ReST API in the dockerised deployment.
 *
 * @return the configured client
 */
protected static ResteasyClient setupResteasyClient()
{
    final SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new RestAPIBeanDeserializerModifier());

    final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
    final ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(Include.NON_EMPTY);
    mapper.registerModule(module);
    resteasyJacksonProvider.setMapper(mapper);

    final LocalResteasyProviderFactory resteasyProviderFactory = new LocalResteasyProviderFactory(new ResteasyProviderFactoryImpl());
    resteasyProviderFactory.register(resteasyJacksonProvider);
    // will cause a warning regarding Jackson provider which is already registered
    RegisterBuiltin.register(resteasyProviderFactory);
    resteasyProviderFactory.register(new MultiValuedParamConverterProvider());

    final ResteasyClient client = new ResteasyClientBuilderImpl().providerFactory(resteasyProviderFactory).build();
    return client;
}
 
Example #2
Source File: ZMSClientTimeoutTest.java    From athenz with Apache License 2.0 6 votes vote down vote up
@Test
public void testZMSClientReadTimeoutForRestEasyContainer() throws Exception {

    ZMSClientExt.setClientBuilder(new ResteasyClientBuilderImpl());
    server = new JettyServer(port);
    server.start();

    String baseUri = "http://localhost:" + port;
    ZMSClientExt zmsClient = new ZMSClientExt(baseUri);

    try {
        zmsClient.getDomain("test");
        fail("read timeout not set");
    } catch (ZMSClientException expected) {
        assertEquals(expected.code, ZMSClientException.BAD_REQUEST);
        assertEquals(
                expected.getMessage(),
                "ResourceException (400): RESTEASY004655: Unable to invoke request: java.net.SocketTimeoutException: Read timed out");
    }
    zmsClient.close();
    ZMSClientExt.setClientBuilder(null);
}
 
Example #3
Source File: ZTSClientTimeoutTest.java    From athenz with Apache License 2.0 6 votes vote down vote up
@Test
public void testZTSClientReadTimeoutForRestEasyContainer() throws Exception {

    ZTSClientMock.setClientBuilder(new ResteasyClientBuilderImpl());
    server = new JettyServer(port);
    server.start();

    String baseUri = "http://localhost:" + port;

    ZTSClientMock ztsClient = new ZTSClientMock(baseUri);

    try {
        ztsClient.getRoleAccess("testDomain", "testPrincipal");
        fail("read timeout not set");
    } catch (ZTSClientException expected) {
        assertEquals(expected.code, ZTSClientException.BAD_REQUEST);
        assertEquals(
                expected.getMessage(),
                "ResourceException (400): RESTEASY004655: Unable to invoke request: java.net.SocketTimeoutException: Read timed out");
    }
    ztsClient.close();
    ZTSClientMock.setClientBuilder(null);
}
 
Example #4
Source File: KeycloakAdminClientProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
ReflectiveClassBuildItem reflect() {
    return ReflectiveClassBuildItem.builder(ResteasyClientBuilderImpl.class, JacksonProvider.class, ProxyBuilderImpl.class,
            StringListMapDeserializer.class,
            StringOrArrayDeserializer.class,
            StringOrArraySerializer.class)
            .constructors(true)
            .methods(true)
            .build();
}
 
Example #5
Source File: ClientBuilderReplacement.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Substitute
public static ClientBuilder newBuilder() {
    ResteasyClientBuilder client = new ResteasyClientBuilderImpl();
    client.providerFactory(new LocalResteasyProviderFactory(RestClientRecorder.providerFactory));
    return client;
}