当前位置: 首页>>代码示例>>Java>>正文


Java LocalServiceTestHelper类代码示例

本文整理汇总了Java中com.google.appengine.tools.development.testing.LocalServiceTestHelper的典型用法代码示例。如果您正苦于以下问题:Java LocalServiceTestHelper类的具体用法?Java LocalServiceTestHelper怎么用?Java LocalServiceTestHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalServiceTestHelper类属于com.google.appengine.tools.development.testing包,在下文中一共展示了LocalServiceTestHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
/**
 * Sets up the GAE simulation.
 */
public synchronized void setup() {
    System.out.println("Setting up GAE simulation");

    LocalTaskQueueTestConfig localTasks = new LocalTaskQueueTestConfig();
    localTasks.setQueueXmlPath(QUEUE_XML_PATH);

    LocalUserServiceTestConfig localUserServices = new LocalUserServiceTestConfig();
    LocalDatastoreServiceTestConfig localDatastore = new LocalDatastoreServiceTestConfig();
    LocalMailServiceTestConfig localMail = new LocalMailServiceTestConfig();
    LocalSearchServiceTestConfig localSearch = new LocalSearchServiceTestConfig();
    localSearch.setPersistent(false);
    LocalModulesServiceTestConfig localModules = new LocalModulesServiceTestConfig();
    LocalLogServiceTestConfig localLog = new LocalLogServiceTestConfig();
    helper = new LocalServiceTestHelper(localDatastore, localMail, localUserServices,
                                        localTasks, localSearch, localModules, localLog);
    helper.setUp();

    sc = new ServletRunner().newClient();
    localLogService = LocalLogServiceTestConfig.getLocalLogService();
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:24,代码来源:GaeSimulation.java

示例2: setUp

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  // Initialize a Security handler and install our authenticatior.
  ServletHandler servletHandler = new ServletHandler();
  servletHandler.addServletWithMapping(new ServletHolder(new AuthServlet()) {}, "/*");
  securityHandler = new TestConstraintSecurityHandler();
  securityHandler.setHandler(servletHandler);
  AppEngineAuthentication.configureSecurityHandler(securityHandler, new MockAddressChecker());

  // Add authenticated paths to the security handler. Requests for those paths will be forwarded
  // to the authenticator with "mandatory=true".
  addConstraint(securityHandler, "/admin/*", "adminOnly", "admin");
  addConstraint(securityHandler, "/user/*", "userOnly", "*");
  addConstraint(securityHandler, "/_ah/login", "reserved", "*", "admin");
  securityHandler.doStart(); // Start the handler so the constraint map is compiled.

  // Use a local test version of the UserService to allow us to control login state.
  helper = new LocalServiceTestHelper(new LocalUserServiceTestConfig()).setUp();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:20,代码来源:AppEngineAuthenticationTest.java

示例3: setUp

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@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();
}
 
开发者ID:instacount,项目名称:appengine-counter,代码行数:27,代码来源:ShardedCounterServiceCounterShardDecrementNoMemcacheTest.java

示例4: disableMemcache

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
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();
}
 
开发者ID:instacount,项目名称:appengine-counter,代码行数:24,代码来源:AbstractShardedCounterServiceTest.java

示例5: before

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
    List<LocalServiceTestConfig> testConfigs = createTestConfigs();
    helper = new LocalServiceTestHelper(testConfigs.toArray(new LocalServiceTestConfig[0]));
    helper.setTimeZone(TimeZone.getDefault());
    helper.setUp();
}
 
开发者ID:monPlan,项目名称:springboot-spwa-gae-demo,代码行数:8,代码来源:SetupAppengine.java

示例6: before

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Before
public void before() {
  helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()).setUp();
  // Clear out the factory so that it requires re-registration on each test method.
  // Otherwise, static registration of types in one method would persist across methods.
  initOfy();
  factory = ObjectifyService.factory();
  ObjectifyService.setFactory(new ObjectifyFactory(false));
}
 
开发者ID:google,项目名称:nomulus,代码行数:10,代码来源:OfyFilterTest.java

