Package net.officefloor.server.http
Class AbstractHttpServerImplementationTestCase
java.lang.Object
net.officefloor.server.http.AbstractHttpServerImplementationTestCase
- Direct Known Subclasses:
AbstractServletHttpServerImplementationTest
@ExtendWith(TestSupportExtension.class)
public abstract class AbstractHttpServerImplementationTestCase
extends Object
Abstract
TestCase for testing a HttpServerImplementation.- Author:
- Daniel Sagenschneider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTest fixture for asynchronous servicing.static classTest fixture for servicing requests with aByteBuffer.static classTest fixture for servicing requests with raw bytes.static classAbstractManagedObjectSourceto cancel connections.static classTest fixture for servicing requests that wait for connection cancellation.static classTest fixture for servicing requests that closes a file channel after writing.protected static classCompares results ofOfficeFloorservicing against Raw servicing.static classTest fixture for servicing requests with encoded URLs.static classTest fixture for servicing requests that fail.static classTest fixture for servicing requests with a file.static classTest fixture for verifying full HTTP request and response functionality.protected static classResult of a pipeline execution.static classServicer that is slow causing significant back pressure.static classTest fixture for servicing requests with qualified connections.static classTest fixture for servicing requests.static classMarkerManagedObjectfor identifyingTeam.static classMarkerManagedObjectfor identifyingTeam.static classMarker managed object for threaded servicing.static classTest fixture for servicing requests on a different thread. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringQualifier for the firstServerHttpConnection.static final StringQualifier for the secondServerHttpConnection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidasync()Ensure able to service asynchronous servicing.voidEnsure can service multiple requests pipelined.voidEnsure can service overload requests pipelined.voidVerify pipeline HTTP requests.voidEnsure can pipeline HTTP requests.voidEnsure can handle HTTP requests with threaded handler.voidEnsure can service multiple requests pipelined.voidEnsure can service overload requests pipelined.voidVerify pipeline HTTP requests.voidEnsure can pipeline HTTP requests.voidEnsure can handle HTTP requests with threaded handler.voidEnsureProcessStateinstances for connection are cancelled on loss of connection.voiddoMultiClientLoadTest(Class<?> servicerClass, int clientCount, int requestCount, String resultName) Undertakes the multi-client pipelining test.voiddoPipelineVerifyTest(Class<?> servicerClass) Undertakes verifying the pipeline tests.voidEnsure can service multiple requests pipelined.voidEnsure can service overload requests pipelined.voidVerify pipeline HTTP requests.voidEnsure can pipeline HTTP requests.voidEnsure can handle HTTP requests with threaded handler.voidEnsure able to send all details and receive all details.protected abstract Class<? extends HttpServerImplementation>Obtains the expectedHttpServerImplementationClassbeing tested.protected intObtains the request count.protected StringObtains the server name.protected abstract StringObtains theServerHttpHeaderValuesuffix.protected abstract HttpHeader[]Obtains the server responseHttpHeaderinstances in the order they are sent from the server.voidEnsure can handleEscalation.protected booleanIndicates if handle cancel.voidEnsure can send multiple HTTP requests.voidEnsure can send multiple HTTPS requests.protected static HttpHeadernewHttpHeader(String name, String value) Creates a newHttpHeader.voidEnsure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).voidEnsure can qualify theServerHttpConnection.voidEnsure can service multiple requests pipelined.voidEnsure can service over requests pipelined.voidVerify pipeline HTTP requests.voidEnsure can pipeline HTTP requests.voidEnsure can handle raw single HTTP request.voidEnsure can handle HTTP requests with threaded handler.voidEnsureProcessStateinstances for connection are cancelled on loss of secure connection.voidEnsure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicerfor a secure connection.voidEnsure raw secure request.voidEnsure send Server and DateHttpHeadervalues.voidsetUp(org.junit.jupiter.api.TestInfo testInfo) Sets up the test.voidEnsure can send a single HTTPByteBufferresponse.voidEnsure closes theFileChannelon write.voidEnsure can send a single HTTPStreamBuffer.FileBufferresponse.voidEnsure can send a single HTTP request.voidEnsure can send a single HTTPSByteBufferresponse.voidEnsure closes theFileChannelon write.voidEnsure can send a single HTTPSStreamBuffer.FileBufferresponse.voidEnsure can send a single HTTPS request.voidEnsure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer.voidsocket()Ensure raw request.protected voidstartHttpServer(Class<?> sectionServicer) Starts theHttpServer.protected voidstartHttpServer(Class<?> sectionServicer, String qualifier, OfficeFloorExtensionService extension) Starts theHttpServer.protected AutoCloseablestartHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension) Starts theHttpServer.protected abstract AutoCloseablestartRawHttpServer(HttpServerLocation serverLocation) Starts a raw implementation of the underlying HTTP server.voidEnsure can handle pressure overloading the server.voidtearDown()Tears down the test.
-
Field Details
-
CONNECTION_QUALIFIER_ONE
Qualifier for the firstServerHttpConnection.- See Also:
-
CONNECTION_QUALIFIER_TWO
Qualifier for the secondServerHttpConnection.- See Also:
-
-
Constructor Details
-
AbstractHttpServerImplementationTestCase
public AbstractHttpServerImplementationTestCase()
-
-
Method Details
-
getRequestCount
protected int getRequestCount()Obtains the request count.
Allows changing the number for server implementations that have higher overheads.
- Returns:
- Request count.
-
newHttpHeader
Creates a newHttpHeader.- Parameters:
name-HttpHeadername.value-HttpHeadervalue.- Returns:
- New
HttpHeader.
-
getHttpServerImplementationClass
Obtains the expectedHttpServerImplementationClassbeing tested.- Returns:
- Expected
HttpServerImplementationClass.
-
startRawHttpServer
protected abstract AutoCloseable startRawHttpServer(HttpServerLocation serverLocation) throws Exception Starts a raw implementation of the underlying HTTP server. This allows performance comparisons of adding in
OfficeFloorservicing overheads.The raw implementation is to return "hello world" in UTF-8 encoding for the response entity.
- Parameters:
serverLocation-HttpServerLocation.- Returns:
AutoCloseableTo stop the server.- Throws:
Exception- If fails to start the raw HTTP server.
-
getServerResponseHeaderValues
Obtains the server responseHttpHeaderinstances in the order they are sent from the server.- Returns:
- Server response
HttpHeaderinstances in the order they are sent from the server.
-
getServerNameSuffix
Obtains theServerHttpHeaderValuesuffix.- Returns:
ServerHttpHeaderValuesuffix. May benullif no suffix.
-
setUp
Sets up the test.- Parameters:
testInfo-TestInfo.- Throws:
Exception- On test failure.
-
tearDown
Tears down the test.- Throws:
Exception- On test failure.
-
startHttpServer
Starts theHttpServer.- Parameters:
sectionServicer-Classof theClassSectionSourceto service theHttpRequest.- Throws:
Exception- If fails to start theHttpServer.
-
startHttpServer
protected void startHttpServer(Class<?> sectionServicer, String qualifier, OfficeFloorExtensionService extension) throws Exception Starts theHttpServer.- Parameters:
sectionServicer-Classof theClassSectionSourceto service theHttpRequest.qualifier- Qualifier for theExternalServiceInput. May benull.extension- AdditionalOfficeFloorExtensionService. May benull.- Throws:
Exception- If fails to start theHttpServer.
-
startHttpServer
protected AutoCloseable startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension) throws Exception Starts theHttpServer.- Parameters:
officeFloorExtension-OfficeFloorExtensionServiceto configure theOfficeFloor.officeExtension-OfficeExtensionServiceto configure theOfficeFloor.- Returns:
AutoCloseableto stop the server.- Throws:
Exception- If fails to start theHttpServer.
-
async
Ensure able to service asynchronous servicing.- Throws:
Exception- If test failure.
-
functionality
Ensure able to send all details and receive all details.- Throws:
Exception- If test failure.
-
qualified
Ensure can qualify theServerHttpConnection.- Throws:
Exception- If test failure.
-
rawSingleRequest
Ensure can handle raw single HTTP request.- Throws:
Exception- If test failure.
-
singleRequest
Ensure can send a single HTTP request.- Throws:
Exception- If test failure.
-
singleSecureRequest
Ensure can send a single HTTPS request.- Throws:
Exception- If test failure.
-
singleBufferRequest
Ensure can send a single HTTPByteBufferresponse.- Throws:
Exception- If test failure.
-
singleSecureBufferRequest
Ensure can send a single HTTPSByteBufferresponse.- Throws:
Exception- If test failure.
-
singleFileRequest
Ensure can send a single HTTPStreamBuffer.FileBufferresponse.- Throws:
Exception- If test failure.
-
singleSecureFileRequest
Ensure can send a single HTTPSStreamBuffer.FileBufferresponse.- Throws:
Exception- If test failure.
-
serverDateHeaders
Ensure send Server and DateHttpHeadervalues.- Throws:
Exception- If test failure.
-
getServerName
Obtains the server name.- Returns:
- Server name.
-
singleCloseFileRequest
Ensure closes theFileChannelon write.- Throws:
Exception- If test failure.
-
singleSecureCloseFileRequest
Ensure closes theFileChannelon write.- Throws:
Exception- If test failure.
-
multipleIndividualRequests
Ensure can send multiple HTTP requests.- Throws:
Exception- If test failure.
-
multipleIndividualSecureRequests
Ensure can send multiple HTTPS requests.- Throws:
Exception- If test failure.
-
notDecodeRequestUrl
Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).- Throws:
Exception- If test failure.
-
singleThreadedHandlerRequest
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer.- Throws:
Exception- If test failure.
-
secureSingleThreadedHandlerRequest
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicerfor a secure connection.- Throws:
Exception- If test failure.
-
socket
Ensure raw request.- Throws:
Exception- If test failure.
-
secureSocket
Ensure raw secure request.- Throws:
Exception- If test failure.
-
handleError
Ensure can handleEscalation.- Throws:
Exception- If test failure.
-
teamPressureOverload
Ensure can handle pressure overloading the server.- Throws:
Exception- If test failure.
-
cancelConnection
EnsureProcessStateinstances for connection are cancelled on loss of connection.- Throws:
Exception- If test failure.
-
secureCancelConnection
EnsureProcessStateinstances for connection are cancelled on loss of secure connection.- Throws:
Exception- If test failure.
-
isHandleCancel
protected boolean isHandleCancel()Indicates if handle cancel.- Returns:
trueif handle cancel.
-
rawPipelineVerify
Verify pipeline HTTP requests.- Throws:
Exception- If test failure.
-
bytesPipelineVerify
Verify pipeline HTTP requests.- Throws:
Exception- If test failure.
-
bufferPipelineVerify
Verify pipeline HTTP requests.- Throws:
Exception- If test failure.
-
filePipelineVerify
Verify pipeline HTTP requests.- Throws:
Exception- If test failure.
-
doPipelineVerifyTest
Undertakes verifying the pipeline tests. -
rawPipelining
Ensure can pipeline HTTP requests.- Throws:
Exception- If test failure.
-
bytesPipelining
Ensure can pipeline HTTP requests.- Throws:
Exception- If test failure.
-
bufferPipelining
Ensure can pipeline HTTP requests.- Throws:
Exception- If test failure.
-
filePipelining
Ensure can pipeline HTTP requests.- Throws:
Exception- If test failure.
-
rawThreadedHandler
Ensure can handle HTTP requests with threaded handler.- Throws:
Exception- If test failure.
-
bytesThreadedHandler
Ensure can handle HTTP requests with threaded handler.- Throws:
Exception- If test failure.
-
bufferThreadedHandler
Ensure can handle HTTP requests with threaded handler.- Throws:
Exception- If test failure.
-
fileThreadedHandler
Ensure can handle HTTP requests with threaded handler.- Throws:
Exception- If test failure.
-
rawHeavyLoad
Ensure can service multiple requests pipelined.- Throws:
Exception- If test failure.
-
bytesHeavyLoad
Ensure can service multiple requests pipelined.- Throws:
Exception- If test failure.
-
bufferHeavyLoad
Ensure can service multiple requests pipelined.- Throws:
Exception- If test failure.
-
fileHeavyLoad
Ensure can service multiple requests pipelined.- Throws:
Exception- If test failure.
-
rawOverLoad
Ensure can service over requests pipelined.- Throws:
Exception- If test failure.
-
bytesOverLoad
Ensure can service overload requests pipelined.- Throws:
Exception- If test failure.
-
bufferOverLoad
Ensure can service overload requests pipelined.- Throws:
Exception- If test failure.
-
fileOverLoad
Ensure can service overload requests pipelined.- Throws:
Exception- If test failure.
-
doMultiClientLoadTest
public void doMultiClientLoadTest(Class<?> servicerClass, int clientCount, int requestCount, String resultName) throws Exception Undertakes the multi-client pipelining test.
-