|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig
public final class LocalTaskQueueTestConfig
Config for accessing the local task queue in tests. Default behavior is to
configure the local task queue to not automatically execute any tasks.
tearDown()
wipes out all in-memory state so all queues are empty at
the end of every test.
Nested Class Summary | |
---|---|
static class |
LocalTaskQueueTestConfig.DeferredTaskCallback
A LocalTaskQueueCallback implementation that automatically detects
and runs tasks with a DeferredTask payload. |
static class |
LocalTaskQueueTestConfig.TaskCountDownLatch
A CountDownLatch extension that can be reset. |
Constructor Summary | |
---|---|
LocalTaskQueueTestConfig()
|
Method Summary | |
---|---|
static LocalTaskQueue |
getLocalTaskQueue()
|
LocalTaskQueueTestConfig |
setCallbackClass(java.lang.Class<? extends LocalTaskQueueCallback> callbackClass)
Overrides the callback implementation used by the local task queue for async task execution. |
LocalTaskQueueTestConfig |
setDisableAutoTaskExecution(boolean disableAutoTaskExecution)
Disables/enables automatic task execution. |
LocalTaskQueueTestConfig |
setQueueXmlPath(java.lang.String queueXmlPath)
Overrides the location of queue.xml. |
LocalTaskQueueTestConfig |
setShouldCopyApiProxyEnvironment(boolean b)
Enables copying of the ApiProxy.Environment to task handler
threads. |
LocalTaskQueueTestConfig |
setTaskExecutionLatch(java.util.concurrent.CountDownLatch latch)
Sets a CountDownLatch that the thread executing the task will
decrement after a LocalTaskQueueCallback finishes execution. |
void |
setUp()
Set up the local service. |
void |
tearDown()
Tear down the local service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LocalTaskQueueTestConfig()
Method Detail |
---|
public LocalTaskQueueTestConfig setDisableAutoTaskExecution(boolean disableAutoTaskExecution)
TaskOptions
was constructed. If you do not
have a servlet engine running, this will fail. As an alternative to
launching a servlet engine, instead consider providing a
LocalTaskQueueCallback
via setCallbackClass(Class)
so that
you can assert on the properties of the URLFetchServicePb.URLFetchRequest.
disableAutoTaskExecution
-
this
(for chaining)public LocalTaskQueueTestConfig setQueueXmlPath(java.lang.String queueXmlPath)
queueXmlPath
-
this
(for chaining)public LocalTaskQueueTestConfig setCallbackClass(java.lang.Class<? extends LocalTaskQueueCallback> callbackClass)
callbackClass
- fully-qualified name of a class with a public, default
constructor that implements LocalTaskQueueCallback
.
this
(for chaining)public LocalTaskQueueTestConfig setShouldCopyApiProxyEnvironment(boolean b)
ApiProxy.Environment
to task handler
threads. This setting is ignored unless both
In this case tasks will be handled locally by new threads and it may be
useful for those threads to use the same environment data as the main test
thread. Properties such as the
appID
, and the user
email
will be copied
into the environment of the task threads. Be aware that
attribute
map
will be shallow-copied to the task thread environents, so that any
mutable objects used as values of the map should be thread safe. If this
property is false
then the task handler threads will have an empty
ApiProxy.Environment
. This property is false
by default.
b
- should the ApiProxy.Environment
be pushed to task handler
threads
this
(for chaining)public LocalTaskQueueTestConfig setTaskExecutionLatch(java.util.concurrent.CountDownLatch latch)
CountDownLatch
that the thread executing the task will
decrement after a LocalTaskQueueCallback
finishes execution. This
makes it easy for tests to block until a task queue task runs. Note that
the latch is only used when a callback class is provided (via
setCallbackClass(Class)
) and when automatic task execution is
enabled (via setDisableAutoTaskExecution(boolean)
). Also note
that a CountDownLatch
cannot be reused, so if you have a test that
requires the ability to "reset" a CountDownLatch you can pass an instance
of LocalTaskQueueTestConfig.TaskCountDownLatch
, which exposes additional methods that help
with this.
latch
- The latch.
this
(for chaining)public void setUp()
LocalServiceTestConfig
setUp
in interface LocalServiceTestConfig
public void tearDown()
LocalServiceTestConfig
tearDown
in interface LocalServiceTestConfig
public static LocalTaskQueue getLocalTaskQueue()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |