Package org.jboss.resteasy.mock

Examples of org.jboss.resteasy.mock.MockHttpResponse


      Callable<MockHttpResponse> callable = new Callable<MockHttpResponse>()
      {

         public MockHttpResponse call() throws Exception
         {
            MockHttpResponse theResponse = new MockHttpResponse();

            try
            {
               invokeSuper(in, theResponse, invoker);
            }
View Full Code Here


      {

         public void run()
         {
            logger.debug("RUNNING JOB!!!!");
            MockHttpResponse theResponse = new MockHttpResponse();


            try
            {
               invokeSuper(in, theResponse, invoker);
View Full Code Here

   protected Response process(long wait, String jobId, boolean eatJob)
   {
      Future<MockHttpResponse> job = jobs.get(jobId);
      if (job == null) return Response.status(Response.Status.GONE).build();
      MockHttpResponse response = null;
      boolean nowait = false;
      // I don't want to wait forever!
      if (wait <= 0) nowait = true;

      if (nowait)
      {
         if (job.isDone())
         {
            try
            {
               response = job.get();
            }
            catch (Exception e)
            {
               return Response.serverError().build();
            }
         }
      }
      else
      {
         try
         {
            if (wait > maxWaitMilliSeconds) wait = maxWaitMilliSeconds;
            response = job.get(wait, TimeUnit.MILLISECONDS);
         }
         catch (Exception e)
         {
            return Response.serverError().build();
         }
      }
      if (response == null)
      {
         return Response.status(Response.Status.ACCEPTED).build();
      }
      Response.ResponseBuilder builder = Response.status(response.getStatus());
      builder.entity(response.getOutput());
      for (String name : response.getOutputHeaders().keySet())
      {
         List values = response.getOutputHeaders().get(name);
         for (Object value : values)
         {
            builder.header(name, value);
         }
      }
View Full Code Here

      Callable<MockHttpResponse> callable = new Callable<MockHttpResponse>()
      {

         public MockHttpResponse call() throws Exception
         {
            MockHttpResponse theResponse = new MockHttpResponse();

            try
            {
               invokeSuper(in, theResponse);
            }
View Full Code Here

      {

         public void run()
         {
            logger.debug("RUNNING JOB!!!!");
            MockHttpResponse theResponse = new MockHttpResponse();


            try
            {
               invokeSuper(in, theResponse);
View Full Code Here

         if (dispatcher == null)
         {
            return null;
         }
         enhanceRequest(request);
         return dispatcher.internalInvocation(request, new MockHttpResponse(), entity);
      }
      finally
      {
      }
View Full Code Here

    for (String characterSet : characterSets) {
      MockHttpRequest request = MockHttpRequest.get(path);
      request.accept("application/xml");
      request.header("Accept-Charset", characterSet);
   
      MockHttpResponse response = new MockHttpResponse();
      dispatcher.invoke(request, response);
      assertEquals("Status code.", 200, response.getStatus());

      String contentType = response.getOutputHeaders().getFirst("Content-Type").toString();
      String charsetPattern = "application/xml\\s*;\\s*charset\\s*=\\s*\"?" + characterSet + "\"?";
      String charsetErrorMessage = contentType + " does not match " + charsetPattern;
      assertTrue(charsetErrorMessage, contentType.matches(charsetPattern));

      String xml = response.getContentAsString();
      String encodingPattern = "<\\?xml[^>]*encoding\\s*=\\s*['\"]" + characterSet + "['\"].*";
      String encodingErrorMessage = xml + " does not match " + encodingPattern;
      assertTrue(encodingErrorMessage, xml.matches(encodingPattern));
    }
  }
View Full Code Here

   protected Response process(long wait, String jobId, boolean eatJob)
   {
      Future<MockHttpResponse> job = jobs.get(jobId);
      if (job == null) return Response.status(Response.Status.GONE).build();
      MockHttpResponse response = null;
      boolean nowait = false;
      // I don't want to wait forever!
      if (wait <= 0) nowait = true;

      if (nowait)
      {
         if (job.isDone())
         {
            try
            {
               response = job.get();
            }
            catch (Exception e)
            {
               return Response.serverError().build();
            }
         }
      }
      else
      {
         if (wait > maxWaitMilliSeconds) wait = maxWaitMilliSeconds;
         try
         {
            response = job.get(wait, TimeUnit.MILLISECONDS);
         }
         catch (InterruptedException e)
         {
            return Response.serverError().build();
         }
         catch (ExecutionException e)
         {
            return Response.serverError().build();
         }
         catch (TimeoutException e)
         {
            return Response.status(Response.Status.SERVICE_UNAVAILABLE).build();
         }
      }
      if (response == null)
      {
         return Response.status(Response.Status.ACCEPTED).build();
      }
      Response.ResponseBuilder builder = Response.status(response.getStatus());
      builder.entity(response.getOutput());
      for (String name : response.getOutputHeaders().keySet())
      {
         List values = response.getOutputHeaders().get(name);
         for (Object value : values)
         {
            builder.header(name, value);
         }
      }
View Full Code Here

      Callable<MockHttpResponse> callable = new Callable<MockHttpResponse>()
      {

         public MockHttpResponse call() throws Exception
         {
            MockHttpResponse theResponse = new MockHttpResponse();

            try
            {
               pushContextObjects(in, theResponse);
               invokeSuper(in, theResponse, invoker);
View Full Code Here

      {

         public void run()
         {
            logger.debug("RUNNING JOB!!!!");
            MockHttpResponse theResponse = new MockHttpResponse();


            try
            {
               pushContextObjects(in, theResponse);
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.mock.MockHttpResponse

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.