com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig Java Examples

The following examples show how to use com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShardedCounterServiceCounterShardDecrementNoMemcacheTest.java    From appengine-counter with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
	super.setUp();

	// See
	// http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html
	// NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info
	// below
	// http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues
	final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig()
		.setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml")
		.setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class);

	Capability testOne = new Capability("memcache");
	CapabilityStatus testStatus = CapabilityStatus.DISABLED;
	// Initialize
	LocalCapabilitiesServiceTestConfig capabilityStatusConfig = new LocalCapabilitiesServiceTestConfig()
		.setCapabilityStatus(testOne, testStatus);

	// Use a different queue.xml for testing purposes
	helper = new LocalServiceTestHelper(
		new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(0.01f),
		new LocalMemcacheServiceTestConfig(), localTaskQueueConfig, capabilityStatusConfig);
	helper.setUp();
}
 
Example #2
Source File: ShardedCounterServiceDeleteNoMemcacheTest.java    From appengine-counter with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
	super.setUp();

	// See
	// http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html
	// NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info
	// below
	// http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues
	final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig()
		.setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml")
		.setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class);

	Capability testOne = new Capability("memcache");
	CapabilityStatus testStatus = CapabilityStatus.DISABLED;
	// Initialize
	LocalCapabilitiesServiceTestConfig capabilityStatusConfig = new LocalCapabilitiesServiceTestConfig()
		.setCapabilityStatus(testOne, testStatus);

	// Use a different queue.xml for testing purposes
	helper = new LocalServiceTestHelper(
		new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(0.01f),
		new LocalMemcacheServiceTestConfig(), localTaskQueueConfig, capabilityStatusConfig);
	helper.setUp();
}
 
Example #3
Source File: AbstractShardedCounterServiceTest.java    From appengine-counter with Apache License 2.0 6 votes vote down vote up
protected void disableMemcache()
{
	// See
	// http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html
	// NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info
	// below
	// http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues
	final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig()
		.setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml")
		.setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class);

	Capability testOne = new Capability("memcache");
	CapabilityStatus testStatus = CapabilityStatus.DISABLED;
	// Initialize
	LocalCapabilitiesServiceTestConfig capabilityStatusConfig = new LocalCapabilitiesServiceTestConfig()
		.setCapabilityStatus(testOne, testStatus);

	// Use a different queue.xml for testing purposes
	helper = new LocalServiceTestHelper(
		new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(0.01f),
		new LocalMemcacheServiceTestConfig(), localTaskQueueConfig, capabilityStatusConfig);
	helper.setUp();
}
 
Example #4
Source File: ShardedCounterServiceShardIncrementNoMemcacheTest.java    From appengine-counter with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
	super.setUp();

	// See
	// http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html
	// NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info
	// below
	// http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues
	final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig()
		.setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml")
		.setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class);

	Capability testOne = new Capability("memcache");
	CapabilityStatus testStatus = CapabilityStatus.DISABLED;
	// Initialize
	LocalCapabilitiesServiceTestConfig capabilityStatusConfig = new LocalCapabilitiesServiceTestConfig()
		.setCapabilityStatus(testOne, testStatus);

	// Use a different queue.xml for testing purposes
	helper = new LocalServiceTestHelper(
		new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(0.01f),
		new LocalMemcacheServiceTestConfig(), localTaskQueueConfig, capabilityStatusConfig);
	helper.setUp();
}
 
Example #5
Source File: AbstractShardedCounterServiceTest.java    From appengine-counter with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
	// Don't call super.setUp because we initialize slightly differently
	// here...

	countdownLatch = new LocalTaskQueueTestConfig.TaskCountDownLatch(1);

	// See
	// http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html
	// NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info
	// below
	// http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues
	final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig()
		.setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml")
		.setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class);

	// Use a different queue.xml for testing purposes
	helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy(),
		new LocalMemcacheServiceTestConfig(), new LocalCapabilitiesServiceTestConfig(), localTaskQueueConfig);
	helper.setUp();

	memcache = MemcacheServiceFactory.getMemcacheService();
	capabilitiesService = CapabilitiesServiceFactory.getCapabilitiesService();

	// New Objectify 5.1 Way. See https://groups.google.com/forum/#!topic/objectify-appengine/O4FHC_i7EGk
	this.session = ObjectifyService.begin();

	// Enable Joda Translators
	JodaTimeTranslators.add(ObjectifyService.factory());

	ObjectifyService.factory().register(CounterData.class);
	ObjectifyService.factory().register(CounterShardData.class);
	ObjectifyService.factory().register(CounterShardOperationData.class);

	shardedCounterServiceImpl = new ShardedCounterServiceImpl();
	this.shardedCounterService = shardedCounterServiceImpl;
}