Class AcrossTestWebContextBuilder
AcrossTestWebContext
.
This builder allows easy configuration of properties and modules to add to an AcrossTestWebContext
.
Configures a parent WebApplicationContext
and adds a MockAcrossServletContext
.
Note that AcrossWebModule
is not automatically added to the
created context.
Once build()
has been called, the AcrossTestWebContext
will be created and the internal
AcrossContext
bootstrapped.
- Since:
- 1.1.2
- Author:
- Arne Vandamme
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionalModulePackageClasses
(Class<?>... classes) Type-safe alternative forAcrossTestContextBuilder.additionalModulePackages(String...)
where the packages of the classes will be added for module scanning.additionalModulePackages
(String... packageNames) Additional packages that should be scanned for modules if no customModuleDependencyResolver
is configured.build()
Creates the internalAcrossContext
and bootstraps it.configurer
(AcrossContextConfigurer... configurer) Add one or moreAcrossContextConfigurer
instances that are to be called after the initialAcrossContext
has been created.protected AcrossConfigurableApplicationContext
protected AcrossTestWebContext
createTestContext
(AcrossConfigurableApplicationContext applicationContext, AcrossContext context) dataSource
(DataSource dataSource) Set the core across datasource.developmentMode
(boolean developmentMode) dropFirst
(boolean dropFirst) Should the database be reset before bootstrapping theAcrossContext
.dynamicServletContext
(boolean dynamicServletContext) Should the configuredMockAcrossServletContext
allow for dynamic registration of servlets and filters.Add one or more types (classes, interfaces, annotations) that should be exposed in this test context.installerDataSource
(DataSource installerDataSource) Set the installer datasource.moduleConfigurationPackageClasses
(Class<?>... classes) Type-safe alternative forAcrossTestContextBuilder.moduleConfigurationPackages(String...)
.moduleConfigurationPackages
(String... packageNames) Add one or more custom packages that should be scanned forModuleConfiguration
classes.moduleDependencyResolver
(ModuleDependencyResolver moduleDependencyResolver) Set theModuleDependencyResolver
that should be used for looking up modules by name.modules
(AcrossModule... modules) Array ofAcrossModule
instances to add to the context.Array ofAcrossModule
names that should be configured.properties
(Map<String, Object> properties) Add a properties map to the environment of the parentApplicationContext
.properties
(Properties properties) Add a properties collection to the environment of the parentApplicationContext
.properties
(org.springframework.core.env.PropertySource propertySource) Add aPropertySource
to the environment of the parentApplicationContext
.Set a property value on the environment of the parentApplicationContext
.Add one or more annotated classes to the parentApplicationContext
that is attached to theAcrossContext
.useTestDataSource
(boolean useTestDataSource) Should default test datasources be created.Methods inherited from class com.foreach.across.test.support.AcrossTestContextBuilder
annotatedClasses, configureApplicationContext
-
Constructor Details
-
AcrossTestWebContextBuilder
public AcrossTestWebContextBuilder()
-
-
Method Details
-
dynamicServletContext
Should the configuredMockAcrossServletContext
allow for dynamic registration of servlets and filters. Default istrue
.- Parameters:
dynamicServletContext
- true if dynamic registration should be allowed- Returns:
- self
-
configurer
Description copied from class:AcrossTestContextBuilder
Add one or moreAcrossContextConfigurer
instances that are to be called after the initialAcrossContext
has been created. Subsequent calls will add additional configurers.- Overrides:
configurer
in classAcrossTestContextBuilder
- Parameters:
configurer
- one or more instances- Returns:
- self
-
property
Description copied from class:AcrossTestContextBuilder
Set a property value on the environment of the parentApplicationContext
.- Overrides:
property
in classAcrossTestContextBuilder
- Parameters:
key
- property keyvalue
- property value- Returns:
- self
-
properties
Description copied from class:AcrossTestContextBuilder
Add a properties collection to the environment of the parentApplicationContext
.- Overrides:
properties
in classAcrossTestContextBuilder
- Parameters:
properties
- instance- Returns:
- self
-
properties
Description copied from class:AcrossTestContextBuilder
Add a properties map to the environment of the parentApplicationContext
.- Overrides:
properties
in classAcrossTestContextBuilder
- Parameters:
properties
- map- Returns:
- self
-
properties
public AcrossTestWebContextBuilder properties(org.springframework.core.env.PropertySource propertySource) Description copied from class:AcrossTestContextBuilder
Add aPropertySource
to the environment of the parentApplicationContext
.- Overrides:
properties
in classAcrossTestContextBuilder
- Parameters:
propertySource
- instance- Returns:
- self
-
dropFirst
Description copied from class:AcrossTestContextBuilder
Should the database be reset before bootstrapping theAcrossContext
. Whentrue
, this adds theResetDatabaseConfigurer
to the parentApplicationContext
. This is the default case.- Overrides:
dropFirst
in classAcrossTestContextBuilder
- Parameters:
dropFirst
- true if datasource tables should be dropped before starting the context- Returns:
- self
- See Also:
-
useTestDataSource
Description copied from class:AcrossTestContextBuilder
Should default test datasources be created. This will use the datasource specified by the property acrossTest.datasource or create a memory HSQLDB if none is specified.Using test datasource is the default. This is the equivalent to adding
TestDataSourceConfigurer
the the parentApplicationContext
.- Overrides:
useTestDataSource
in classAcrossTestContextBuilder
- Parameters:
useTestDataSource
- true if test datasource should be created automatically- Returns:
- self
- See Also:
-
expose
Description copied from class:AcrossTestContextBuilder
Add one or more types (classes, interfaces, annotations) that should be exposed in this test context.- Overrides:
expose
in classAcrossTestContextBuilder
- Parameters:
classesToExpose
- list- Returns:
- self
-
register
Description copied from class:AcrossTestContextBuilder
Add one or more annotated classes to the parentApplicationContext
that is attached to theAcrossContext
.- Overrides:
register
in classAcrossTestContextBuilder
- Parameters:
annotatedClasses
- list- Returns:
- self
-
dataSource
Description copied from class:AcrossTestContextBuilder
Set the core across datasource. If no separateAcrossTestContextBuilder.installerDataSource(DataSource)
is configured, this datasource will also be used for installers. If neither datasource is configured, installers will be disabled.- Overrides:
dataSource
in classAcrossTestContextBuilder
- Parameters:
dataSource
- instance- Returns:
- self
-
installerDataSource
Description copied from class:AcrossTestContextBuilder
Set the installer datasource.- Overrides:
installerDataSource
in classAcrossTestContextBuilder
- Parameters:
installerDataSource
- instance- Returns:
- self
-
modules
Description copied from class:AcrossTestContextBuilder
Array ofAcrossModule
names that should be configured. These will be resolved using the configuredAcrossTestContextBuilder.moduleDependencyResolver(ModuleDependencyResolver)
, before any configured module instances and before theAcrossContextConfigurer
instances are called. If noModuleDependencyResolver
was set explicitly, the default will be used.Subsequent calls will add modules.
- Overrides:
modules
in classAcrossTestContextBuilder
- Parameters:
moduleNames
- names- Returns:
- self
-
modules
Description copied from class:AcrossTestContextBuilder
Array ofAcrossModule
instances to add to the context. These will be added after the modules added usingAcrossTestContextBuilder.modules(String...)
have been resolved. Subsequent calls will add modules.- Overrides:
modules
in classAcrossTestContextBuilder
- Parameters:
modules
- collection- Returns:
- self
-
moduleDependencyResolver
public AcrossTestWebContextBuilder moduleDependencyResolver(ModuleDependencyResolver moduleDependencyResolver) Description copied from class:AcrossTestContextBuilder
Set theModuleDependencyResolver
that should be used for looking up modules by name. If none is set, a defaultClassPathScanningModuleDependencyResolver
will be used.- Overrides:
moduleDependencyResolver
in classAcrossTestContextBuilder
- Parameters:
moduleDependencyResolver
- instance- Returns:
- self
- See Also:
-
additionalModulePackages
Description copied from class:AcrossTestContextBuilder
Additional packages that should be scanned for modules if no customModuleDependencyResolver
is configured. In case of a custom resolver, this setting will be ignored.The default
AcrossContextBuilder.STANDARD_MODULES_PACKAGE
will always be added as the first one. If you do not want this, you should set a customModuleDependencyResolver
usingAcrossTestContextBuilder.moduleDependencyResolver(ModuleDependencyResolver)
.Subsequent calls will add additional packages.
- Overrides:
additionalModulePackages
in classAcrossTestContextBuilder
- Parameters:
packageNames
- list- Returns:
- self
- See Also:
-
additionalModulePackageClasses
Description copied from class:AcrossTestContextBuilder
Type-safe alternative forAcrossTestContextBuilder.additionalModulePackages(String...)
where the packages of the classes will be added for module scanning. In case of a custom resolver, this setting will be ignored.The default
AcrossContextBuilder.STANDARD_MODULES_PACKAGE
will always be added as the first one. If you do not want this, you should set a customModuleDependencyResolver
usingAcrossTestContextBuilder.moduleDependencyResolver(ModuleDependencyResolver)
.Subsequent calls will add additional packages.
- Overrides:
additionalModulePackageClasses
in classAcrossTestContextBuilder
- Parameters:
classes
- list- Returns:
- self
-
moduleConfigurationPackages
Description copied from class:AcrossTestContextBuilder
Add one or more custom packages that should be scanned forModuleConfiguration
classes. Subsequent calls will add additional packages.- Overrides:
moduleConfigurationPackages
in classAcrossTestContextBuilder
- Parameters:
packageNames
- list- Returns:
- self
-
moduleConfigurationPackageClasses
Description copied from class:AcrossTestContextBuilder
Type-safe alternative forAcrossTestContextBuilder.moduleConfigurationPackages(String...)
.- Overrides:
moduleConfigurationPackageClasses
in classAcrossTestContextBuilder
- Parameters:
classes
- list- Returns:
- self
-
developmentMode
- Overrides:
developmentMode
in classAcrossTestContextBuilder
- Parameters:
developmentMode
- true if development mode should be active on the created context- Returns:
- self
-
createDefaultApplicationContext
- Overrides:
createDefaultApplicationContext
in classAcrossTestContextBuilder
-
build
Description copied from class:AcrossTestContextBuilder
Creates the internalAcrossContext
and bootstraps it. Then wraps it in aAcrossTestContext
instance that gives easy access to querying functionality.- Overrides:
build
in classAcrossTestContextBuilder
- Returns:
- queryable context containing the bootstrapped
AcrossContext
-
createTestContext
protected AcrossTestWebContext createTestContext(AcrossConfigurableApplicationContext applicationContext, AcrossContext context) - Overrides:
createTestContext
in classAcrossTestContextBuilder
-