com.googlecode.objectify.test.CachingDatastoreTests Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectify Show documentation
Show all versions of objectify Show documentation
*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore
The newest version!
/*
*/
package com.googlecode.objectify.test;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.logging.Logger;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.googlecode.objectify.cache.CachingAsyncDatastoreService;
import com.googlecode.objectify.cache.EntityMemcache;
import com.googlecode.objectify.test.util.MockAsyncDatastoreService;
/**
* Tests of the caching datastore directly, outside of the rest of Objectify. Tries to create as few
* future wrappers as possible so we can easily see what is going on.
*
* @author Jeff Schnitzer
*/
public class CachingDatastoreTests extends TestBase
{
/** */
@SuppressWarnings("unused")
private static Logger log = Logger.getLogger(CachingDatastoreTests.class.getName());
/** Caching */
CachingAsyncDatastoreService cads;
/** No datastore */
CachingAsyncDatastoreService nods;
/** Simple bits of data to use */
Key key;
Set keyInSet;
Entity entity;
List entityInList;
/**
*/
@BeforeMethod
public void setUp()
{
super.setUp();
EntityMemcache mc = new EntityMemcache(null);
cads = new CachingAsyncDatastoreService(DatastoreServiceFactory.getAsyncDatastoreService(), mc);
nods = new CachingAsyncDatastoreService(new MockAsyncDatastoreService(), mc);
key = KeyFactory.createKey("thing", 1);
keyInSet = Collections.singleton(key);
entity = new Entity(key);
entity.setProperty("foo", "bar");
entityInList = Collections.singletonList(entity);
}
/** */
@Test
public void testNegativeCache() throws Exception
{
Future