public abstract class IntegrationTestAppBase<R extends RequestContext<?>,W extends WebsocketContext<?>> extends IntegrationTestBase<R,W>
main()
method).
For tests using this as a base, a GuiceTweaker mecanism is
available. This allows you to tweak the bindings of the application
you are about to test. Doing so, you can start your application using
its real main() method. Note that the GuuiceTweaker only
works with applications started using the standard Bootstrapper
(Spincast.configure(...)).
This class needs to be parametrized with the Request context type
and WebSocket Context type to use.
logger| Constructor and Description |
|---|
IntegrationTestAppBase() |
| Modifier and Type | Method and Description |
|---|---|
protected com.google.inject.Injector |
createInjector()
At this level,
createInjector() expects
your application to use the Spincast utility class
from the spincast-default artifact to initialize
your app. |
protected abstract AppTestingConfigInfo |
getAppTestingConfigInfo()
We force test classes to provide information about
the required testing configurations.
|
protected Class<? extends SpincastConfig> |
getGuiceTweakerConfigImplementationClass()
Final : the implementation class will be taken from the
getAppTestingConfigInfo() return. |
protected com.google.inject.Module |
getGuiceTweakerOverridingModule()
If an overriding Module is to be added using the
Guice tweaker.
|
protected abstract void |
initApp()
Starts the application.
|
protected boolean |
isGuiceTweakerAutoTestingConfigBindings()
When a Spincast application is tested, the default testing
configurations are always enabled, and
getAppTestingConfigInfo()
must be used to configure them. |
afterClass, CONNECT, CONNECT, CONNECT, createTestUrl, createTestUrl, createTestUrl, DELETE, DELETE, DELETE, formatDate, GET, GET, GET, getCookieFactory, getGuiceTweakerPlugins, getHttpClient, getRouter, getServer, HEAD, HEAD, HEAD, isDisableSllCetificateErrors, OPTIONS, OPTIONS, OPTIONS, parseDate, PATCH, PATCH, PATCH, POST, POST, POST, PUT, PUT, PUT, stopServer, TRACE, TRACE, TRACE, validateCreatedInjector, websocket, websocket, websocketaddExtraSystemProperties, afterClassLoops, afterTest, beforeClass, beforeClassException, beforeTest, createGuiceTweaker, createTestingFilePath, createTestingFilePath, deleteTempDir, getExtraSystemProperties, getGuiceTweakerFromThreadLocal, getInjector, getSpincastConfig, getTestingWritableDir, resetSystemProperties, setSpincastConfig, testFailureprotected final boolean isGuiceTweakerAutoTestingConfigBindings()
getAppTestingConfigInfo()
must be used to configure them.isGuiceTweakerAutoTestingConfigBindings in class SpincastTestBaseprotected final Class<? extends SpincastConfig> getGuiceTweakerConfigImplementationClass()
getAppTestingConfigInfo() return.getGuiceTweakerConfigImplementationClass in class SpincastTestBaseprotected com.google.inject.Module getGuiceTweakerOverridingModule()
SpincastTestBaseIn general, you want to keep the Module from the parent by combining/overriding it with your custom Module. For example :
return Modules.combine(super.getGuiceTweakerOverridingModule(),
new SpincastGuiceModuleBase() {
getGuiceTweakerOverridingModule in class SpincastTestBaseprotected abstract AppTestingConfigInfo getAppTestingConfigInfo()
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 com.google.inject.Injector createInjector()
createInjector() expects
your application to use the Spincast utility class
from the spincast-default artifact to initialize
your app. It is going to use a
GuiceTweaker ThreadLocal variable to
tweak how the Guice context is created and to retrieve
the resulting Guice injector.
If your application doesn't use the Spincast utility class
from the spincast-default artifact to initialize
your app, you should probably override this method and it's up to you to
return the proper Guice Injector to use.
createInjector in class SpincastTestBaseprotected abstract void initApp()
Copyright © 2017. All rights reserved.