Class LocalConnector

All Implemented Interfaces:
Connector, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, Graceful, LifeCycle

public class LocalConnector extends AbstractConnector
A local connector, mostly for testing purposes.
  HttpTester.Request request = HttpTester.newRequest();
  request.setURI("/some/resource");
  HttpTester.Response response =
      HttpTester.parseResponse(HttpTester.from(localConnector.getResponse(request.generate())));
 
  • Constructor Details

  • Method Details

    • getTransport

      public Object getTransport()
      Returns:
      the underlying socket, channel, buffer etc. for the connector.
    • executeRequest

      public LocalConnector.LocalEndPoint executeRequest(String rawRequest)
      Execute a request and return the EndPoint through which multiple responses can be received or more input provided.
      Parameters:
      rawRequest - the request
      Returns:
      the local endpoint
    • connect

      public LocalConnector.LocalEndPoint connect()
    • accept

      protected void accept(int acceptorID) throws InterruptedException
      Specified by:
      accept in class AbstractConnector
      Throws:
      InterruptedException
    • getResponse

      public ByteBuffer getResponse(ByteBuffer requestsBuffer) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      requestsBuffer - The request to send
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem
    • getResponse

      public ByteBuffer getResponse(ByteBuffer requestBuffer, long time, TimeUnit unit) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      requestBuffer - The request to send
      time - The time to wait
      unit - The units of the wait
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem
    • getResponse

      public ByteBuffer getResponse(ByteBuffer requestBuffer, boolean head, long time, TimeUnit unit) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      requestBuffer - The request to send
      head - True if the response is for a head request
      time - The time to wait
      unit - The units of the wait
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem
    • getResponse

      public String getResponse(String rawRequest) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      rawRequest - The request to send
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem
    • getResponse

      public String getResponse(String rawRequest, long time, TimeUnit unit) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      rawRequest - The request to send
      time - The time to wait
      unit - The units of the wait
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem
    • getResponse

      public String getResponse(String rawRequest, boolean head, long time, TimeUnit unit) throws Exception
      Get a single response using a parser to search for the end of the message.
      Parameters:
      rawRequest - The request to send
      head - True if the response is for a head request
      time - The time to wait
      unit - The units of the wait
      Returns:
      ByteBuffer containing response or null.
      Throws:
      Exception - If there is a problem