Package net.officefloor.server.http
Class AbstractHttpServerImplementationTest<M>
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- net.officefloor.frame.test.OfficeFrameTestCase
-
- net.officefloor.server.http.AbstractHttpServerImplementationTest<M>
-
- Type Parameters:
M
- Type of momento from raw HTTP server.
- All Implemented Interfaces:
junit.framework.Test
public abstract class AbstractHttpServerImplementationTest<M> extends OfficeFrameTestCase
AbstractTestCase
for testing aHttpServerImplementation
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.frame.test.OfficeFrameTestCase
OfficeFrameTestCase.FailOperation, OfficeFrameTestCase.GuiTest, OfficeFrameTestCase.MultithreadedTestLogic<T extends java.lang.Throwable>, OfficeFrameTestCase.StressTest, OfficeFrameTestCase.TestCapture<T extends java.lang.Throwable>, OfficeFrameTestCase.TestLogic<R,T extends java.lang.Throwable>, OfficeFrameTestCase.UsesDockerTest, OfficeFrameTestCase.UsesGCloudTest, OfficeFrameTestCase.WaitForTruePredicate<T extends java.lang.Throwable>
-
-
Field Summary
-
Fields inherited from class net.officefloor.frame.test.OfficeFrameTestCase
CLASS_LOADER_EXTRA_CLASS_NAME, CLASS_LOADER_EXTRA_PACKAGE_NAME, classLoaderTestSupport, END_OF_LINE, fileTestSupport, logTestSupport, mockTestSupport, threadedTestSupport
-
-
Constructor Summary
Constructors Constructor Description AbstractHttpServerImplementationTest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.protected abstract java.lang.Class<? extends HttpServerImplementation>
getHttpServerImplementationClass()
Obtains the expectedHttpServerImplementation
Class
being tested.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.protected boolean
isHandleCancel()
Indicates if handle cancel.protected static HttpHeader
newHttpHeader(java.lang.String name, java.lang.String value)
Creates a newHttpHeader
.protected void
setUp()
protected void
startHttpServer(java.lang.Class<?> sectionServicer)
Starts theHttpServer
.protected void
startHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension)
Starts theHttpServer
.protected void
startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension, java.util.function.Consumer<OfficeFloor> officeFloorListener)
Starts theHttpServer
.protected abstract M
startRawHttpServer(HttpServerLocation serverLocation)
Starts a raw implementation of the underlying HTTP server.protected abstract void
stopRawHttpServer(M momento)
Stops the raw implementation.protected void
tearDown()
void
testBufferHeavyLoad()
Ensure can service multiple requests pipelined.void
testBufferOverLoad()
Ensure can service overload requests pipelined.void
testBufferPipelineVerify()
Verify pipeline HTTP requests.void
testBufferPipelining()
Ensure can pipeline HTTP requests.void
testBufferThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
testBytesHeavyLoad()
Ensure can service multiple requests pipelined.void
testBytesOverLoad()
Ensure can service overload requests pipelined.void
testBytesPipelineVerify()
Verify pipeline HTTP requests.void
testBytesPipelining()
Ensure can pipeline HTTP requests.void
testBytesThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
testCancelConnection()
EnsureProcessState
instances for connection are cancelled on loss of connection.void
testFileHeavyLoad()
Ensure can service multiple requests pipelined.void
testFileOverLoad()
Ensure can service overload requests pipelined.void
testFilePipelineVerify()
Verify pipeline HTTP requests.void
testFilePipelining()
Ensure can pipeline HTTP requests.void
testFileThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
testFunctionality()
Ensure able to send all details and receive all details.void
testHandleError()
Ensure can handleEscalation
.void
testMultipleIndividualRequests()
Ensure can send multiple HTTP requests.void
testMultipleIndividualSecureRequests()
Ensure can send multiple HTTPS requests.void
testNotDecodeRequestUrl()
Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).void
testRawHeavyLoad()
Ensure can service multiple requests pipelined.void
testRawOverLoad()
Ensure can service over requests pipelined.void
testRawPipelineVerify()
Verify pipeline HTTP requests.void
testRawPipelining()
Ensure can pipeline HTTP requests.void
testRawSingleRequest()
Ensure can handle raw single HTTP request.void
testRawThreadedHandler()
Ensure can handle HTTP requests with threaded handler.void
testSecureCancelConnection()
EnsureProcessState
instances for connection are cancelled on loss of secure connection.void
testSecureSingleThreadedHandlerRequest()
Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer
for a secure connection.void
testSecureSocket()
Ensure raw secure request.void
testServerDateHeaders()
Ensure send Server and DateHttpHeader
values.void
testSingleBufferRequest()
Ensure can send a single HTTPByteBuffer
response.void
testSingleCloseFileRequest()
Ensure closes theFileChannel
on write.void
testSingleFileRequest()
Ensure can send a single HTTPStreamBuffer.FileBuffer
response.void
testSingleRequest()
Ensure can send a single HTTP request.void
testSingleSecureBufferRequest()
Ensure can send a single HTTPSByteBuffer
response.void
testSingleSecureCloseFileRequest()
Ensure closes theFileChannel
on write.void
testSingleSecureFileRequest()
Ensure can send a single HTTPSStreamBuffer.FileBuffer
response.void
testSingleSecureRequest()
Ensure can send a single HTTPS request.void
testSingleThreadedHandlerRequest()
Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer
.void
testSocket()
Ensure raw request.void
testTeamPressureOverload()
Ensure can handle pressure overloading the server.-
Methods inherited from class net.officefloor.frame.test.OfficeFrameTestCase
assertContents, assertContents, assertFail, assertFail, assertFail, assertGraph, assertList, assertList, assertList, assertList, assertList, assertProperties, assertTextEquals, assertXmlEquals, captureLoggerOutput, clearDirectory, copyDirectory, createFile, createMock, createNewClassLoader, createPlatformIndependentText, createSynchronizedMock, deleteDirectory, displayGraph, displayGraph, doMultiThreadedTest, doMultiThreadedTest, doTest, fail, findFile, findFile, findInputStream, getDisplayRunTime, getDisplayRunTime, getFileContents, getFileLocation, getItem, getPackageRelativePath, getProperty, isGuiAvailable, isPrintMessages, isSkipStressTests, isSkipTestsUsingDocker, isSkipTestsUsingGCloud, param, paramType, printHeapMemoryDiagnostics, printMessage, printMessage, printMessage, recordReturn, recordReturn, recordThrows, recordVoid, removeXmlWhiteSpacing, replayMockObjects, runBare, setDebugVerbose, setLogGC, setName, setVerbose, sleep, throwException, timeout, timeout, verifyMockObjects, waitForTrue, waitForTrue
-
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, toString
-
-
-
-
Method Detail
-
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 M 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:
- Momento to provide to stopping the server.
- Throws:
java.lang.Exception
- If fails to start the raw HTTP server.
-
stopRawHttpServer
protected abstract void stopRawHttpServer(M momento) throws java.lang.Exception
Stops the raw implementation.- Parameters:
momento
- Momento provided from starting the raw HTTP server.- Throws:
java.lang.Exception
- If fails to stop 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
protected void setUp() throws java.lang.Exception
- Overrides:
setUp
in classjunit.framework.TestCase
- Throws:
java.lang.Exception
-
tearDown
protected void tearDown() throws java.lang.Exception
- Overrides:
tearDown
in classjunit.framework.TestCase
- 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 void startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension, java.util.function.Consumer<OfficeFloor> officeFloorListener) throws java.lang.Exception
Starts theHttpServer
.- Parameters:
officeFloorExtension
-OfficeFloorExtensionService
to configure theOfficeFloor
.officeExtension
-OfficeExtensionService
to configure theOfficeFloor
.officeFloorListener
-Consumer
to receive theOfficeFloor
.- Throws:
java.lang.Exception
- If fails to start theHttpServer
.
-
testFunctionality
public void testFunctionality() throws java.lang.Exception
Ensure able to send all details and receive all details.- Throws:
java.lang.Exception
- If test failure.
-
testRawSingleRequest
public void testRawSingleRequest() throws java.lang.Exception
Ensure can handle raw single HTTP request.- Throws:
java.lang.Exception
- If test failure.
-
testSingleRequest
public void testSingleRequest() throws java.lang.Exception
Ensure can send a single HTTP request.- Throws:
java.lang.Exception
- If test failure.
-
testSingleSecureRequest
public void testSingleSecureRequest() throws java.lang.Exception
Ensure can send a single HTTPS request.- Throws:
java.lang.Exception
- If test failure.
-
testSingleBufferRequest
public void testSingleBufferRequest() throws java.lang.Exception
Ensure can send a single HTTPByteBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
testSingleSecureBufferRequest
public void testSingleSecureBufferRequest() throws java.lang.Exception
Ensure can send a single HTTPSByteBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
testSingleFileRequest
public void testSingleFileRequest() throws java.lang.Exception
Ensure can send a single HTTPStreamBuffer.FileBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
testSingleSecureFileRequest
public void testSingleSecureFileRequest() throws java.lang.Exception
Ensure can send a single HTTPSStreamBuffer.FileBuffer
response.- Throws:
java.lang.Exception
- If test failure.
-
testServerDateHeaders
public void testServerDateHeaders() 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.
-
testSingleCloseFileRequest
public void testSingleCloseFileRequest() throws java.lang.Exception
Ensure closes theFileChannel
on write.- Throws:
java.lang.Exception
- If test failure.
-
testSingleSecureCloseFileRequest
public void testSingleSecureCloseFileRequest() throws java.lang.Exception
Ensure closes theFileChannel
on write.- Throws:
java.lang.Exception
- If test failure.
-
testMultipleIndividualRequests
public void testMultipleIndividualRequests() throws java.lang.Exception
Ensure can send multiple HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testMultipleIndividualSecureRequests
public void testMultipleIndividualSecureRequests() throws java.lang.Exception
Ensure can send multiple HTTPS requests.- Throws:
java.lang.Exception
- If test failure.
-
testNotDecodeRequestUrl
public void testNotDecodeRequestUrl() 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.
-
testSingleThreadedHandlerRequest
public void testSingleThreadedHandlerRequest() throws java.lang.Exception
Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer
.- Throws:
java.lang.Exception
- If test failure.
-
testSecureSingleThreadedHandlerRequest
public void testSecureSingleThreadedHandlerRequest() throws java.lang.Exception
Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer
for a secure connection.- Throws:
java.lang.Exception
- If test failure.
-
testSocket
public void testSocket() throws java.lang.Exception
Ensure raw request.- Throws:
java.lang.Exception
- If test failure.
-
testSecureSocket
public void testSecureSocket() throws java.lang.Exception
Ensure raw secure request.- Throws:
java.lang.Exception
- If test failure.
-
testHandleError
public void testHandleError() throws java.lang.Exception
Ensure can handleEscalation
.- Throws:
java.lang.Exception
- If test failure.
-
testTeamPressureOverload
public void testTeamPressureOverload() throws java.lang.Exception
Ensure can handle pressure overloading the server.- Throws:
java.lang.Exception
- If test failure.
-
testCancelConnection
public void testCancelConnection() throws java.lang.Exception
EnsureProcessState
instances for connection are cancelled on loss of connection.- Throws:
java.lang.Exception
- If test failure.
-
testSecureCancelConnection
public void testSecureCancelConnection() 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.
-
testRawPipelineVerify
public void testRawPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testBytesPipelineVerify
public void testBytesPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testBufferPipelineVerify
public void testBufferPipelineVerify() throws java.lang.Exception
Verify pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testFilePipelineVerify
public void testFilePipelineVerify() 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.
-
testRawPipelining
public void testRawPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testBytesPipelining
public void testBytesPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testBufferPipelining
public void testBufferPipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testFilePipelining
public void testFilePipelining() throws java.lang.Exception
Ensure can pipeline HTTP requests.- Throws:
java.lang.Exception
- If test failure.
-
testRawThreadedHandler
public void testRawThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
testBytesThreadedHandler
public void testBytesThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
testBufferThreadedHandler
public void testBufferThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
testFileThreadedHandler
public void testFileThreadedHandler() throws java.lang.Exception
Ensure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception
- If test failure.
-
testRawHeavyLoad
public void testRawHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testBytesHeavyLoad
public void testBytesHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testBufferHeavyLoad
public void testBufferHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testFileHeavyLoad
public void testFileHeavyLoad() throws java.lang.Exception
Ensure can service multiple requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testRawOverLoad
public void testRawOverLoad() throws java.lang.Exception
Ensure can service over requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testBytesOverLoad
public void testBytesOverLoad() throws java.lang.Exception
Ensure can service overload requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testBufferOverLoad
public void testBufferOverLoad() throws java.lang.Exception
Ensure can service overload requests pipelined.- Throws:
java.lang.Exception
- If test failure.
-
testFileOverLoad
public void testFileOverLoad() 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.
-
-