Package net.officefloor.woof.mock
Class MockWoofServer
java.lang.Object
net.officefloor.server.http.mock.MockHttpServer
net.officefloor.woof.mock.MockWoofServer
- All Implemented Interfaces:
AutoCloseable,HttpServerImplementation,HttpServerLocation
- Direct Known Subclasses:
MockWoofServerExtension,MockWoofServerRule
MockHttpServer loading the WoOF application.
This provides convenient means to test WoOF applications.
- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceAnnotates service methods for theClassSectionSource.protected classMockWoofResponseimplementation.static interfaceEnables configuring theMockWoofServer.static interfaceEnables wrapping the compile and open.static interfaceContext forMockWoofServer.WrapCompileAndOpen.Nested classes/interfaces inherited from class net.officefloor.server.http.mock.MockHttpServer
MockHttpServer.MockHttpRequest, MockHttpServer.MockHttpResponseImpl, MockHttpServer.MockServerHttpConnectionImpl -
Field Summary
Fields inherited from interface net.officefloor.server.http.HttpServerLocation
PROPERTY_CLUSTER_HOST_NAME, PROPERTY_CLUSTER_HTTP_PORT, PROPERTY_CLUSTER_HTTPS_PORT, PROPERTY_DOMAIN, PROPERTY_HTTP_PORT, PROPERTY_HTTPS_PORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected MockHttpResponsecreateMockHttpResponse(MockHttpServer.MockHttpRequest request, Throwable failure) Creates theMockHttpResponse.protected MockHttpResponsecreateMockHttpResponse(MockHttpServer.MockHttpRequest request, HttpVersion version, HttpStatus status, List<WritableHttpHeader> headers, List<WritableHttpCookie> cookies, InputStream entityInputStream) Creates theMockHttpResponse.createSectionServicer(Class<?> sectionClass) Obtains theOfficeFloor.static OfficeFloorstatic OfficeFlooropen(int httpPort, int httpsPort, MockWoofServer.MockWoofServerConfigurer... configurers) Opens theWoOFon particular ports.static OfficeFloorstatic MockWoofServeropen(MockWoofServer.MockWoofServerConfigurer... configurers) Opens theMockWoofServer.protected static MockWoofServeropen(MockWoofServer server, MockWoofServer.MockWoofServerConfigurer... configurers) Opens theMockWoofServer.send(MockHttpRequestBuilder request) Sends theMockHttpRequestBuilderand blocks waiting for theMockHttpResponse.sendFollowRedirect(MockHttpRequestBuilder request) Sends theMockHttpRequestBuilderand blocks following the redirect.Wraps the compile and open.Methods inherited from class net.officefloor.server.http.mock.MockHttpServer
configureHttpServer, configureMockHttpServer, configureMockHttpServer, configureMockHttpServer, createClientUrl, direct, direct, getClusterHostName, getClusterHttpPort, getClusterHttpsPort, getDomain, getExternalServiceInput, getExternalServiceInput, getHttpPort, getHttpsPort, mockConnection, mockConnection, mockJsonRequest, mockJsonRequest, mockRequest, mockRequest, mockResponse, mockResponseCookie, send, timeout
-
Constructor Details
-
MockWoofServer
public MockWoofServer()
-
-
Method Details
-
open
public static MockWoofServer open(MockWoofServer.MockWoofServerConfigurer... configurers) throws Exception Opens theMockWoofServer.- Parameters:
configurers-MockWoofServer.MockWoofServerConfigurerinstances.- Returns:
MockWoofServer.- Throws:
Exception- If fails to start theMockWoofServer.
-
open
Opens the
WoOFon a particular port with theClassSectionSourceto serviceServerHttpConnection.This is a convenience method to typically setup a mock server to respond to application requests.
- Parameters:
httpPort- HTTP port.sectionClass-ClassforClassSectionSource.- Returns:
MockWoofServer.- Throws:
Exception- If fails to start theMockWoofServer.
-
open
Opens the
WoOFon a particular port with theClassSectionSourceto serviceServerHttpConnection.This is a convenience method to typically setup a mock server to respond to application requests.
- Parameters:
httpPort- HTTP port.httpsPort- HTTPS port.sectionClass-ClassforClassSectionSource.- Returns:
MockWoofServer.- Throws:
Exception- If fails to start theMockWoofServer.
-
createSectionServicer
- Parameters:
sectionClass-ClassSectionSourceClass.- Returns:
MockWoofServer.MockWoofServerConfigurer.
-
open
public static OfficeFloor open(int httpPort, int httpsPort, MockWoofServer.MockWoofServerConfigurer... configurers) throws Exception Opens theWoOFon particular ports.- Parameters:
httpPort- HTTP port.httpsPort- HTTPS port.configurers-MockWoofServer.MockWoofServerConfigurerinstances.- Returns:
MockWoofServer.- Throws:
Exception- If fails to start theMockWoofServer.
-
open
protected static MockWoofServer open(MockWoofServer server, MockWoofServer.MockWoofServerConfigurer... configurers) throws Exception Opens theMockWoofServer.- Parameters:
server-MockWoofServer.configurers-MockWoofServer.MockWoofServerConfigurerinstances.- Returns:
- Input
MockWoofServer. - Throws:
Exception- If fails to open theMockWoofServer.
-
getOfficeFloor
Obtains theOfficeFloor.- Returns:
OfficeFloor.
-
wrap
Wraps the compile and open.- Parameters:
wrap-MockWoofServer.WrapCompileAndOpen.- Returns:
this.
-
createMockHttpResponse
protected MockHttpResponse createMockHttpResponse(MockHttpServer.MockHttpRequest request, HttpVersion version, HttpStatus status, List<WritableHttpHeader> headers, List<WritableHttpCookie> cookies, InputStream entityInputStream) Description copied from class:MockHttpServerCreates theMockHttpResponse.- Overrides:
createMockHttpResponsein classMockHttpServer- Parameters:
request-MockHttpServer.MockHttpRequest.version-HttpVersion.status-HttpStatus.headers-WritableHttpHeaderinstances.cookies-WritableHttpCookieinstances.entityInputStream- Entity.- Returns:
MockHttpResponse.
-
createMockHttpResponse
protected MockHttpResponse createMockHttpResponse(MockHttpServer.MockHttpRequest request, Throwable failure) Description copied from class:MockHttpServerCreates theMockHttpResponse.- Overrides:
createMockHttpResponsein classMockHttpServer- Parameters:
request-MockHttpServer.MockHttpRequest.failure- Failure in servicing.- Returns:
MockHttpResponse.
-
send
Description copied from class:MockHttpServerSends theMockHttpRequestBuilderand blocks waiting for theMockHttpResponse.- Overrides:
sendin classMockHttpServer- Parameters:
request-MockHttpRequestBuilder.- Returns:
MockHttpResponse.
-
sendFollowRedirect
Description copied from class:MockHttpServerSends theMockHttpRequestBuilderand blocks following the redirect.- Overrides:
sendFollowRedirectin classMockHttpServer- Parameters:
request-MockHttpRequestBuilder.- Returns:
- Redirect
MockHttpResponse.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-