public abstract class IntegrationTestBase<R extends RequestContext<?>,W extends WebsocketContext<?>> extends SpincastTestBase
This requires a "Server" to be bound in the Guice context : it will automatically be stopped after the test class is ran.
Note that this class doesn't start the server by itself because this lets the opportunity to test an application by using its true bootstraping process, which usually starts a server itself!
All client data (such as cookies) are cleared before each test.
| Constructor and Description |
|---|
IntegrationTestBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterClass()
Called after the tests of the class are ran.
|
protected ConnectRequestBuilder |
CONNECT(String path)
Starts an Http Client builder for a CONNECT method.
|
protected ConnectRequestBuilder |
CONNECT(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a CONNECT method.
|
protected ConnectRequestBuilder |
CONNECT(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a CONNECT method.
|
protected String |
createTestUrl(String path)
Creates an URL to the started HTTP server.
|
protected String |
createTestUrl(String path,
boolean https)
Creates an URL to the started HTTP server.
|
protected String |
createTestUrl(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Creates an URL to the started HTTP server.
|
protected DeleteRequestBuilder |
DELETE(String path)
Starts an Http Client builder for a DELETE method.
|
protected DeleteRequestBuilder |
DELETE(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a DELETE method.
|
protected DeleteRequestBuilder |
DELETE(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a DELETE method.
|
protected String |
formatDate(Date date)
Format a date so it can be used in a HTTP header.
|
protected GetRequestBuilder |
GET(String path)
Starts an Http Client builder for a GET method.
|
protected GetRequestBuilder |
GET(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a GET method.
|
protected GetRequestBuilder |
GET(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a GET method.
|
protected CookieFactory |
getCookieFactory() |
protected List<SpincastPlugin> |
getGuiceTweakerExtraPlugins()
The extra plugins added by the Guice Tweaker.
|
protected HttpClient |
getHttpClient() |
protected Router<R,W> |
getRouter() |
protected Server |
getServer() |
protected HeadRequestBuilder |
HEAD(String path)
Starts an Http Client builder for a HEAD method.
|
protected HeadRequestBuilder |
HEAD(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a HEAD method.
|
protected HeadRequestBuilder |
HEAD(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a HEAD method.
|
protected boolean |
isDisableSllCetificateErrors()
By default, for the tests, by disable the
SSL certificate errors.
|
protected OptionsRequestBuilder |
OPTIONS(String path)
Starts an Http Client builder for a OPTIONS method.
|
protected OptionsRequestBuilder |
OPTIONS(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a OPTIONS method.
|
protected OptionsRequestBuilder |
OPTIONS(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a OPTIONS method.
|
protected Date |
parseDate(String dateHeaderValue)
Parse a date from a HTTP header to a Date object.
|
protected PatchRequestBuilder |
PATCH(String path)
Starts an Http Client builder for a PATCH method.
|
protected PatchRequestBuilder |
PATCH(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a PATCH method.
|
protected PatchRequestBuilder |
PATCH(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a PATCH method.
|
protected PostRequestBuilder |
POST(String path)
Starts an Http Client builder for a POST method.
|
protected PostRequestBuilder |
POST(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a POST method.
|
protected PostRequestBuilder |
POST(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a POST method.
|
protected PutRequestBuilder |
PUT(String path)
Starts an Http Client builder for a PUT method.
|
protected PutRequestBuilder |
PUT(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a PUT method.
|
protected PutRequestBuilder |
PUT(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a PUT method.
|
protected void |
stopServer() |
protected TraceRequestBuilder |
TRACE(String path)
Starts an Http Client builder for a TRACE method.
|
protected TraceRequestBuilder |
TRACE(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a TRACE method.
|
protected TraceRequestBuilder |
TRACE(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a TRACE method.
|
protected WebsocketRequestBuilder |
websocket(String path) |
protected WebsocketRequestBuilder |
websocket(String pathOrUrl,
boolean isFullUrl) |
protected WebsocketRequestBuilder |
websocket(String pathOrUrl,
boolean isFullUrl,
boolean isHttps) |
afterClassLoops, afterTest, beforeClass, beforeTest, createGuiceTweaker, createInjector, createTestingFilePath, createTestingFilePath, deleteTempDir, getInjector, getSpincastConfig, getSpincastConfigTestingImplementation, getSpincastPluginFromThreadLocal, getTestingWritableDir, isEnableGuiceTweaker, isEnableGuiceTweakerExtraPlugins, isEnableGuiceTweakerTestingConfigMecanism, setSpincastConfig, setupSpincastConfigTesting, testFailurepublic void afterClass()
BeforeAfterClassMethodsProviderThis will only be called if the beforeClass() method completed successfully, so you can be sure that the instanciation of the class is complete here.
afterClass in interface BeforeAfterClassMethodsProviderafterClass in class SpincastTestBaseprotected void stopServer()
protected List<SpincastPlugin> getGuiceTweakerExtraPlugins()
getGuiceTweakerExtraPlugins in class SpincastTestBaseprotected HttpClient getHttpClient()
protected CookieFactory getCookieFactory()
protected Server getServer()
protected String createTestUrl(String path)
path - the relative path to be appended to the
base test URL.protected String createTestUrl(String path, boolean https)
path - the relative path to be appended to the
base test URL.https - if true, "https:" will be used
instead of "http:".protected String createTestUrl(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path OR a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected WebsocketRequestBuilder websocket(String path)
protected WebsocketRequestBuilder websocket(String pathOrUrl, boolean isFullUrl)
protected WebsocketRequestBuilder websocket(String pathOrUrl, boolean isFullUrl, boolean isHttps)
protected GetRequestBuilder GET(String path)
path - the relative path to be appended to the
base test URL.protected GetRequestBuilder GET(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected GetRequestBuilder GET(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected boolean isDisableSllCetificateErrors()
protected PostRequestBuilder POST(String path)
path - the relative path to be appended to the
base test URL.protected PostRequestBuilder POST(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected PostRequestBuilder POST(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected PutRequestBuilder PUT(String path)
path - the relative path to be appended to the
base test URL.protected PutRequestBuilder PUT(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected PutRequestBuilder PUT(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected DeleteRequestBuilder DELETE(String path)
path - the relative path to be appended to the
base test URL.protected DeleteRequestBuilder DELETE(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected DeleteRequestBuilder DELETE(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected OptionsRequestBuilder OPTIONS(String path)
path - the relative path to be appended to the
base test URL.protected OptionsRequestBuilder OPTIONS(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected OptionsRequestBuilder OPTIONS(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected TraceRequestBuilder TRACE(String path)
path - the relative path to be appended to the
base test URL.protected TraceRequestBuilder TRACE(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected TraceRequestBuilder TRACE(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected ConnectRequestBuilder CONNECT(String path)
path - the relative path to be appended to the
base test URL.protected ConnectRequestBuilder CONNECT(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected ConnectRequestBuilder CONNECT(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected PatchRequestBuilder PATCH(String path)
path - the relative path to be appended to the
base test URL.protected PatchRequestBuilder PATCH(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected PatchRequestBuilder PATCH(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".protected HeadRequestBuilder HEAD(String path)
path - the relative path to be appended to the
base test URL.protected HeadRequestBuilder HEAD(String pathOrUrl, boolean isFullUrl)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.protected HeadRequestBuilder HEAD(String pathOrUrl, boolean isFullUrl, boolean isHttps)
pathOrUrl - a relative path or a full URL.isFullUrl - if the 'pathOrUrl' parameter a full URL? If
so, it will be used as is. Otherwise it will be appended to the
base test URL.isHttps - if true, "https:" will be used
instead of "http:".Copyright © 2017. All rights reserved.