I'm attempting to write unit tests for my Java AppEngine application around my caching service. Any time I make a get or put I get the following exception:
Can't make API call memcache.Get in a thread that is neither the original request thread nor a thread created by ThreadManager
My implementation is simple enough:
MemcacheServiceFactory.getAsyncMemcacheService(NAMESPACE).get("key")
MemcacheServiceFactory.getAsyncMemcacheService(NAMESPACE).put("key", "value")
I have also tried:
MemcacheServiceFactory.getMemcacheService(NAMESPACE).get("key")
MemcacheServiceFactory.getMemcacheService(NAMESPACE).put("key", "value")
This works just fine when I'm running it as a "local deployment" as part of my web service as a whole, but the standalone test on this section of code will not work.
Is there any way to test the memcache service stand alone - outside of the gae envirnment?
Have you initialized LocalServiceTestHelper like that?
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalMemcacheServiceTestConfig());
Here you can find an example: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/unittests/src/test/java/com/google/appengine/samples/LocalMemcacheTest.java
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.