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 java.lang.Object
AbstractTestCasefor testing aHttpServerImplementation.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description AbstractHttpServerImplementationTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidasync()Ensure able to service asynchronous servicing.voidbufferHeavyLoad()Ensure can service multiple requests pipelined.voidbufferOverLoad()Ensure can service overload requests pipelined.voidbufferPipelineVerify()Verify pipeline HTTP requests.voidbufferPipelining()Ensure can pipeline HTTP requests.voidbufferThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidbytesHeavyLoad()Ensure can service multiple requests pipelined.voidbytesOverLoad()Ensure can service overload requests pipelined.voidbytesPipelineVerify()Verify pipeline HTTP requests.voidbytesPipelining()Ensure can pipeline HTTP requests.voidbytesThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidcancelConnection()EnsureProcessStateinstances for connection are cancelled on loss of connection.voiddoMultiClientLoadTest(java.lang.Class<?> servicerClass, int clientCount, int requestCount, java.lang.String resultName)Undertakes the multi-client pipelining test.voiddoPipelineVerifyTest(java.lang.Class<?> servicerClass)Undertakes verifying the pipeline tests.voidfileHeavyLoad()Ensure can service multiple requests pipelined.voidfileOverLoad()Ensure can service overload requests pipelined.voidfilePipelineVerify()Verify pipeline HTTP requests.voidfilePipelining()Ensure can pipeline HTTP requests.voidfileThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidfunctionality()Ensure able to send all details and receive all details.protected abstract java.lang.Class<? extends HttpServerImplementation>getHttpServerImplementationClass()Obtains the expectedHttpServerImplementationClassbeing tested.protected intgetRequestCount()Obtains the request count.protected java.lang.StringgetServerName()Obtains the server name.protected abstract java.lang.StringgetServerNameSuffix()Obtains theServerHttpHeaderValuesuffix.protected abstract HttpHeader[]getServerResponseHeaderValues()Obtains the server responseHttpHeaderinstances in the order they are sent from the server.voidhandleError()Ensure can handleEscalation.protected booleanisHandleCancel()Indicates if handle cancel.voidmultipleIndividualRequests()Ensure can send multiple HTTP requests.voidmultipleIndividualSecureRequests()Ensure can send multiple HTTPS requests.protected static HttpHeadernewHttpHeader(java.lang.String name, java.lang.String value)Creates a newHttpHeader.voidnotDecodeRequestUrl()Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).voidrawHeavyLoad()Ensure can service multiple requests pipelined.voidrawOverLoad()Ensure can service over requests pipelined.voidrawPipelineVerify()Verify pipeline HTTP requests.voidrawPipelining()Ensure can pipeline HTTP requests.voidrawSingleRequest()Ensure can handle raw single HTTP request.voidrawThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidsecureCancelConnection()EnsureProcessStateinstances for connection are cancelled on loss of secure connection.voidsecureSingleThreadedHandlerRequest()Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicerfor a secure connection.voidsecureSocket()Ensure raw secure request.voidserverDateHeaders()Ensure send Server and DateHttpHeadervalues.voidsetUp(org.junit.jupiter.api.TestInfo testInfo)voidsingleBufferRequest()Ensure can send a single HTTPByteBufferresponse.voidsingleCloseFileRequest()Ensure closes theFileChannelon write.voidsingleFileRequest()Ensure can send a single HTTPStreamBuffer.FileBufferresponse.voidsingleRequest()Ensure can send a single HTTP request.voidsingleSecureBufferRequest()Ensure can send a single HTTPSByteBufferresponse.voidsingleSecureCloseFileRequest()Ensure closes theFileChannelon write.voidsingleSecureFileRequest()Ensure can send a single HTTPSStreamBuffer.FileBufferresponse.voidsingleSecureRequest()Ensure can send a single HTTPS request.voidsingleThreadedHandlerRequest()Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer.voidsocket()Ensure raw request.protected voidstartHttpServer(java.lang.Class<?> sectionServicer)Starts theHttpServer.protected voidstartHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension)Starts theHttpServer.protected java.lang.AutoCloseablestartHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension)Starts theHttpServer.protected abstract java.lang.AutoCloseablestartRawHttpServer(HttpServerLocation serverLocation)Starts a raw implementation of the underlying HTTP server.voidteamPressureOverload()Ensure can handle pressure overloading the server.voidtearDown()
-
-
-
Method Detail
-
getRequestCount
protected int getRequestCount()
Obtains the request count.
Allows changing the number for server implementations that have higher overheads.
- Returns:
- Request count.
-
newHttpHeader
protected static HttpHeader newHttpHeader(java.lang.String name, java.lang.String value)
Creates a newHttpHeader.- Parameters:
name-HttpHeadername.value-HttpHeadervalue.- Returns:
- New
HttpHeader.
-
getHttpServerImplementationClass
protected abstract java.lang.Class<? extends HttpServerImplementation> getHttpServerImplementationClass()
Obtains the expectedHttpServerImplementationClassbeing tested.- Returns:
- Expected
HttpServerImplementationClass.
-
startRawHttpServer
protected abstract java.lang.AutoCloseable startRawHttpServer(HttpServerLocation serverLocation) throws java.lang.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:
java.lang.Exception- If fails to start the raw HTTP server.
-
getServerResponseHeaderValues
protected abstract HttpHeader[] 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
protected abstract java.lang.String getServerNameSuffix()
Obtains theServerHttpHeaderValuesuffix.- Returns:
ServerHttpHeaderValuesuffix. May benullif no suffix.
-
setUp
@BeforeEach public void setUp(org.junit.jupiter.api.TestInfo testInfo) throws java.lang.Exception- Throws:
java.lang.Exception
-
tearDown
@AfterEach public void tearDown() throws java.lang.Exception- Throws:
java.lang.Exception
-
startHttpServer
protected void startHttpServer(java.lang.Class<?> sectionServicer) throws java.lang.ExceptionStarts theHttpServer.- Parameters:
sectionServicer-Classof theClassSectionSourceto service theHttpRequest.- Throws:
java.lang.Exception- If fails to start theHttpServer.
-
startHttpServer
protected void startHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension) throws java.lang.ExceptionStarts theHttpServer.- Parameters:
sectionServicer-Classof theClassSectionSourceto service theHttpRequest.extension- AdditionalOfficeFloorExtensionService. May benull.- Throws:
java.lang.Exception- If fails to start theHttpServer.
-
startHttpServer
protected java.lang.AutoCloseable startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension) throws java.lang.Exception
Starts theHttpServer.- Parameters:
officeFloorExtension-OfficeFloorExtensionServiceto configure theOfficeFloor.officeExtension-OfficeExtensionServiceto configure theOfficeFloor.- Returns:
AutoCloseableto stop the server.- Throws:
java.lang.Exception- If fails to start theHttpServer.
-
async
@Test public void async() throws java.lang.ExceptionEnsure able to service asynchronous servicing.- Throws:
java.lang.Exception- If test failure.
-
functionality
@Test public void functionality() throws java.lang.ExceptionEnsure able to send all details and receive all details.- Throws:
java.lang.Exception- If test failure.
-
rawSingleRequest
@Test public void rawSingleRequest() throws java.lang.ExceptionEnsure can handle raw single HTTP request.- Throws:
java.lang.Exception- If test failure.
-
singleRequest
@Test public void singleRequest() throws java.lang.ExceptionEnsure can send a single HTTP request.- Throws:
java.lang.Exception- If test failure.
-
singleSecureRequest
@Test public void singleSecureRequest() throws java.lang.ExceptionEnsure can send a single HTTPS request.- Throws:
java.lang.Exception- If test failure.
-
singleBufferRequest
@Test public void singleBufferRequest() throws java.lang.ExceptionEnsure can send a single HTTPByteBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
singleSecureBufferRequest
@Test public void singleSecureBufferRequest() throws java.lang.ExceptionEnsure can send a single HTTPSByteBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
singleFileRequest
@Test public void singleFileRequest() throws java.lang.ExceptionEnsure can send a single HTTPStreamBuffer.FileBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
singleSecureFileRequest
@Test public void singleSecureFileRequest() throws java.lang.ExceptionEnsure can send a single HTTPSStreamBuffer.FileBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
serverDateHeaders
@Test public void serverDateHeaders() throws java.lang.ExceptionEnsure send Server and DateHttpHeadervalues.- Throws:
java.lang.Exception- If test failure.
-
getServerName
protected java.lang.String getServerName()
Obtains the server name.- Returns:
- Server name.
-
singleCloseFileRequest
@Test public void singleCloseFileRequest() throws java.lang.ExceptionEnsure closes theFileChannelon write.- Throws:
java.lang.Exception- If test failure.
-
singleSecureCloseFileRequest
@Test public void singleSecureCloseFileRequest() throws java.lang.ExceptionEnsure closes theFileChannelon write.- Throws:
java.lang.Exception- If test failure.
-
multipleIndividualRequests
public void multipleIndividualRequests() throws java.lang.ExceptionEnsure can send multiple HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
multipleIndividualSecureRequests
public void multipleIndividualSecureRequests() throws java.lang.ExceptionEnsure can send multiple HTTPS requests.- Throws:
java.lang.Exception- If test failure.
-
notDecodeRequestUrl
@Test public void notDecodeRequestUrl() throws java.lang.ExceptionEnsure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).- Throws:
java.lang.Exception- If test failure.
-
singleThreadedHandlerRequest
@Test public void singleThreadedHandlerRequest() throws java.lang.ExceptionEnsure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer.- Throws:
java.lang.Exception- If test failure.
-
secureSingleThreadedHandlerRequest
@Test public void secureSingleThreadedHandlerRequest() throws java.lang.ExceptionEnsure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicerfor a secure connection.- Throws:
java.lang.Exception- If test failure.
-
socket
@Test public void socket() throws java.lang.ExceptionEnsure raw request.- Throws:
java.lang.Exception- If test failure.
-
secureSocket
@Test public void secureSocket() throws java.lang.ExceptionEnsure raw secure request.- Throws:
java.lang.Exception- If test failure.
-
handleError
@Test public void handleError() throws java.lang.ExceptionEnsure can handleEscalation.- Throws:
java.lang.Exception- If test failure.
-
teamPressureOverload
@Test public void teamPressureOverload() throws java.lang.ExceptionEnsure can handle pressure overloading the server.- Throws:
java.lang.Exception- If test failure.
-
cancelConnection
@Test public void cancelConnection() throws java.lang.ExceptionEnsureProcessStateinstances for connection are cancelled on loss of connection.- Throws:
java.lang.Exception- If test failure.
-
secureCancelConnection
@Test public void secureCancelConnection() throws java.lang.ExceptionEnsureProcessStateinstances for connection are cancelled on loss of secure connection.- Throws:
java.lang.Exception- If test failure.
-
isHandleCancel
protected boolean isHandleCancel()
Indicates if handle cancel.- Returns:
trueif handle cancel.
-
rawPipelineVerify
@Test public void rawPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
bytesPipelineVerify
@Test public void bytesPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
bufferPipelineVerify
@Test public void bufferPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
filePipelineVerify
@Test public void filePipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
doPipelineVerifyTest
public void doPipelineVerifyTest(java.lang.Class<?> servicerClass) throws java.lang.ExceptionUndertakes verifying the pipeline tests.- Parameters:
servicerClass- ServicerClass.- Throws:
java.lang.Exception- If fails test.
-
rawPipelining
public void rawPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
bytesPipelining
public void bytesPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
bufferPipelining
public void bufferPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
filePipelining
public void filePipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
rawThreadedHandler
public void rawThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
bytesThreadedHandler
public void bytesThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
bufferThreadedHandler
public void bufferThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
fileThreadedHandler
public void fileThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
rawHeavyLoad
public void rawHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
bytesHeavyLoad
public void bytesHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
bufferHeavyLoad
public void bufferHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
fileHeavyLoad
public void fileHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
rawOverLoad
public void rawOverLoad() throws java.lang.ExceptionEnsure can service over requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
bytesOverLoad
public void bytesOverLoad() throws java.lang.ExceptionEnsure can service overload requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
bufferOverLoad
public void bufferOverLoad() throws java.lang.ExceptionEnsure can service overload requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
fileOverLoad
public void fileOverLoad() throws java.lang.ExceptionEnsure can service overload requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
doMultiClientLoadTest
public void doMultiClientLoadTest(java.lang.Class<?> servicerClass, int clientCount, int requestCount, java.lang.String resultName) throws java.lang.ExceptionUndertakes the multi-client pipelining test.- Parameters:
servicerClass- ServicerClass.clientCount- Number of simultaneous clients.requestCount- Number of requests per client.resultName- Name of result for comparison.- Throws:
java.lang.Exception- If test failure.
-
-