Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.tools.development.testing
Class LocalServiceTestHelper

    java.lang.Object
      com.google.appengine.tools.development.testing.LocalServiceTestHelper

    public class LocalServiceTestHelper

extends java.lang.Object

Helper class for testing against local app engine services. Construct the helper with one `LocalServiceTestConfig` instance for each service that you wish to access as part of your test. Then call `setUp()` before each test executes and `tearDown()` after each test executes. No specific test-harness is assumed, but here's a JUnit 3 example that uses task queues and the datastore.

>      public void MyTest extends TestCase {

>        private final LocalServiceTestHelper helper = new LocalServiceTestHelper(
>          new LocalTaskQueueTestConfig(), new LocalDatastoreServiceTestConfig());

>        @Override
>        public void setUp() {
>          super.setUp();
>          helper.setUp();
>        }

>        @Override
>        public void tearDown() {
>          helper.tearDown();
>          super.tearDown();
>        }
>      }

Constructor Summary
`LocalServiceTestHelper(LocalServiceTestConfig... configs)` Constructs a LocalServiceTestHelper with the provided configurations.

Method Summary
`static ApiProxyLocal` | `getApiProxyLocal()` Convenience function for getting ahold of the currently registered `ApiProxyLocal`.
`static LocalRpcService` | `getLocalService(java.lang.String serviceName)` Convenience function for getting ahold of a specific local service.
`protected com.google.apphosting.api.ApiProxy.Environment` | `newEnvironment()` Constructs the `ApiProxy.Environment` that will be installed.
`protected LocalServerEnvironment` | `newLocalServerEnvironment()` Constructs the `LocalServerEnvironment` that will be installed.
`LocalServiceTestHelper` | `setClock(Clock clock)` Sets the clock with which all local services will be initialized.
`LocalServiceTestHelper` | `setEnforceApiDeadlines(boolean val)` Determines whether or not API calls should be subject to the same deadlines as in production.
`LocalServiceTestHelper` | `setEnvAppId(java.lang.String envAppId)` The value to be returned by `ApiProxy.getCurrentEnvironment().getAppId()`
`LocalServiceTestHelper` | `setEnvAttributes(java.util.Map<java.lang.String,java.lang.Object> envAttributes)` The value to be returned by `ApiProxy.getCurrentEnvironment().getAttributes()`
`LocalServiceTestHelper` | `setEnvAuthDomain(java.lang.String envAuthDomain)` The value to be returned by `ApiProxy.getCurrentEnvironment().getAuthDomain()`
`LocalServiceTestHelper` | `setEnvEmail(java.lang.String envEmail)` The value to be returned by `ApiProxy.getCurrentEnvironment().getEmail()`
`LocalServiceTestHelper` | `setEnvIsAdmin(boolean envIsAdmin)` The value to be returned by `ApiProxy.getCurrentEnvironment().isAdmin()`
`LocalServiceTestHelper` | `setEnvIsLoggedIn(boolean envIsLoggedIn)` The value to be returned by `ApiProxy.getCurrentEnvironment().isLoggedIn()`
`LocalServiceTestHelper` | `setEnvRequestNamespace(java.lang.String envRequestNamespace)` The value to be returned by `ApiProxy.getCurrentEnvironment().getRequestNamespace()`
`LocalServiceTestHelper` | `setEnvVersionId(java.lang.String envVersionId)` The value to be returned by `ApiProxy.getCurrentEnvironment().getVersionId()`
`LocalServiceTestHelper` | `setSimulateProdLatencies(boolean val)` Determines whether or not local services should simulate production latencies.
`LocalServiceTestHelper` | `setTimeZone(java.util.TimeZone timeZone)` Sets the time zone in which tests will execute.
`LocalServiceTestHelper` | `setUp()` Set up an environment in which tests that use local services can execute.
`void` | `tearDown()` Tear down the environment in which tests that use local services can execute.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LocalServiceTestHelper

    public LocalServiceTestHelper(LocalServiceTestConfig... configs)

  Constructs a LocalServiceTestHelper with the provided configurations.

  Parameters:
    `configs` - for the local services that need to be set up and torn down.

Method Detail

