當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalDatastoreServiceTestConfig類代碼示例

本文整理匯總了Java中com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig的典型用法代碼示例。如果您正苦於以下問題:Java LocalDatastoreServiceTestConfig類的具體用法?Java LocalDatastoreServiceTestConfig怎麽用?Java LocalDatastoreServiceTestConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LocalDatastoreServiceTestConfig類屬於com.google.appengine.tools.development.testing包,在下文中一共展示了LocalDatastoreServiceTestConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTestConfigs

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的package包/類
/**
 * Override to customise the test configs required.
 *
 * @return Test configs.
 */
protected List<LocalServiceTestConfig> createTestConfigs() {
    List<LocalServiceTestConfig> results = new ArrayList<>();
    LocalTaskQueueTestConfig queueConfig = new LocalTaskQueueTestConfig();
    queueConfig.setQueueXmlPath("src/main/webapp/WEB-INF/queue.xml");

    results.add(new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy());
    results.add(queueConfig);
    results.add(new LocalMemcacheServiceTestConfig());
    results.add(new LocalSearchServiceTestConfig());
    return results;
}
 
開發者ID:n15g,項目名稱:spring-boot-gae,代碼行數:17,代碼來源:SetupAppengine.java

示例2: setup

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例3: setUp

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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.LocalDatastoreServiceTestConfig; //導入依賴的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: createTestConfigs

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的package包/類
/**
 * Override to customise the test configs required.
 *
 * @return
 */
protected List<LocalServiceTestConfig> createTestConfigs() {
    List<LocalServiceTestConfig> results = new ArrayList<>();
    LocalTaskQueueTestConfig queueConfig = new LocalTaskQueueTestConfig();
    queueConfig.setQueueXmlPath("src/main/webapp/WEB-INF/queue.xml");

    results.add(new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy());
    results.add(queueConfig);
    results.add(new LocalMemcacheServiceTestConfig());
    results.add(new LocalSearchServiceTestConfig());
    return results;
}
 
開發者ID:monPlan,項目名稱:springboot-spwa-gae-demo,代碼行數:17,代碼來源:SetupAppengine.java

示例6: before

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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.LocalDatastoreServiceTestConfig; //導入依賴的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: RetryTest

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例9: UserGuideTest

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例10: PipelineTest

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例11: setUp

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例12: testSavingAndLoadingJavaObject

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例13: before

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例14: setUp

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的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

示例15: before

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; //導入依賴的package包/類
@Override
protected void before() throws IOException {
  setupLogging();
  Set<LocalServiceTestConfig> configs = new HashSet<>();
  if (withUrlFetch) {
    configs.add(new LocalURLFetchServiceTestConfig());
  }
  if (withDatastore) {
    configs.add(new LocalDatastoreServiceTestConfig()
        // We need to set this to allow cross entity group transactions.
        .setApplyAllHighRepJobPolicy()
        // This causes unit tests to write a file containing any indexes the test required. We
        // can use that file below to make sure we have the right indexes in our prod code.
        .setNoIndexAutoGen(false));
    // This forces app engine to write the generated indexes to a usable location.
    System.setProperty("appengine.generated.dir", temporaryFolder.getRoot().getAbsolutePath());
  }
  if (withLocalModules) {
    configs.add(new LocalModulesServiceTestConfig()
        .addBasicScalingModuleVersion("default", "1", 1)
        .addBasicScalingModuleVersion("tools", "1", 1)
        .addBasicScalingModuleVersion("backend", "1", 1));
  }
  if (withTaskQueue) {
    File queueFile = temporaryFolder.newFile("queue.xml");
    Files.asCharSink(queueFile, UTF_8).write(taskQueueXml);
    configs.add(new LocalTaskQueueTestConfig()
        .setQueueXmlPath(queueFile.getAbsolutePath()));
  }
  if (withUserService) {
    configs.add(new LocalUserServiceTestConfig());
  }

  helper = new LocalServiceTestHelper(configs.toArray(new LocalServiceTestConfig[]{}));

  if (withUserService) {
    // Set top-level properties on LocalServiceTestConfig for user login.
    helper.setEnvIsLoggedIn(userInfo.isLoggedIn())
        // This envAttributes thing is the only way to set userId.
        // see https://code.google.com/p/googleappengine/issues/detail?id=3579
        .setEnvAttributes(ImmutableMap.<String, Object>of(
            "com.google.appengine.api.users.UserService.user_id_key", userInfo.gaeUserId()))
        .setEnvAuthDomain(userInfo.authDomain())
        .setEnvEmail(userInfo.email())
        .setEnvIsAdmin(userInfo.isAdmin());
  }

  if (clock != null) {
    helper.setClock(() -> clock.nowUtc().getMillis());
  }

  if (withLocalModules) {
    helper.setEnvInstance("0");
  }

  helper.setUp();

  if (withDatastore) {
    ObjectifyService.initOfy();
    // Reset id allocation in ObjectifyService so that ids are deterministic in tests.
    ObjectifyService.resetNextTestId();
    loadInitialData();
  }
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:65,代碼來源:AppEngineRule.java


注:本文中的com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。