congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.jboss.arquillian.extension.rest.client
Code IndexAdd Tabnine to your IDE (free)

How to use org.jboss.arquillian.extension.rest.client

Best Java code snippets using org.jboss.arquillian.extension.rest.client (Showing top 18 results out of 315)

origin: arquillian/arquillian-extension-rest

private static MemberValue[] toMemberValue(Object[] value, Class<?> valueType, ConstPool constpool,
  ClassPool classPool) throws NotFoundException {
  final MemberValue[] memberValues = new MemberValue[value.length];
  for (int i = 0; i < value.length; i++) {
    memberValues[i] = toMemberValue(value[i], valueType, constpool, classPool);
  }
  return memberValues;
}
origin: arquillian/arquillian-extension-rest

private void addHeaders(Map<String, String> headersMap, Header annotation) {
  if (null != annotation) {
    headersMap.put(annotation.name(), annotation.value());
  }
}
origin: arquillian/arquillian-extension-rest

protected Map<String, String> getHeaders(Class<?> clazz, Method method) {
  final Map<String, String> headers = getHeaders(clazz);
  headers.putAll(getHeaders(method));
  return headers;
}
origin: arquillian/arquillian-extension-rest

  @Override
  protected Object enrichByType(Class<?> clazz, Method method, ArquillianResteasyResource annotation, Consumes consumes,
    Produces produces) {
    Object result = null;
    if (ClientBuilder.class.isAssignableFrom(clazz)) {
      result = ClientBuilder.newBuilder();
    } else if (Client.class.isAssignableFrom(clazz)) {
      result = ClientBuilder.newClient();
    } else if (WebTarget.class.isAssignableFrom(clazz)) {
      WebTarget webTarget = ClientBuilder.newClient().target(getBaseURL() + annotation.value());
      final Map<String, String> headers = getHeaders(clazz, method);
      if (!headers.isEmpty()) {
        webTarget.register(new HeaderFilter(headers));
      }
      result = webTarget;
    }
    return result;
  }
}
origin: arquillian/arquillian-extension-rest

protected Map<String, String> getHeaders(AnnotatedElement annotatedElement) {
  final Map<String, String> headersMap = new HashMap<String, String>();
  final Headers headersAnnotation = annotatedElement.getAnnotation(Headers.class);
  if (null != headersAnnotation && null != headersAnnotation.value()) {
    for (Header header : headersAnnotation.value()) {
      addHeaders(headersMap, header);
    }
  }
  addHeaders(headersMap, annotatedElement.getAnnotation(Header.class));
  return headersMap;
}
origin: arquillian/arquillian-extension-rest

@Override
public Object[] resolve(Method method) {
  Object[] values = new Object[method.getParameterTypes().length];
  Class<?>[] parameterTypes = method.getParameterTypes();
  final Consumes consumes = method.getDeclaringClass().getAnnotation(Consumes.class);
  final Produces produces = method.getDeclaringClass().getAnnotation(Produces.class);
  if (responseInst.get() != null) {
    for (int i = 0; i < parameterTypes.length; i++) {
      if (Response.class.isAssignableFrom(parameterTypes[i])) {
        values[i] = responseInst.get();
      }
    }
  } else {
    for (int i = 0; i < parameterTypes.length; i++) {
      final Annotation[] parameterAnnotations = method.getParameterAnnotations()[i];
      for (Annotation annotation : parameterAnnotations) {
        if (annotation instanceof ArquillianResteasyResource) {
          ArquillianResteasyResource arr = (ArquillianResteasyResource) annotation;
          Class<?> clazz = parameterTypes[i];
          if (isSupportedParameter(clazz)) {
            values[i] = enrichByType(clazz, method, arr, consumes, produces);
          } else {
            throw new RuntimeException("Not able to provide a client injection for type " + clazz);
          }
        }
      }
    }
  }
  return values;
}
origin: arquillian/arquillian-extension-rest

