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
AbstractTestCase
for 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 void
async()
Ensure able to service asynchronous servicing.void
bufferHeavyLoad()
Ensure can service multiple requests pipelined.void
bufferOverLoad()
Ensure can service overload requests pipelined.void
bufferPipelineVerify()
Verify pipeline HTTP requests.void
bufferPipelining()
Ensure can pipeline HTTP requests.void
bufferThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
bytesHeavyLoad()
Ensure can service multiple requests pipelined.void
bytesOverLoad()
Ensure can service overload requests pipelined.void
bytesPipelineVerify()
Verify pipeline HTTP requests.void
bytesPipelining()
Ensure can pipeline HTTP requests.void
bytesThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
cancelConnection()
EnsureProcessState
instances for connection are cancelled on loss of connection.void
doMultiClientLoadTest(java.lang.Class<?> servicerClass, int clientCount, int requestCount, java.lang.String resultName)
Undertakes the multi-client pipelining test.void
doPipelineVerifyTest(java.lang.Class<?> servicerClass)
Undertakes verifying the pipeline tests.void
fileHeavyLoad()
Ensure can service multiple requests pipelined.void
fileOverLoad()
Ensure can service overload requests pipelined.void
filePipelineVerify()
Verify pipeline HTTP requests.void
filePipelining()
Ensure can pipeline HTTP requests.void
fileThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
functionality()
Ensure able to send all details and receive all details.protected abstract java.lang.Class<? extends HttpServerImplementation>
getHttpServerImplementationClass()
Obtains the expectedHttpServerImplementation
Class
being tested.protected int
getRequestCount()
Obtains the request count.protected java.lang.String
getServerName()
Obtains the server name.protected abstract java.lang.String
getServerNameSuffix()
Obtains theServer
HttpHeaderValue
suffix.protected abstract HttpHeader[]
getServerResponseHeaderValues()
Obtains the server responseHttpHeader
instances in the order they are sent from the server.void
handleError()
Ensure can handleEscalation
.protected boolean
isHandleCancel()
Indicates if handle cancel.void
multipleIndividualRequests()
Ensure can send multiple HTTP requests.void
multipleIndividualSecureRequests()
Ensure can send multiple HTTPS requests.protected static HttpHeader
newHttpHeader(java.lang.String name, java.lang.String value)
Creates a newHttpHeader
.void
notDecodeRequestUrl()
Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).void
rawHeavyLoad()
Ensure can service multiple requests pipelined.void
rawOverLoad()
Ensure can service over requests pipelined.void
rawPipelineVerify()
Verify pipeline HTTP requests.void
rawPipelining()
Ensure can pipeline HTTP requests.void
rawSingleRequest()
Ensure can handle raw single HTTP request.void
rawThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
secureCancelConnection()
EnsureProcessState
instances for connection are cancelled on loss of secure connection.void
secureSingleThreadedHandlerRequest()
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer
for a secure connection.void
secureSocket()
Ensure raw secure request.void
serverDateHeaders()
Ensure send Server and DateHttpHeader
values.void
setUp(org.junit.jupiter.api.TestInfo testInfo)
void
singleBufferRequest()
Ensure can send a single HTTPByteBuffer
response.void
singleCloseFileRequest()
Ensure closes theFileChannel
on write.void
singleFileRequest()
Ensure can send a single HTTPStreamBuffer.FileBuffer
response.void
singleRequest()
Ensure can send a single HTTP request.void
singleSecureBufferRequest()
Ensure can send a single HTTPSByteBuffer
response.void
singleSecureCloseFileRequest()
Ensure closes theFileChannel
on write.void
singleSecureFileRequest()
Ensure can send a single HTTPSStreamBuffer.FileBuffer
response.void
singleSecureRequest()
Ensure can send a single HTTPS request.void
singleThreadedHandlerRequest()
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer
.void
socket()
Ensure raw request.protected void
startHttpServer(java.lang.Class<?> sectionServicer)
Starts theHttpServer
.protected void
startHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension)
Starts theHttpServer
.protected java.lang.AutoCloseable
startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension)
Starts theHttpServer
.protected abstract java.lang.AutoCloseable
startRawHttpServer(HttpServerLocation serverLocation)
Starts a raw implementation of the underlying HTTP server.void
teamPressureOverload()
Ensure can handle pressure overloading the server.void
tearDown()
-
-
-
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
-HttpHeader
name.value
-HttpHeader
value.- Returns:
- New
HttpHeader
.
-
getHttpServerImplementationClass
protected abstract java.lang.Class<? extends HttpServerImplementation> getHttpServerImplementationClass()
Obtains the expectedHttpServerImplementation
Class
being tested.- Returns:
- Expected
HttpServerImplementation
Class
.
-
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
OfficeFloor
servicing overheads.The raw implementation is to return "hello world" in UTF-8 encoding for the response entity.
- Parameters:
serverLocation
-HttpServerLocation
.- Returns:
AutoCloseable
To stop the server.- Throws:
java.lang.Exception
- If fails to start the raw HTTP server.
-
getServerResponseHeaderValues
protected abstract HttpHeader[] getServerResponseHeaderValues()
Obtains the server responseHttpHeader
instances in the order they are sent from the server.- Returns:
- Server response
HttpHeader
instances in the order they are sent from the server.
-
getServerNameSuffix
protected abstract java.lang.String getServerNameSuffix()
Obtains theServer
HttpHeaderValue
suffix.- Returns:
Server
HttpHeaderValue
suffix. May benull
if 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.Exception
Starts theHttpServer
.- Parameters:
sectionServicer
-Class
of theClassSectionSource
to service theHttpRequest
.- Throws:
java.lang.Exception
- If fails to start theHttpServer
.
-
startHttpServer
protected void startHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension) throws java.lang.Exception
Starts theHttpServer
.- Parameters:
sectionServicer
-Class
of theClassSectionSource
to 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
-OfficeFloorExtensionService
to configure theOfficeFloor
.officeExtension
-OfficeExtensionService
to configure theOfficeFloor
.- Returns:
AutoCloseable
to stop the server.- Throws:
java.lang.Exception
- If fails to start theHttpServer
.
-
async
@Test public void async() throws java.lang.Exception
Ensure able to service asynchronous servicing.- Throws:
java.lang.Exception
- If test failure.
-
functionality
@Test public void functionality() throws java.lang.Exception
Ensure able to send all details and receive all details.- Throws:
java.lang.Exception
- If test failure.
-
rawSingleRequest
@Test public void rawSingleRequest() throws java.lang.Exception
Ensure can handle raw single HTTP request.- Throws:
java.lang.Exception
- If test failure.
-
singleRequest
@Test public void singleRequest() throws java.lang.Exception
Ensure can send a single HTTP request.- Throws:
java.lang.Exception
- If test failure.
-
singleSecureRequest
@Test public void singleSecureRequest() throws java.lang.Exception
Ensure can send a single HTTPS request.- Throws:
java.lang.Exception
- If test failure.
-
singleBufferRequest
@Test public void singleBufferRequest() throws java.lang.Exception
Ensure can send a single HTTPByteBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
singleSecureBufferRequest
@Test public void singleSecureBufferRequest() throws java.lang.Exception
Ensure can send a single HTTPSByteBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
singleFileRequest
@Test public void singleFileRequest() throws java.lang.Exception
Ensure can send a single HTTPStreamBuffer.FileBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
singleSecureFileRequest
@Test public void singleSecureFileRequest() throws java.lang.Exception
Ensure can send a single HTTPSStreamBuffer.FileBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
serverDateHeaders
@Test public void serverDateHeaders() throws java.lang.Exception
Ensure send Server and DateHttpHeader
values.- 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.Exception
Ensure closes theFileChannel
on write.- Throws:
java.lang.Exception
- If test failure.
-
singleSecureCloseFileRequest
@Test public void singleSecureCloseFileRequest() throws java.lang.Exception
Ensure closes theFileChannel
on write.- Throws:
java.lang.Exception
- If test failure.
-
multipleIndividualRequests
public void multipleIndividualRequests() throws java.lang.Exception
Ensure can send multiple HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
multipleIndividualSecureRequests
public void multipleIndividualSecureRequests() throws java.lang.Exception
Ensure can send multiple HTTPS requests.- Throws:
java.lang.Exception
- If test failure.
-
notDecodeRequestUrl
@Test public void notDecodeRequestUrl() throws java.lang.Exception
Ensure 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.Exception
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer
.- Throws:
java.lang.Exception
- If test failure.
-
secureSingleThreadedHandlerRequest
@Test public void secureSingleThreadedHandlerRequest() throws java.lang.Exception
Ensure can handle request withAbstractHttpServerImplementationTestCase.ThreadedServicer
for a secure connection.- Throws:
java.lang.Exception
- If test failure.
-
socket
@Test public void socket() throws java.lang.Exception
Ensure raw request.- Throws:
java.lang.Exception
- If test failure.
-
secureSocket
@Test public void secureSocket() throws java.lang.Exception
Ensure raw secure request.- Throws:
java.lang.Exception
- If test failure.
-
handleError
@Test public void handleError() throws java.lang.Exception
Ensure can handleEscalation
.- Throws:
java.lang.Exception
- If test failure.
-
teamPressureOverload
@Test public void teamPressureOverload() throws java.lang.Exception
Ensure can handle pressure overloading the server.- Throws:
java.lang.Exception
- If test failure.
-
cancelConnection
@Test public void cancelConnection() throws java.lang.Exception
EnsureProcessState
instances for connection are cancelled on loss of connection.- Throws:
java.lang.Exception
- If test failure.
-
secureCancelConnection
@Test public void secureCancelConnection() throws java.lang.Exception
EnsureProcessState
instances 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:
true
if handle cancel.
-
rawPipelineVerify
@Test public void rawPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
bytesPipelineVerify
@Test public void bytesPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
bufferPipelineVerify
@Test public void bufferPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
filePipelineVerify
@Test public void filePipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
doPipelineVerifyTest
public void doPipelineVerifyTest(java.lang.Class<?> servicerClass) throws java.lang.Exception
Undertakes verifying the pipeline tests.- Parameters:
servicerClass
- ServicerClass
.- Throws:
java.lang.Exception
- If fails test.
-
rawPipelining
public void rawPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
bytesPipelining
public void bytesPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
bufferPipelining
public void bufferPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
filePipelining
public void filePipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
rawThreadedHandler
public void rawThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
bytesThreadedHandler
public void bytesThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
bufferThreadedHandler
public void bufferThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
fileThreadedHandler
public void fileThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
rawHeavyLoad
public void rawHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
bytesHeavyLoad
public void bytesHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
bufferHeavyLoad
public void bufferHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
fileHeavyLoad
public void fileHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
rawOverLoad
public void rawOverLoad() throws java.lang.Exception
Ensure can service over requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
bytesOverLoad
public void bytesOverLoad() throws java.lang.Exception
Ensure can service overload requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
bufferOverLoad
public void bufferOverLoad() throws java.lang.Exception
Ensure can service overload requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
fileOverLoad
public void fileOverLoad() throws java.lang.Exception
Ensure 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.Exception
Undertakes 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.
-
-