public Invocation.Builder getServiceInstanceDetails() { Client client = JerseyClientBuilder.newClient(); WebTarget target= client.target(marathonClientConfiguration.getMarathonApiUrl() + "/v2/apps"+ marathonClientConfiguration.getMarathonAppNameSpace()); return target.request(); }
@Override protected Object enrichByType(Class<?> clazz, Method method, ArquillianResteasyResource annotation, Consumes consumes, Produces produces) { Object value; Client client = JerseyClientBuilder.newClient(); WebTarget webTarget = client.target(getBaseURL() + annotation.value()); final Map<String, String> headers = getHeaders(clazz, method); if (!headers.isEmpty()) { webTarget.register(new HeaderFilter(headers)); } JerseyWebTarget jerseyWebTarget = (JerseyWebTarget) webTarget; if (WebTarget.class.isAssignableFrom(clazz)) { value = jerseyWebTarget; } else { final Class<?> parameterType; try { final Annotation[] methodDeclaredAnnotations = method.getDeclaredAnnotations(); // This is test method so if it only contains @Test annotation then we don't need to hassel with substitutions parameterType = methodDeclaredAnnotations.length <= 1 ? clazz : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations); } catch (Exception e) { throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e); } value = WebResourceFactory.newResource(parameterType, jerseyWebTarget); } return value; }
@Override protected Object enrichByType(Class<?> clazz, Method method, ArquillianResteasyResource annotation, Consumes consumes, Produces produces) { Object value; Client client = JerseyClientBuilder.newClient(); WebTarget webTarget = client.target(getBaseURL() + annotation.value()); final Map<String, String> headers = getHeaders(clazz, method); if (!headers.isEmpty()) { webTarget.register(new HeaderFilter(headers)); } JerseyWebTarget jerseyWebTarget = (JerseyWebTarget) webTarget; if (WebTarget.class.isAssignableFrom(clazz)) { value = jerseyWebTarget; } else { final Class<?> parameterType; try { final Annotation[] methodDeclaredAnnotations = method.getDeclaredAnnotations(); // This is test method so if it only contains @Test annotation then we don't need to hassel with substitutions parameterType = methodDeclaredAnnotations.length <= 1 ? clazz : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations); } catch (Exception e) { throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e); } value = WebResourceFactory.newResource(parameterType, jerseyWebTarget); } return value; }
private Invocation.Builder request() { Client client = JerseyClientBuilder.newClient(); if (configuration.connectTimeout() != 0) client.property(CONNECT_TIMEOUT, configuration.connectTimeout()); if (configuration.readTimeout() != 0) client.property(READ_TIMEOUT, configuration.readTimeout()); configureClient(client); return client .register(configuration.httpAuthenticationFeature()) .target(configuration.apiUrl()) .path(configuration.domain()) .path("messages") .request(); } }
public ClientWrapper(final Map<String, String> headers, String userName, String password) { realClient = JerseyClientBuilder.newClient(); realClient.register(new MultiPartFeature()); realClient.register(new JettisonFeature()); realClient.register(new CsrfProtectionFilter()); if ((userName != null) && (password != null)) { realClient.register(HttpAuthenticationFeature.basic(userName, password)); } realClient.register(new ClientRequestFilter() { @Override public void filter(ClientRequestContext rc) throws IOException { for (Map.Entry<String, String> entry : headers.entrySet()) { rc.getHeaders().add(entry.getKey(), entry.getValue()); } } }); }