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
AbstractTestCasefor 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 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.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.protected booleanisHandleCancel()Indicates if handle cancel.protected static HttpHeadernewHttpHeader(java.lang.String name, java.lang.String value)Creates a newHttpHeader.protected voidsetUp()protected voidstartHttpServer(java.lang.Class<?> sectionServicer)Starts theHttpServer.protected voidstartHttpServer(java.lang.Class<?> sectionServicer, OfficeFloorExtensionService extension)Starts theHttpServer.protected voidstartHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension, java.util.function.Consumer<OfficeFloor> officeFloorListener)Starts theHttpServer.protected abstract MstartRawHttpServer(HttpServerLocation serverLocation)Starts a raw implementation of the underlying HTTP server.protected abstract voidstopRawHttpServer(M momento)Stops the raw implementation.protected voidtearDown()voidtestBufferHeavyLoad()Ensure can service multiple requests pipelined.voidtestBufferOverLoad()Ensure can service overload requests pipelined.voidtestBufferPipelineVerify()Verify pipeline HTTP requests.voidtestBufferPipelining()Ensure can pipeline HTTP requests.voidtestBufferThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidtestBytesHeavyLoad()Ensure can service multiple requests pipelined.voidtestBytesOverLoad()Ensure can service overload requests pipelined.voidtestBytesPipelineVerify()Verify pipeline HTTP requests.voidtestBytesPipelining()Ensure can pipeline HTTP requests.voidtestBytesThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidtestCancelConnection()EnsureProcessStateinstances for connection are cancelled on loss of connection.voidtestFileHeavyLoad()Ensure can service multiple requests pipelined.voidtestFileOverLoad()Ensure can service overload requests pipelined.voidtestFilePipelineVerify()Verify pipeline HTTP requests.voidtestFilePipelining()Ensure can pipeline HTTP requests.voidtestFileThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidtestFunctionality()Ensure able to send all details and receive all details.voidtestHandleError()Ensure can handleEscalation.voidtestMultipleIndividualRequests()Ensure can send multiple HTTP requests.voidtestMultipleIndividualSecureRequests()Ensure can send multiple HTTPS requests.voidtestNotDecodeRequestUrl()Ensure does not decode characters (allows for routing to work correctly and not find query string / fragment incorrectly).voidtestRawHeavyLoad()Ensure can service multiple requests pipelined.voidtestRawOverLoad()Ensure can service over requests pipelined.voidtestRawPipelineVerify()Verify pipeline HTTP requests.voidtestRawPipelining()Ensure can pipeline HTTP requests.voidtestRawSingleRequest()Ensure can handle raw single HTTP request.voidtestRawThreadedHandler()Ensure can handle HTTP requests with threaded handler.voidtestSecureCancelConnection()EnsureProcessStateinstances for connection are cancelled on loss of secure connection.voidtestSecureSingleThreadedHandlerRequest()Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicerfor a secure connection.voidtestSecureSocket()Ensure raw secure request.voidtestServerDateHeaders()Ensure send Server and DateHttpHeadervalues.voidtestSingleBufferRequest()Ensure can send a single HTTPByteBufferresponse.voidtestSingleCloseFileRequest()Ensure closes theFileChannelon write.voidtestSingleFileRequest()Ensure can send a single HTTPStreamBuffer.FileBufferresponse.voidtestSingleRequest()Ensure can send a single HTTP request.voidtestSingleSecureBufferRequest()Ensure can send a single HTTPSByteBufferresponse.voidtestSingleSecureCloseFileRequest()Ensure closes theFileChannelon write.voidtestSingleSecureFileRequest()Ensure can send a single HTTPSStreamBuffer.FileBufferresponse.voidtestSingleSecureRequest()Ensure can send a single HTTPS request.voidtestSingleThreadedHandlerRequest()Ensure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer.voidtestSocket()Ensure raw request.voidtestTeamPressureOverload()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
-
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 M 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:
- 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 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
protected void setUp() throws java.lang.Exception- Overrides:
setUpin classjunit.framework.TestCase- Throws:
java.lang.Exception
-
tearDown
protected void tearDown() throws java.lang.Exception- Overrides:
tearDownin classjunit.framework.TestCase- 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 void startHttpServer(OfficeFloorExtensionService officeFloorExtension, OfficeExtensionService officeExtension, java.util.function.Consumer<OfficeFloor> officeFloorListener) throws java.lang.Exception
Starts theHttpServer.- Parameters:
officeFloorExtension-OfficeFloorExtensionServiceto configure theOfficeFloor.officeExtension-OfficeExtensionServiceto configure theOfficeFloor.officeFloorListener-Consumerto receive theOfficeFloor.- Throws:
java.lang.Exception- If fails to start theHttpServer.
-
testFunctionality
public void testFunctionality() throws java.lang.ExceptionEnsure able to send all details and receive all details.- Throws:
java.lang.Exception- If test failure.
-
testRawSingleRequest
public void testRawSingleRequest() throws java.lang.ExceptionEnsure can handle raw single HTTP request.- Throws:
java.lang.Exception- If test failure.
-
testSingleRequest
public void testSingleRequest() throws java.lang.ExceptionEnsure can send a single HTTP request.- Throws:
java.lang.Exception- If test failure.
-
testSingleSecureRequest
public void testSingleSecureRequest() throws java.lang.ExceptionEnsure can send a single HTTPS request.- Throws:
java.lang.Exception- If test failure.
-
testSingleBufferRequest
public void testSingleBufferRequest() throws java.lang.ExceptionEnsure can send a single HTTPByteBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
testSingleSecureBufferRequest
public void testSingleSecureBufferRequest() throws java.lang.ExceptionEnsure can send a single HTTPSByteBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
testSingleFileRequest
public void testSingleFileRequest() throws java.lang.ExceptionEnsure can send a single HTTPStreamBuffer.FileBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
testSingleSecureFileRequest
public void testSingleSecureFileRequest() throws java.lang.ExceptionEnsure can send a single HTTPSStreamBuffer.FileBufferresponse.- Throws:
java.lang.Exception- If test failure.
-
testServerDateHeaders
public void testServerDateHeaders() 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.
-
testSingleCloseFileRequest
public void testSingleCloseFileRequest() throws java.lang.ExceptionEnsure closes theFileChannelon write.- Throws:
java.lang.Exception- If test failure.
-
testSingleSecureCloseFileRequest
public void testSingleSecureCloseFileRequest() throws java.lang.ExceptionEnsure closes theFileChannelon write.- Throws:
java.lang.Exception- If test failure.
-
testMultipleIndividualRequests
public void testMultipleIndividualRequests() throws java.lang.ExceptionEnsure can send multiple HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testMultipleIndividualSecureRequests
public void testMultipleIndividualSecureRequests() throws java.lang.ExceptionEnsure can send multiple HTTPS requests.- Throws:
java.lang.Exception- If test failure.
-
testNotDecodeRequestUrl
public void testNotDecodeRequestUrl() 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.
-
testSingleThreadedHandlerRequest
public void testSingleThreadedHandlerRequest() throws java.lang.ExceptionEnsure can handle request withAbstractHttpServerImplementationTest.ThreadedServicer.- Throws:
java.lang.Exception- If test failure.
-
testSecureSingleThreadedHandlerRequest
public void testSecureSingleThreadedHandlerRequest() throws java.lang.ExceptionEnsure can handle request withAbstractHttpServerImplementationTest.ThreadedServicerfor a secure connection.- Throws:
java.lang.Exception- If test failure.
-
testSocket
public void testSocket() throws java.lang.ExceptionEnsure raw request.- Throws:
java.lang.Exception- If test failure.
-
testSecureSocket
public void testSecureSocket() throws java.lang.ExceptionEnsure raw secure request.- Throws:
java.lang.Exception- If test failure.
-
testHandleError
public void testHandleError() throws java.lang.ExceptionEnsure can handleEscalation.- Throws:
java.lang.Exception- If test failure.
-
testTeamPressureOverload
public void testTeamPressureOverload() throws java.lang.ExceptionEnsure can handle pressure overloading the server.- Throws:
java.lang.Exception- If test failure.
-
testCancelConnection
public void testCancelConnection() throws java.lang.ExceptionEnsureProcessStateinstances for connection are cancelled on loss of connection.- Throws:
java.lang.Exception- If test failure.
-
testSecureCancelConnection
public void testSecureCancelConnection() 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.
-
testRawPipelineVerify
public void testRawPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testBytesPipelineVerify
public void testBytesPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testBufferPipelineVerify
public void testBufferPipelineVerify() throws java.lang.ExceptionVerify pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testFilePipelineVerify
public void testFilePipelineVerify() 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.
-
testRawPipelining
public void testRawPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testBytesPipelining
public void testBytesPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testBufferPipelining
public void testBufferPipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testFilePipelining
public void testFilePipelining() throws java.lang.ExceptionEnsure can pipeline HTTP requests.- Throws:
java.lang.Exception- If test failure.
-
testRawThreadedHandler
public void testRawThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
testBytesThreadedHandler
public void testBytesThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
testBufferThreadedHandler
public void testBufferThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
testFileThreadedHandler
public void testFileThreadedHandler() throws java.lang.ExceptionEnsure can handle HTTP requests with threaded handler.- Throws:
java.lang.Exception- If test failure.
-
testRawHeavyLoad
public void testRawHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testBytesHeavyLoad
public void testBytesHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testBufferHeavyLoad
public void testBufferHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testFileHeavyLoad
public void testFileHeavyLoad() throws java.lang.ExceptionEnsure can service multiple requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testRawOverLoad
public void testRawOverLoad() throws java.lang.ExceptionEnsure can service over requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testBytesOverLoad
public void testBytesOverLoad() throws java.lang.ExceptionEnsure can service overload requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testBufferOverLoad
public void testBufferOverLoad() throws java.lang.ExceptionEnsure can service overload requests pipelined.- Throws:
java.lang.Exception- If test failure.
-
testFileOverLoad
public void testFileOverLoad() 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.
-
-