public abstract class AppBasedTestingBase<R extends RequestContext<?>,W extends WebsocketContext<?>> extends SpincastTestBase
logger, spincastConfig| Constructor and Description |
|---|
AppBasedTestingBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterClass() |
protected org.spincast.plugins.httpclient.builders.ConnectRequestBuilder |
CONNECT(String path)
Starts an Http Client builder for a CONNECT method.
|
protected org.spincast.plugins.httpclient.builders.ConnectRequestBuilder |
CONNECT(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a CONNECT method.
|
protected org.spincast.plugins.httpclient.builders.ConnectRequestBuilder |
CONNECT(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a CONNECT method.
|
protected com.google.inject.Injector |
createInjector()
The test class must implement this method to create
the Guice injector.
|
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 org.spincast.plugins.httpclient.builders.DeleteRequestBuilder |
DELETE(String path)
Starts an Http Client builder for a DELETE method.
|
protected org.spincast.plugins.httpclient.builders.DeleteRequestBuilder |
DELETE(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a DELETE method.
|
protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.GetRequestBuilder |
GET(String path)
Starts an Http Client builder for a GET method.
|
protected org.spincast.plugins.httpclient.builders.GetRequestBuilder |
GET(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a GET method.
|
protected org.spincast.plugins.httpclient.builders.GetRequestBuilder |
GET(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a GET method.
|
protected abstract AppTestingConfigs |
getAppTestingConfigs()
We force test classes to provide information about
the required testing configurations.
|
protected CookieFactory |
getCookieFactory() |
protected com.google.inject.Module |
getExtraOverridingModule()
If an overriding Module is to be added using the
Guice tweaker.
|
protected com.google.inject.Module |
getExtraOverridingModule2() |
protected List<SpincastPlugin> |
getExtraPlugins()
The extra required plugins.
|
protected List<SpincastPlugin> |
getExtraPlugins2()
The extra required plugins.
|
protected HttpClient |
getHttpClient() |
protected Router<R,W> |
getRouter() |
protected Server |
getServer() |
protected Class<? extends SpincastConfig> |
getTestingConfigImplementationClass()
The implementation to use for the
SpincastConfig binding,
when running tests. |
protected org.spincast.plugins.httpclient.builders.HeadRequestBuilder |
HEAD(String path)
Starts an Http Client builder for a HEAD method.
|
protected org.spincast.plugins.httpclient.builders.HeadRequestBuilder |
HEAD(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a HEAD method.
|
protected org.spincast.plugins.httpclient.builders.HeadRequestBuilder |
HEAD(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a HEAD method.
|
protected boolean |
isDisableBindCurrentClass() |
protected boolean |
isDisableSllCetificateErrors()
By default, for the tests, by disable the
SSL certificate errors.
|
protected org.spincast.plugins.httpclient.builders.OptionsRequestBuilder |
OPTIONS(String path)
Starts an Http Client builder for a OPTIONS method.
|
protected org.spincast.plugins.httpclient.builders.OptionsRequestBuilder |
OPTIONS(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a OPTIONS method.
|
protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.PatchRequestBuilder |
PATCH(String path)
Starts an Http Client builder for a PATCH method.
|
protected org.spincast.plugins.httpclient.builders.PatchRequestBuilder |
PATCH(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a PATCH method.
|
protected org.spincast.plugins.httpclient.builders.PatchRequestBuilder |
PATCH(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a PATCH method.
|
protected org.spincast.plugins.httpclient.builders.PostRequestBuilder |
POST(String path)
Starts an Http Client builder for a POST method.
|
protected org.spincast.plugins.httpclient.builders.PostRequestBuilder |
POST(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a POST method.
|
protected org.spincast.plugins.httpclient.builders.PostRequestBuilder |
POST(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a POST method.
|
protected org.spincast.plugins.httpclient.builders.PutRequestBuilder |
PUT(String path)
Starts an Http Client builder for a PUT method.
|
protected org.spincast.plugins.httpclient.builders.PutRequestBuilder |
PUT(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a PUT method.
|
protected org.spincast.plugins.httpclient.builders.PutRequestBuilder |
PUT(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a PUT method.
|
protected abstract void |
startApp()
Starts the application.
|
protected void |
stopServer() |
protected org.spincast.plugins.httpclient.builders.TraceRequestBuilder |
TRACE(String path)
Starts an Http Client builder for a TRACE method.
|
protected org.spincast.plugins.httpclient.builders.TraceRequestBuilder |
TRACE(String pathOrUrl,
boolean isFullUrl)
Starts an Http Client builder for a TRACE method.
|
protected org.spincast.plugins.httpclient.builders.TraceRequestBuilder |
TRACE(String pathOrUrl,
boolean isFullUrl,
boolean isHttps)
Starts an Http Client builder for a TRACE method.
|
protected void |
validateCreatedInjector(com.google.inject.Injector guice)
Validates the created Injector, before the
dependencies are injected in the test class.
|
protected WebsocketRequestBuilder |
websocket(String path) |
protected WebsocketRequestBuilder |
websocket(String pathOrUrl,
boolean isFullUrl) |
protected WebsocketRequestBuilder |
websocket(String pathOrUrl,
boolean isFullUrl,
boolean isHttps) |
addExtraSystemProperties, afterClassLoops, afterTest, beforeClass, beforeClassException, beforeTest, createGuiceTweaker, createTestingFilePath, createTestingFilePath, deleteTempDir, getExtraSystemProperties, getGuiceTweakerFromThreadLocal, getInjector, getSpincastConfig, getTestingWritableDir, resetSystemProperties, testFailureprotected final com.google.inject.Injector createInjector()
SpincastTestBasemain(...) method) or by
creating a custom Injector.createInjector in class SpincastTestBaseprotected final Class<? extends SpincastConfig> getTestingConfigImplementationClass()
SpincastTestBaseSpincastConfig binding,
when running tests.getTestingConfigImplementationClass in class SpincastTestBaseprotected final boolean isDisableBindCurrentClass()
isDisableBindCurrentClass in class SpincastTestBaseprotected final com.google.inject.Module getExtraOverridingModule()
SpincastTestBasegetExtraOverridingModule in class SpincastTestBaseprotected com.google.inject.Module getExtraOverridingModule2()
protected final List<SpincastPlugin> getExtraPlugins()
getExtraPlugins in class SpincastTestBaseprotected List<SpincastPlugin> getExtraPlugins2()
protected void validateCreatedInjector(com.google.inject.Injector guice)
SpincastTestBasevalidateCreatedInjector in class SpincastTestBasepublic void afterClass()
afterClass in interface BeforeAfterClassMethodsProviderafterClass in class SpincastTestBaseprotected void stopServer()
protected 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 org.spincast.plugins.httpclient.builders.GetRequestBuilder GET(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.PostRequestBuilder POST(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.PutRequestBuilder PUT(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.DeleteRequestBuilder DELETE(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.OptionsRequestBuilder OPTIONS(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.TraceRequestBuilder TRACE(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.ConnectRequestBuilder CONNECT(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.PatchRequestBuilder PATCH(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.HeadRequestBuilder HEAD(String path)
path - the relative path to be appended to the
base test URL.protected org.spincast.plugins.httpclient.builders.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 org.spincast.plugins.httpclient.builders.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:".protected Date parseDate(String dateHeaderValue)
protected abstract AppTestingConfigs getAppTestingConfigs()
The bindings for those components will be automatically created.
null
to disable this process (you will then have to add the
required config bindings by yourself).protected abstract void startApp()
In this method, you should call your
application main() method.
Returns a boolean to tell if the class calling the Spincast bootstrapper, commonly named "App", should be added to the Guice context or not.
Returning true is common if your
test class runs integration tests, since
it is probably the calling class that starts the
HTTP server. Return false if you
don't need any server to be started, but still
want the full application Guice context to be
created (used in general for unit tests).
Copyright © 2018. All rights reserved.