|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
net.officefloor.frame.test.OfficeFrameTestCase
net.officefloor.frame.test.AbstractOfficeConstructTestCase
net.officefloor.plugin.socket.server.http.server.MockHttpServer
public abstract class MockHttpServer
Provides functionality to run a HTTP server for testing.
This should NEVER be used for Production as its focus is only to simplify writing tests for HTTP server functionality.
| Nested Class Summary | |
|---|---|
static class |
MockHttpServer.TestSslEngineConfigurator
SslEngineConfigurator to setup MockHttpServer to work
with TestProtocolSocketFactory. |
| Nested classes/interfaces inherited from class net.officefloor.frame.test.OfficeFrameTestCase |
|---|
OfficeFrameTestCase.FailOperation, OfficeFrameTestCase.StressTest |
| Constructor Summary | |
|---|---|
MockHttpServer()
|
|
| Method Summary | |
|---|---|
HttpServicerTask |
buildServicer(String managedObjectName,
MockHttpServer server)
Builds the ServerHttpConnection servicer Task. |
org.apache.http.client.HttpClient |
createHttpClient()
Creates a HttpClient to connect to this MockHttpServer. |
static int |
getAvailablePort()
Obtains the next port number for testing. |
static String |
getEntityBody(org.apache.http.HttpResponse response)
Obtains the HttpEntity content. |
static String |
getEntityBody(org.apache.http.HttpResponse response,
Charset charset)
Obtains the HttpEntity content. |
InetSocketAddress |
getLocalAddress()
Obtains the local InetSocketAddress for this server. |
String |
getServerUrl()
Obtains the URL of the server. |
boolean |
isServerSecure()
Flags if MockHttpServer is running with secure connections. |
protected void |
setUp()
|
void |
setupSecure()
Flags to setup the MockHttpServer with secure connections. |
void |
shutdown()
Shuts down this MockHttpServer. |
void |
startup(HttpServicerBuilder servicerBuilder)
Starts up this MockHttpServer. |
protected void |
tearDown()
|
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runTest, setName, toString |
| Methods inherited from class junit.framework.Assert |
|---|
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, fail, fail, failNotEquals, failNotSame, failSame |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MockHttpServer()
| Method Detail |
|---|
public static int getAvailablePort()
public static String getEntityBody(org.apache.http.HttpResponse response)
throws IOException
HttpEntity content.
response - HttpResponse.
HttpEntity.
IOException - If fails to obtain content.
public static String getEntityBody(org.apache.http.HttpResponse response,
Charset charset)
throws IOException
HttpEntity content.
response - HttpResponse.charset - Charset.
HttpEntity.
IOException - If fails to obtain content.public void setupSecure()
MockHttpServer with secure connections.
public void startup(HttpServicerBuilder servicerBuilder)
throws Exception
MockHttpServer.
Exceptionpublic boolean isServerSecure()
MockHttpServer is running with secure connections.
true if secure connections.public String getServerUrl()
public org.apache.http.client.HttpClient createHttpClient()
HttpClient to connect to this MockHttpServer.
HttpClient to connect to this MockHttpServer.public InetSocketAddress getLocalAddress()
InetSocketAddress for this server.
InetSocketAddress for this server.
public void shutdown()
throws Exception
MockHttpServer.
Exception
protected void setUp()
throws Exception
setUp in class AbstractOfficeConstructTestCaseException
protected void tearDown()
throws Exception
tearDown in class AbstractOfficeConstructTestCaseException
public HttpServicerTask buildServicer(String managedObjectName,
MockHttpServer server)
throws Exception
HttpServicerBuilderServerHttpConnection servicer Task.
buildServicer in interface HttpServicerBuildermanagedObjectName - Name that the ManagedObject for the
ServerHttpConnection is registered under.server - MockHttpServer to construct the servicer Task
instances.
HttpServicerTask to link the ManagedObjectSource
to service the ServerHttpConnection.
Exception - If fails to build the servicer Task.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||