Class LoopbackRestServer
java.lang.Object
org.refcodes.observer.AbstractObservable<RestEndpoint, HttpRequest>
org.refcodes.rest.AbstractRestServer
org.refcodes.rest.LoopbackRestServer
- All Implemented Interfaces:
Disposable, Observable<RestEndpoint>, Observers<RestEndpoint, RestServer>, RestServer, BaseLocatorAccessor, BaseLocatorAccessor.BaseLocatorBuilder<RestServer>, BaseLocatorAccessor.BaseLocatorMutator, BaseLocatorAccessor.BaseLocatorProperty, MediaTypeFactoryLookup, MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, RealmAccessor, RealmAccessor.RealmBuilder<RestServer>, RealmAccessor.RealmMutator, RealmAccessor.RealmProperty
- Direct Known Subclasses:
LoopbackRestServerSingleton
Implements 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.-
Nested Class Summary
Nested classes/interfaces inherited from interface BaseLocatorAccessor
BaseLocatorAccessor.BaseLocatorBuilder<B>, BaseLocatorAccessor.BaseLocatorMutator, BaseLocatorAccessor.BaseLocatorPropertyNested classes/interfaces inherited from interface MediaTypeFactoryLookup
MediaTypeFactoryLookup.MutableMediaTypeFactoryLookupNested classes/interfaces inherited from interface RealmAccessor
RealmAccessor.RealmBuilder<B>, RealmAccessor.RealmMutator, RealmAccessor.RealmProperty -
Field Summary
Fields inherited from class AbstractRestServer
_isVerbose -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aRequestHeaderFields, InputStream aHttpInputStream, HttpServerResponse aHttpServerResponse) Invoke this method to simulate a REST request to be handled by the according registeredRestEndpointinstances:.voidonHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aRequestHeaderFields, String aHttpBody, HttpServerResponse aHttpServerResponse) Invoke this method to simulate a REST request to be handled by the according registeredRestEndpointinstances:.withBaseLocator(String aBaseLocator) withObserversActive(boolean isActive) Methods inherited from class AbstractRestServer
addMediaTypeFactory, dispose, fireEvent, getBaseLocator, getFactoryMediaTypes, getRealm, initMedaTypeFactories, isObserversActive, observers, postIntercept, preIntercept, setBaseLocator, setObserversActive, setRealm, subscribeObserver, toMediaTypeFactory, toNegotiatedContenType, toResponseBody, unsubscribeObserverMethods inherited from class AbstractObservable
clear, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserver, isEmpty, setThreadPriority, sizeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseLocatorAccessor.BaseLocatorProperty
letBaseLocatorMethods inherited from interface MediaTypeFactoryLookup
hasMediaTypeFactoryMethods inherited from interface Observable
hasObserverMethods inherited from interface Observers
disableObservers, enableObserversMethods inherited from interface RealmAccessor.RealmProperty
letRealm
-
Constructor Details
-
LoopbackRestServer
public LoopbackRestServer()
-
-
Method Details
-
onHttpRequest
public void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aRequestHeaderFields, String aHttpBody, HttpServerResponse aHttpServerResponse) throws HttpStatusException Invoke this method to simulate a REST request to be handled by the according registeredRestEndpointinstances:.- Parameters:
aLocalAddress- the local addressaClientAddress- the client addressaHttpMethod- The method for the simulated REST request to be usedaUrl- The query string part of the request.aRequestHeaderFields- The simulated REST request's Header-Fields to be usedaHttpBody- The raw body for the simulated REST request to be used.aHttpServerResponse- TheHttpServerResponseto be filled with the complete result of processing the request.- Throws:
HttpStatusException- thrown in case of HTTP status code related exceptions (e.g. as of a HTTP response was of an erroneous status).
-
onHttpRequest
public void onHttpRequest(InetSocketAddress aLocalAddress, InetSocketAddress aClientAddress, HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aRequestHeaderFields, InputStream aHttpInputStream, HttpServerResponse aHttpServerResponse) throws HttpStatusException Invoke this method to simulate a REST request to be handled by the according registeredRestEndpointinstances:.- Overrides:
onHttpRequestin classAbstractRestServer- Parameters:
aLocalAddress- the local addressaClientAddress- the client addressaHttpMethod- The method for the simulated REST request to be usedaUrl- The query string part of the request.aRequestHeaderFields- The simulated REST request's Header-Fields to be usedaHttpInputStream- The HTTPInputStreamrepresenting the body for the simulated REST request to be used.aHttpServerResponse- TheHttpServerResponseto be filled with the complete result of processing the request.- Throws:
HttpStatusException- thrown in case of HTTP status code related exceptions (e.g. as of a HTTP response was of an erroneous status).
-
withBaseLocator
-
withRealm
-
withObserversActive
-
withEnableObservers
-
withDisableObservers
-