@SuppressWarnings("unchecked")
public static <T> Class<T> getModifiedClass(Class<T> clazz, Annotation[] add)
  throws javassist.NotFoundException, CannotCompileException, InvocationTargetException, IllegalAccessException {
  ClassPool pool = ClassPool.getDefault();
  CtClass cc = pool.get(clazz.getCanonicalName());
  for (CtMethod method : cc.getDeclaredMethods()) {
    ClassFile ccFile = cc.getClassFile();
    ConstPool constpool = ccFile.getConstPool();
    AnnotationsAttribute attr;
    attr = filterExistingAnnotations(add, method);
    addNewAnnotations(add, method, constpool, pool, attr);
  }
  cc.setName(cc.getName() + "$ClassModifier$" + COUNTER.increment());
  cc.setSuperclass(pool.get(clazz.getCanonicalName()));
  return cc.toClass();
}
origin: arquillian/arquillian-extension-rest

private static MemberValue toMemberValue(Object value, Class<?> componentType, ConstPool constpool,
  ClassPool classPool) throws NotFoundException {
  final CtClass type = getType(value, componentType, classPool);
  final MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(constpool, type);
  if (memberValue instanceof BooleanMemberValue) {
  } else if (type.isArray()) {
    ((ArrayMemberValue) memberValue).setValue(
      toMemberValue((Object[]) value, componentType, constpool, classPool));
  } else if (type.isInterface()) {
    final javassist.bytecode.annotation.Annotation annotation =
      try {
        annotation.addMemberValue(method.getName(),
          toMemberValue(method.invoke(value), null, constpool, classPool));
      } catch (Exception e) {
        throw new RuntimeException(e);
origin: arquillian/arquillian-extension-rest

private static void addNewAnnotations(Annotation[] add, CtMethod method, ConstPool constpool, ClassPool classPool,
  AnnotationsAttribute attr)
  throws IllegalAccessException, NotFoundException, InvocationTargetException {
  if (null == attr) {
    attr = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
    method.getMethodInfo().addAttribute(attr);
  }
  for (Annotation toAdd : add) {
    attr.addAnnotation(toJavassist(toAdd, constpool, classPool));
  }
}
origin: arquillian/arquillian-extension-rest

protected URI getBaseURL() {
  HTTPContext context = metaDataInst.get().getContext(HTTPContext.class);
  if (allInSameContext(context.getServlets())) {
    return context.getServlets().get(0).getBaseURI();
  }
  throw new IllegalStateException("No baseURL found in HTTPContext");
}
origin: GluuFederation/oxAuth

  @RunAsClient
  @Parameters({ "gluuConfigurationPath", "webTarget" })
  @Consumes(MediaType.APPLICATION_JSON)
  @Test
  public void getConfigurationTest(String gluuConfigurationPath,
      @Optional @ArquillianResteasyResource("") final WebTarget webTarget) throws Exception {
    Response response = webTarget.path(gluuConfigurationPath).request().get();
    String entity = response.readEntity(String.class);
    BaseTest.showResponse("UMA : TConfiguration.configuration", response, entity);

    assertEquals(response.getStatus(), 200, "Unexpected response code.");
    try {
      GluuConfiguration appConfiguration = ServerUtil.createJsonMapper().readValue(entity,
          GluuConfiguration.class);
      System.err.println(appConfiguration.getIdGenerationEndpoint());
      assertNotNull(appConfiguration, "Meta data configuration is null");
      assertNotNull(appConfiguration.getIdGenerationEndpoint());
      assertNotNull(appConfiguration.getIntrospectionEndpoint());
      assertNotNull(appConfiguration.getAuthLevelMapping());
      assertNotNull(appConfiguration.getScopeToClaimsMapping());
    } catch (IOException e) {
      e.printStackTrace();
      fail();
    }
  }
}
origin: org.jboss.arquillian.extension/arquillian-rest-client-impl-jersey

  @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;
  }

origin: arquillian/arquillian-extension-rest

private static javassist.bytecode.annotation.Annotation toJavassist(Annotation annotation, ConstPool constpool,
  ClassPool classPool)
  throws NotFoundException, InvocationTargetException, IllegalAccessException {
  final javassist.bytecode.annotation.Annotation newAnnotation = new javassist.bytecode.annotation.Annotation(
    annotation.annotationType().getCanonicalName(), constpool);
  for (Method method : annotation.annotationType().getDeclaredMethods()) {
    final Object value = method.invoke(annotation);
    Class<?> componentType = null;
    if (method.getReturnType().isArray()) {
      componentType = method.getReturnType().getComponentType();
    }
    newAnnotation.addMemberValue(method.getName(), toMemberValue(value, componentType, constpool, classPool));
  }
  return newAnnotation;
}
origin: arquillian/arquillian-extension-rest

@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;
}
origin: org.jboss.arquillian.extension/arquillian-rest-client-impl-3x

