Package org.jboss.resteasy.client

Examples of org.jboss.resteasy.client.ClientRequest


      try
      {
         if (uri == null) throw new RuntimeException("You have not set a base URI for the client proxy");

         ClientRequest request = createRequest(args);

         BaseClientResponse clientResponse = null;
         try
         {
            clientResponse = (BaseClientResponse) request.httpMethod(httpMethod);
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
View Full Code Here


      }
   }

   protected ClientRequest createRequest(Object[] args)
   {
      ClientRequest request = new ClientRequest(uri, executor, providerFactory);
      request.getAttributes().putAll(attributes);
      if (accepts != null) request.header(HttpHeaders.ACCEPT, accepts.toString());
      this.copyClientInterceptorsTo(request);

      boolean isClientResponseResult = ClientResponse.class.isAssignableFrom(method.getReturnType());
      request.followRedirects(!isClientResponseResult || this.followRedirects);

      for (int i = 0; i < marshallers.length; i++)
      {
         marshallers[i].build(request, args[i]);
      }
View Full Code Here

      return method.isAnnotationPresent(GET.class);
   }

   public ClientResponse execute(ClientExecutionContext ctx) throws Exception
   {
      ClientRequest request = ctx.getRequest();
      if (!request.getHttpMethod().equals("GET"))
      {
         return ctx.proceed();
      }

      BrowserCache.Entry entry = getEntry(request);
      if (entry == null)
      {
         return cache(request, ctx.proceed());
      }

      if (entry.expired())
      {
         cache.remove(request.getUri(), entry.getMediaType());
         BrowserCache.Header[] headers = entry.getValidationHeaders();
         for (BrowserCache.Header header : headers)
         {
            request.header(header.getName(), header.getValue());
         }
         return handleExpired(ctx, request, entry);
      }

      return createClientResponse(request, entry);
View Full Code Here

   }

   @Test
   public void testIt() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/sayhello/widget/08%2F26%2F2009");
      ClientResponse<String> response = request.get(String.class);
      Assert.assertEquals(200, response.getStatus());

   }
View Full Code Here

            resp.getWriter().write("world");
         }
      });
      server.start();

      ClientRequest request = TestPortProvider.createClientRequest("/hello");
      Assert.assertEquals("world", request.get(String.class).getEntity());
   }
View Full Code Here

      checkText("/test.html", "<html><body>Hello, World!</body></html>");
   }

   private void checkText(String uri, final String text) throws Exception
   {
      ClientRequest request = TestPortProvider.createClientRequest(uri);
      Assert.assertEquals(text, request.get(String.class).getEntity());
   }
View Full Code Here

public class ApplicationTest
{
   @Test
   public void testCount() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/my/application/count");
      String count = request.getTarget(String.class);
      Assert.assertEquals("1", count);
   }
View Full Code Here

    * @throws Exception
    */
   @Test
   public void testNullJaxb() throws Exception
   {
      ClientRequest request = new ClientRequest("http://localhost:9095/my/null");
      request.header("Content-Length", "0");
      request.header("Content-Type", "application/xml");
      ClientResponse res = request.post();
      Assert.assertEquals(204, res.getStatus());
   }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   private void doTest(String path, int expectedStatus, boolean get) throws Exception
   {
      ClientRequest request = new ClientRequest(generateURL(path));
      ClientResponse response = get ? request.get() : request.delete();
      Assert.assertEquals(expectedStatus, response.getStatus());
      Assert.assertNotNull(response.getHeaders().getFirst("custom-header"));

   }
View Full Code Here

   public void testCustomInjectorFactory() throws Exception
   {
      InMemoryClientExecutor executor = new InMemoryClientExecutor(initializeDispatcher());
      executor.getRegistry().addPerRequestResource(HelloResource.class);

      Object result = new ClientRequest("/", executor).get().getEntity(String.class);
      Assert.assertEquals("world", result);
   }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.client.ClientRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.