示例7: setUp

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
/**
 * Sets up the AppEngine environment and initializes Guice.
 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    datastoreConfig = new LocalDatastoreServiceTestConfig();
    memcacheConfig = new LocalMemcacheServiceTestConfig();
    taskQueueConfig = new LocalTaskQueueTestConfig();
    taskQueueConfig.setQueueXmlPath("src/main/webapp/WEB-INF/queue.xml");

    HashMap<String, Object> envAttr = new HashMap<String, Object>();
    envAttr.put("com.google.appengine.api.users.UserService.user_id_key", "13");

    helper = new LocalServiceTestHelper(datastoreConfig, taskQueueConfig);
    helper.setEnvAuthDomain("auth");
    helper.setEnvEmail("[email protected]");
    helper.setEnvAttributes(envAttr);
    helper.setEnvIsAdmin(true);
    helper.setEnvIsLoggedIn(true);
    helper.setUp();
    User user = UserTestCase.addTestUser();

    // Mock the session so AuthFilter will also return the test user
    HttpServletRequest mockServletRequest = Mockito.mock(HttpServletRequest.class);
    HttpSession mockHttpSession = Mockito.mock(HttpSession.class);
    Mockito.when(mockHttpSession.getAttribute(AuthFilter.USER_KEY)).thenReturn(user);
    Mockito.when(mockServletRequest.getSession()).thenReturn(mockHttpSession);
    AuthFilter.testLogin(mockServletRequest, user);
}
 
开发者ID:turbomanage,项目名称:listmaker,代码行数:31,代码来源:BaseTest.java

示例8: testDisabledDatastore

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Test(expected = ApiProxy.CapabilityDisabledException.class)
public void testDisabledDatastore() {
  Capability testOne = new Capability("datastore_v3");
  CapabilityStatus testStatus = CapabilityStatus.DISABLED;
  // Initialize the test configuration.
  LocalCapabilitiesServiceTestConfig config =
      new LocalCapabilitiesServiceTestConfig().setCapabilityStatus(testOne, testStatus);
  helper = new LocalServiceTestHelper(config);
  helper.setUp();
  FetchOptions fo = FetchOptions.Builder.withLimit(10);
  DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
  assertEquals(0, ds.prepare(new Query("yam")).countEntities(fo));
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:14,代码来源:ShortTest.java

示例9: RetryTest

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
public RetryTest() {
  LocalTaskQueueTestConfig taskQueueConfig = new LocalTaskQueueTestConfig();
  taskQueueConfig.setCallbackClass(TestingTaskQueueCallback.class);
  taskQueueConfig.setDisableAutoTaskExecution(false);
  taskQueueConfig.setShouldCopyApiProxyEnvironment(true);
  helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig(), taskQueueConfig,
      new LocalModulesServiceTestConfig());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:9,代码来源:RetryTest.java

示例10: UserGuideTest

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
public UserGuideTest() {
  LocalTaskQueueTestConfig taskQueueConfig = new LocalTaskQueueTestConfig();
  taskQueueConfig.setCallbackClass(TestingTaskQueueCallback.class);
  taskQueueConfig.setDisableAutoTaskExecution(false);
  taskQueueConfig.setShouldCopyApiProxyEnvironment(true);
  helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig(), taskQueueConfig,
      new LocalModulesServiceTestConfig());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:9,代码来源:UserGuideTest.java

示例11: PipelineTest

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
public PipelineTest() {
  LocalTaskQueueTestConfig taskQueueConfig = new LocalTaskQueueTestConfig();
  taskQueueConfig.setCallbackClass(TestingTaskQueueCallback.class);
  taskQueueConfig.setDisableAutoTaskExecution(false);
  taskQueueConfig.setShouldCopyApiProxyEnvironment(true);
  helper = new LocalServiceTestHelper(
      new LocalDatastoreServiceTestConfig()
          .setDefaultHighRepJobPolicyUnappliedJobPercentage(
              isHrdSafe() ? 100 : 0),
      taskQueueConfig, new LocalModulesServiceTestConfig());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:12,代码来源:PipelineTest.java

示例12: setUp

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();
  LocalTaskQueueTestConfig taskQueueConfig = new LocalTaskQueueTestConfig();
  taskQueueConfig.setDisableAutoTaskExecution(true);
  taskQueueConfig.setShouldCopyApiProxyEnvironment(true);
  helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig(), taskQueueConfig,
      new LocalModulesServiceTestConfig());
  helper.setUp();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:11,代码来源:AppEngineTaskQueueTest.java

示例13: testSavingAndLoadingJavaObject

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Test
public void testSavingAndLoadingJavaObject() {
    final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
    helper.setUp();
    final String key = "testid-" + RandomUtils.getInstance().getRandomSafeString(20);

    Resource.buildJavaObject(key, testClass).save(false);
    final TestClass result = (TestClass) Resource.load(key).getJavaObject();

    assertEquals(result, testClass);
}
 
开发者ID:ZupCat,项目名称:simple-datastore,代码行数:12,代码来源:ResourceTest.java

示例14: before

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@Override 
protected void before() throws Throwable {
	LocalDatastoreServiceTestConfig cfg = new LocalDatastoreServiceTestConfig();
	LocalBlobstoreServiceTestConfig blobCfg = new LocalBlobstoreServiceTestConfig();
	LocalTaskQueueTestConfig queueCfg = new LocalTaskQueueTestConfig();
	LocalMemcacheServiceTestConfig cacheCfg = new LocalMemcacheServiceTestConfig();
	helper = new LocalServiceTestHelper(cfg, blobCfg, queueCfg, cacheCfg);
	helper.setUp();
}
 
开发者ID:rzymek,项目名称:obsolete-web-boards-gwt,代码行数:10,代码来源:EmbeddedDataStore.java

示例15: setUp

import com.google.appengine.tools.development.testing.LocalServiceTestHelper; //导入依赖的package包/类
@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;
}
 
开发者ID:instacount,项目名称:appengine-counter,代码行数:39,代码来源:AbstractShardedCounterServiceTest.java


注:本文中的com.google.appengine.tools.development.testing.LocalServiceTestHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。