al helper.setEnvVersionId("v2"); // Optional helper.setEnvInstance("2"); // Optional helper.setUp(); } } A tester may specify the module versions in the test configuration explicitly by following these steps.
- Construct a {@link LocalModulesServiceTestConfig}
- Add needed module versions with {@link #addDefaultModuleVersion}, {@link #addAutomaticScalingModuleVersion}, {@link #addManualScalingModuleVersion} and{@link #addBasicScalingModuleVersion}. When multiple versions are added for the same module, the first will be the default.
- Pass the {@link LocalModulesServiceTestConfig} to the {@link LocalServiceTestHelper} constructor with other needed {@link LocalServiceTestConfig}objects.
- Update the test {@link com.google.apphosting.api.ApiProxy.Environment} to refer to aconfigured module instance as needed.
- Start the testing environment with {@link #setUp}. Changes made to the configuration after calling {@link #setUp} are not available during your test.
Here is a sample usage:
{@code LocalServiceTestHelper helper;}
@Before public void createService() { helper = new LocalServiceTestHelper(new LocalModulesServiceTestConfig() .addDefaultModuleVersion() .addAutomaticScalingModuleVersion("a1", "v1") // default version for module "a1" .addManualScalingModuleVersion("m1", "v1", 2) // default version for module "m1" .addManualScalingModuleVersion("m1", "v2", 3)); helper.setEnvModuleId("m1"); helper.setEnvVersionId("v2"); helper.setEnvInstance("0"); // Optional helper.setUp(); } }