### setEnvAppId

    public LocalServiceTestHelper setEnvAppId(java.lang.String envAppId)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getAppId()`

  Parameters:
    `envAppId` -
  Returns:
    `this` (for chaining)

### setEnvVersionId

    public LocalServiceTestHelper setEnvVersionId(java.lang.String envVersionId)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getVersionId()`

  Parameters:
    `envVersionId` -
  Returns:
    `this` (for chaining)

### setEnvEmail

    public LocalServiceTestHelper setEnvEmail(java.lang.String envEmail)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getEmail()`

  Parameters:
    `envEmail` -
  Returns:
    `this` (for chaining)

### setEnvIsLoggedIn

    public LocalServiceTestHelper setEnvIsLoggedIn(boolean envIsLoggedIn)

  The value to be returned by `ApiProxy.getCurrentEnvironment().isLoggedIn()`

  Parameters:
    `envIsLoggedIn` -
  Returns:
    `this` (for chaining)

### setEnvIsAdmin

    public LocalServiceTestHelper setEnvIsAdmin(boolean envIsAdmin)

  The value to be returned by `ApiProxy.getCurrentEnvironment().isAdmin()`

  Parameters:
    `envIsAdmin` -
  Returns:
    `this` (for chaining)

### setEnvAuthDomain

    public LocalServiceTestHelper setEnvAuthDomain(java.lang.String envAuthDomain)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getAuthDomain()`

  Parameters:
    `envAuthDomain` -
  Returns:
    `this` (for chaining)

### setEnvRequestNamespace

    public LocalServiceTestHelper setEnvRequestNamespace(java.lang.String envRequestNamespace)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getRequestNamespace()`

  Parameters:
    `envRequestNamespace` -
  Returns:
    `this` (for chaining)

### setEnvAttributes

    public LocalServiceTestHelper setEnvAttributes(java.util.Map<java.lang.String,java.lang.Object> envAttributes)

  The value to be returned by `ApiProxy.getCurrentEnvironment().getAttributes()`

  Parameters:
    `envAttributes` -
  Returns:
    `this` (for chaining)

### setClock

    public LocalServiceTestHelper setClock(Clock clock)

  Sets the clock with which all local services will be initialized. Note that once a local service is initialized its clock cannot be altered.

  Parameters:
    `clock` -
  Returns:
    `this` (for chaining)

### setEnforceApiDeadlines

    public LocalServiceTestHelper setEnforceApiDeadlines(boolean val)

  Determines whether or not API calls should be subject to the same deadlines as in production. The default is `false`.

  Parameters:
    `val` -
  Returns:
    `this` (for chaining)

### setSimulateProdLatencies

    public LocalServiceTestHelper setSimulateProdLatencies(boolean val)

  Determines whether or not local services should simulate production latencies. The default is `false`.

  Parameters:
    `val` -
  Returns:
    `this` (for chaining)

### setTimeZone

    public LocalServiceTestHelper setTimeZone(java.util.TimeZone timeZone)

  Sets the time zone in which tests will execute. If not set we use the same timezone that we use in production and the dev appserver: UTC

  Parameters:
    `timeZone` - the time zone
  Returns:
    `this` (for chaining)

### setUp

    public final LocalServiceTestHelper setUp()

  Set up an environment in which tests that use local services can execute.

  Returns:
    `this` (for chaining)

### newEnvironment

    protected com.google.apphosting.api.ApiProxy.Environment newEnvironment()

  Constructs the `ApiProxy.Environment` that will be installed. Subclass and override to provide your own implementation.

### newLocalServerEnvironment

    protected LocalServerEnvironment newLocalServerEnvironment()

  Constructs the `LocalServerEnvironment` that will be installed. Subclass and override to provide your own implementation.

### tearDown

    public final void tearDown()

  Tear down the environment in which tests that use local services can execute.

### getApiProxyLocal

    public static ApiProxyLocal getApiProxyLocal()

  Convenience function for getting ahold of the currently registered `ApiProxyLocal`.

### getLocalService

    public static LocalRpcService getLocalService(java.lang.String serviceName)

  Convenience function for getting ahold of a specific local service. For example, to get ahold of the LocalDatastoreService you would call `getLocalService(LocalDatastoreService.PACKAGE)`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD