And the test code is like this:
@Test
public void memcacheConcurrentAccess() throws InterruptedException {
Runnable runner = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
MemcacheService service =
MemcacheServiceFactory.getMemcacheService();
service.increment("test-key", 1L, 1L);
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
service.increment("test-key", 1L, 1L);
}
};
Thread t1 = new Thread(runner);
Thread t2 = new Thread(runner);
t1.start();
t2.start();
while (t1.isAlive()) {
Thread.sleep(100L);
}
}
On Apr 24, 3:59 pm, Phuong Nguyen <[email protected]> wrote:
> Here is one kind of exception that I got:
> Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException:
> The API package 'memcache' or call 'Increment()' was not found.
> at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:95)
> at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:48)
> at
> com.google.appengine.api.memcache.MemcacheServiceImpl.increment(MemcacheServiceImpl.java:
> 623)
>
> Other exceptions are almost similar (ApiProxy$CallNotFoundException,
> with different command - 'Set()', for example).
>
> On Apr 24, 3:31 pm, Phuong Nguyen <[email protected]> wrote:
>
>
>
> > Hi,
> > Is there any way to simulating concurrent access to memcache during
> > unit testing?
> > I'm trying to write a wrapper to try to synchronize access to
> > memcache. However, my test fail miserably because when ever I create a
> > thread, then inside this thread, almost any interaction with Memcache
> > API would result in an exception. (I guess it due to GAE constraint
> > that threads won't be manually created???)
>
> > I'm using these components to create the testing env:
>
> > LocalDatastoreServiceTestConfig datastoreConfig = new
> > LocalDatastoreServiceTestConfig();
> > LocalMemcacheServiceTestConfig memcacheConfig = new
> > LocalMemcacheServiceTestConfig();
> > helper = new LocalServiceTestHelper(datastoreConfig, memcacheConfig);
>
> > and helper.setUp/helper.tearDown before and after test method.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group
> athttp://groups.google.com/group/google-appengine-java?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.