Class LocalModulesServiceTestConfig

  • java.lang.Object
    • com.google.appengine.tools.development.testing.LocalModulesServiceTestConfig
  • All Implemented Interfaces:

    public class LocalModulesServiceTestConfig
    extends java.lang.Object
    implements LocalServiceTestConfig
    Config for accessing the 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:

    1. LocalServiceTestHelper.setEnvModuleId(java.lang.String) specifies the result returned by ModulesService.getCurrentModule(). The default module is "default".
    2. LocalServiceTestHelper.setEnvVersionId(java.lang.String) specifies the result returned by ModulesService.getCurrentVersion(). The default version is "1".
    3. 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:

    1. If the envModuleId element is not "default" then an automatic scaling module version will be added with module = "default" and version = "1". This simulates the appengine rule that an application must have a version of the default module.
    2. If the envInstance has not been set or is set to its default "-1" value then an automatic scaling module version will be added with module = envModuleId and version = envVerionId. Note here and below that in the event envVersionId contains a . suffix (eg "v1.9") the minor suffix is not included in the added module version.
    3. If the envInstance has been set or is set to a non default ("-1") value then a manual scaling module version will be added with module = envModuleId and version = envVerionId and instance = envInstance.
    To configure a test to use ModulesService with a generated configuration perform these steps in the order given.
    1. Construct a LocalModulesServiceTestConfig
    2. Pass the LocalModulesServiceTestConfig to the LocalServiceTestHelper constructor with other needed LocalServiceTestConfig objects.
    3. Update the test ApiProxy.Environment to refer to a desired module, version and instance (if needed).
    4. Start the testing environment with setUp() and execute your test.
    Here is a sample usage:
       LocalServiceTestHelper helper;
    • Field Detail


        public static final java.lang.String DEFAULT_MODULE_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • LocalModulesServiceTestConfig

        public LocalModulesServiceTestConfig()
    • Method Detail

      • addAutomaticScalingModuleVersion

        public LocalModulesServiceTestConfig addAutomaticScalingModuleVersion(java.lang.String module,
                                                                              java.lang.String version)
        Adds a automatic scaling module version.
        module - the module name
        version - the version
        this for chaining
        java.lang.IllegalArgumentException - if a module version with the same name and version has already been added.
      • addManualScalingModuleVersion

        public LocalModulesServiceTestConfig addManualScalingModuleVersion(java.lang.String module,
                                                                           java.lang.String version,
                                                                           int numInstances)
        Adds a manual scaling module version.
        module - the mo