Class TestingFrameworkRequestHandler

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> desiredResponse  
      protected java.util.Map<java.lang.String,​java.lang.Object> requestExpectations  
      protected java.lang.Throwable thrown  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assertNothingThrown()
      After the handler returns the response, any exception or failed assertion will be in the member called "thrown".
      void handle​(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context)
      Checks the HTTP request against the requestExpectations that it was previously given.
      void setDesiredResponse​(java.util.Map<java.lang.String,​java.lang.Object> desiredResponse)
      Sets the desired response.
      void setRequestExpectations​(java.util.Map<java.lang.String,​java.lang.Object> requestExpectations)
      Sets the request expectations.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • thrown

        protected java.lang.Throwable thrown
      • requestExpectations

        protected java.util.Map<java.lang.String,​java.lang.Object> requestExpectations
      • desiredResponse

        protected java.util.Map<java.lang.String,​java.lang.Object> desiredResponse
    • Constructor Detail

      • TestingFrameworkRequestHandler

        public TestingFrameworkRequestHandler()
    • Method Detail

      • setRequestExpectations

        public void setRequestExpectations​(java.util.Map<java.lang.String,​java.lang.Object> requestExpectations)
                                    throws TestingFrameworkException
        Sets the request expectations.
        Parameters:
        requestExpectations - the expected values of the request.
        Throws:
        TestingFrameworkException
      • setDesiredResponse

        public void setDesiredResponse​(java.util.Map<java.lang.String,​java.lang.Object> desiredResponse)
                                throws TestingFrameworkException
        Sets the desired response. The handler will return a response that matches this.
        Parameters:
        desiredResponse - the desired response.
        Throws:
        TestingFrameworkException
      • assertNothingThrown

        public void assertNothingThrown()
                                 throws TestingFrameworkException
        After the handler returns the response, any exception or failed assertion will be in the member called "thrown". A testing framework can later call this method which will rethrow the exception that was thrown before.
        Throws:
        TestingFrameworkException
      • handle

        public void handle​(ClassicHttpRequest request,
                           ClassicHttpResponse response,
                           HttpContext context)
                    throws HttpException,
                           java.io.IOException

        Checks the HTTP request against the requestExpectations that it was previously given. If there is a mismatch, an exception will be saved in the "thrown" member.

        Also, a response will be returned that matches the desiredResponse.

        Specified by:
        handle in interface HttpRequestHandler
        Parameters:
        request - the HTTP request.
        response - the HTTP response.
        context - the HTTP execution context.
        Throws:
        HttpException - in case of HTTP protocol violation or a processing problem.
        java.io.IOException - in case of an I/O error.