Interface LoopbackRestServer

All Superinterfaces:
org.refcodes.web.BaseLocatorAccessor, org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestServer>, org.refcodes.web.BaseLocatorAccessor.BaseLocatorMutator, org.refcodes.web.BaseLocatorAccessor.BaseLocatorProperty, HttpExceptionHandlerAccessor, HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<RestServer>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty, HttpExceptionHandlingAccessor, HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<RestServer>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty, org.refcodes.web.MediaTypeFactoryLookup, org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, org.refcodes.observer.Observable<RestEndpoint>, org.refcodes.observer.Observers<RestEndpoint,RestServer>, org.refcodes.web.RealmAccessor, org.refcodes.web.RealmAccessor.RealmBuilder<RestServer>, org.refcodes.web.RealmAccessor.RealmMutator, org.refcodes.web.RealmAccessor.RealmProperty, org.refcodes.runtime.RequestCorrelation<RestServer>, RestServer, org.refcodes.runtime.SessionCorrelation<RestServer>
All Known Implementing Classes:
LoopbackRestServerImpl, LoopbackRestServerSingleton

public interface LoopbackRestServer extends RestServer
Extends a RestServer to be used as loopback device e.g. for testing purposes such as testing your RestRequestConsumer implementations. Use the onHttpRequest(InetSocketAddress, InetSocketAddress, HttpMethod, Url, RequestHeaderFields, InputStream, HttpServerResponse) method to simulate REST requests on the LoopbackRestServer. An registered RestEndpoint instances being targeted at will be invoked accordingly.
  • Method Details

    • onHttpRequest

      void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aRequestHeaderFields, String aHttpBody, org.refcodes.web.HttpServerResponse aHttpServerResponse) throws org.refcodes.web.HttpStatusException
      Invoke this method to simulate a REST request to be handled by the according registered RestEndpoint instances:
      Parameters:
      aLocalAddress - the local address
      aClientAddress - the client address
      aHttpMethod - The method for the simulated REST request to be used
      aUrl - The query string part of the request.
      aRequestHeaderFields - The simulated REST request's Header-Fields to be used
      aHttpBody - The raw body for the simulated REST request to be used.
      aHttpServerResponse - The HttpServerResponse to be filled with the complete result of processing the request.
      Throws:
      org.refcodes.web.HttpStatusException - the http status exception
    • onHttpRequest

      void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, org.refcodes.web.HttpMethod aHttpMethod, org.refcodes.web.Url aUrl, org.refcodes.web.RequestHeaderFields aRequestHeaderFields, InputStream aHttpInputStream, org.refcodes.web.HttpServerResponse aHttpServerResponse) throws org.refcodes.web.HttpStatusException
      Invoke this method to simulate a REST request to be handled by the according registered RestEndpoint instances:.
      Parameters:
      aLocalAddress - the local address
      aClientAddress - the client address
      aHttpMethod - The method for the simulated REST request to be used
      aUrl - The query string part of the request.
      aRequestHeaderFields - The simulated REST request's Header-Fields to be used
      aHttpInputStream - The HTTP InputStream representing the body for the simulated REST request to be used.
      aHttpServerResponse - The HttpServerResponse to be filled with the complete result of processing the request.
      Throws:
      org.refcodes.web.HttpStatusException - the http status exception
    • withHttpExceptionHandler

      default LoopbackRestServer withHttpExceptionHandler(HttpExceptionHandler aHttpErrorHandler)
      Sets the HttpExceptionHandler for the HttpExceptionHandler property.
      Specified by:
      withHttpExceptionHandler in interface HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<RestServer>
      Parameters:
      aHttpErrorHandler - The HttpExceptionHandler to be stored by the HttpExceptionHandler property.
      Returns:
      The builder for applying multiple build operations.
    • withHttpExceptionHandling

      default LoopbackRestServer withHttpExceptionHandling(HttpExceptionHandling aHttpErrorHandling)
      Sets the HttpExceptionHandling for the HttpExceptionHandling property.
      Specified by:
      withHttpExceptionHandling in interface HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<RestServer>
      Parameters:
      aHttpErrorHandling - The HttpExceptionHandling to be stored by the HttpExceptionHandling property.
      Returns:
      The builder for applying multiple build operations.
    • withRealm

      default LoopbackRestServer withRealm(String aRealm)
      Specified by:
      withRealm in interface org.refcodes.web.RealmAccessor.RealmBuilder<RestServer>
      Specified by:
      withRealm in interface RestServer
    • withBaseLocator

      default LoopbackRestServer withBaseLocator(String aBaseLocator)
      Specified by:
      withBaseLocator in interface org.refcodes.web.BaseLocatorAccessor.BaseLocatorBuilder<RestServer>
      Specified by:
      withBaseLocator in interface RestServer