public class LocalModulesServiceTestConfig extends java.lang.Object implements LocalServiceTestConfig
LocalModulesService
in tests.
To understand the operation of LocalModulesServiceTestConfig
please note that a number
of ApiProxy.Environment
settings affect the
operation of ModulesService
. For the test environment
these settings are controlled using LocalServiceTestHelper
:
LocalServiceTestHelper.setEnvModuleId(java.lang.String)
specifies the result returned by
ModulesService.getCurrentModule()
. The default
module is "default".
LocalServiceTestHelper.setEnvVersionId(java.lang.String)
specifies the result returned by
ModulesService.getCurrentVersion()
. The default
version is "1".
LocalServiceTestHelper.setEnvInstance(java.lang.String)
specifies the result returned by
ModulesService.getCurrentInstanceId()
. For manual
scaling and basic scaling module versions you can explicitly specify a configured instance
or if you prefer you can leave the default("-1") value and the testing framework will set
the instance to 0. For automatic scaling module version you must leave the value as the
default("-1").
The environment values for LocalServiceTestHelper
must match a module, version (and
instance if needed) that you configure or one that is automatically generated for you.
Changes made to the environment values for LocalServiceTestHelper
after you call
setUp()
do not apply for ModulesService
during your test run.
For simple configurations LocalModulesServiceTestConfig
will generate a configuration
based on the current ApiProxy.Environment
. The generated
LocalModulesServiceTestConfig
contains the following elements:
LocalModulesServiceTestConfig
LocalModulesServiceTestConfig
to the LocalServiceTestHelper
constructor with other needed LocalServiceTestConfig
objects.
ApiProxy.Environment
to refer to a
desired module, version and instance (if needed).
setUp()
and execute your test.
{@code LocalServiceTestHelper helper;
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_MODULE_NAME |
Constructor and Description |
---|
LocalModulesServiceTestConfig() |
Modifier and Type | Method and Description |
---|---|
LocalModulesServiceTestConfig |
addAutomaticScalingModuleVersion(java.lang.String module,
java.lang.String version)
Adds a automatic scaling module version.
|
LocalModulesServiceTestConfig |
addBasicScalingModuleVersion(java.lang.String module,
java.lang.String version,
int numInstances)
Adds a basic scaling module version.
|
LocalModulesServiceTestConfig |
addDefaultModuleVersion()
Adds an automatic scaling module version that matches the default
ApiProxy.Environment constructed by
LocalServiceTestHelper with module = "default" and version = "1". |
LocalModulesServiceTestConfig |
addManualScalingModuleVersion(java.lang.String module,
java.lang.String version,
int numInstances)
Adds a manual scaling module version.
|
void |
clearModuleVersions()
Clears any module versions that have been added with
addAutomaticScalingModuleVersion(java.lang.String, java.lang.String) ,
addBasicScalingModuleVersion(java.lang.String, java.lang.String, int) , addManualScalingModuleVersion(java.lang.String, java.lang.String, int) and
addDefaultModuleVersion() . |
static com.google.appengine.api.modules.dev.LocalModulesService |
getLocalModulesService()
Returns the
LocalModulesService which is created on first use. |
void |
setUp()
Set up the local service.
|
void |
tearDown()
Tear down the local service.
|
public static final java.lang.String DEFAULT_MODULE_NAME
public void setUp()
LocalServiceTestConfig
setUp
in interface LocalServiceTestConfig
public void tearDown()
LocalServiceTestConfig
tearDown
in interface LocalServiceTestConfig
public LocalModulesServiceTestConfig addAutomaticScalingModuleVersion(java.lang.String module, java.lang.String version)
module
- the module nameversion
- the versionjava.lang.IllegalArgumentException
- if a module version with the same name and version
has already been added.public LocalModulesServiceTestConfig addManualScalingModuleVersion(java.lang.String module, java.lang.String version, int numInstances)
module
- the module nameversion
- the versionnumInstances
- the number of instances for the module version.java.lang.IllegalArgumentException
- if a module version with the same name and version
has already been added.java.lang.IllegalArgumentException
- if numInstances <= 0.public LocalModulesServiceTestConfig addBasicScalingModuleVersion(java.lang.String module, java.lang.String version, int numInstances)
module
- the module nameversion
- the versionnumInstances
- the number of instances for the module version.java.lang.IllegalArgumentException
- if a module version with the same name and version
has already been added.java.lang.IllegalArgumentException
- if numInstances <= 0.public LocalModulesServiceTestConfig addDefaultModuleVersion()
ApiProxy.Environment
constructed by
LocalServiceTestHelper
with module = "default" and version = "1".java.lang.IllegalArgumentException
- if a module version with the same name and version
has already been added.public void clearModuleVersions()
addAutomaticScalingModuleVersion(java.lang.String, java.lang.String)
,
addBasicScalingModuleVersion(java.lang.String, java.lang.String, int)
, addManualScalingModuleVersion(java.lang.String, java.lang.String, int)
and
addDefaultModuleVersion()
.public static com.google.appengine.api.modules.dev.LocalModulesService getLocalModulesService()
LocalModulesService
which is created on first use.