WebTarget webTarget = client.target(getBaseURL() + annotation.value());
final Map<String, String> headers = getHeaders(clazz, method);
if (!headers.isEmpty()) {
  webTarget.register(new HeaderFilter(headers));
    final Annotation[] methodDeclaredAnnotations = method.getDeclaredAnnotations();
    parameterType = methodDeclaredAnnotations.length <= 1 ? clazz : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations);
  } catch (Exception e) {
    throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e);
origin: arquillian/arquillian-extension-rest

Object value;
Client client = ResteasyClientBuilder.newClient();
WebTarget webTarget = client.target(getBaseURL() + annotation.value());
final Map<String, String> headers = getHeaders(clazz, method);
if (!headers.isEmpty()) {
  webTarget.register(new HeaderFilter(headers));
      : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations);
  } catch (Exception e) {
    throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e);
origin: arquillian/arquillian-extension-rest

Produces produces) {
Object value;
final String resourcePath = annotation.value();
if (ClientRequest.class.isAssignableFrom(clazz)) {
  final ClientRequest clientRequest =
    new ClientRequestFactory(getBaseURL()).createRelativeRequest(resourcePath);
  final Map<String, String> headers = getHeaders(clazz, method);
  if (!headers.isEmpty()) {
    clientRequest.registerInterceptor(new HeaderFilter(headers));
      : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations);
  } catch (Exception e) {
    throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e);
  final ProxyBuilder<?> proxyBuilder = ProxyBuilder.build(parameterType, getBaseURL() + resourcePath);
  final Map<String, String> headers = getHeaders(clazz, method);
  if (!headers.isEmpty()) {
    proxyBuilder.executor(new ApacheHttpClient4Executor() {
origin: org.jboss.arquillian.extension/arquillian-rest-client-impl-2x

final String resourcePath = annotation.value();
if (ClientRequest.class.isAssignableFrom(clazz)) {
  final ClientRequest clientRequest = new ClientRequestFactory(getBaseURL()).createRelativeRequest(resourcePath);
  final Map<String, String> headers = getHeaders(clazz, method);
  if (!headers.isEmpty()) {
    clientRequest.registerInterceptor(new HeaderFilter(headers));
    final Annotation[] methodDeclaredAnnotations = method.getDeclaredAnnotations();
    parameterType = methodDeclaredAnnotations.length <= 1 ? clazz : ClassModifier.getModifiedClass(clazz, methodDeclaredAnnotations);
  } catch (Exception e) {
    throw new RuntimeException("Cannot substitute annotations for method " + method.getName(), e);
  final ProxyBuilder<?> proxyBuilder = ProxyBuilder.build(parameterType, getBaseURL() + resourcePath);
  final Map<String, String> headers = getHeaders(clazz, method);
  if (!headers.isEmpty()) {
    proxyBuilder.executor(new ApacheHttpClient4Executor() {
org.jboss.arquillian.extension.rest.client

Most used classes

  • ArquillianResteasyResource
  • ClassModifier
  • HeaderFilter
  • RestEnricher
    RestEnricher
  • BaseRestEnricher
  • Headers
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now