• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LocalUserServiceTestConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setup

import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig; //导入依赖的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.LocalUserServiceTestConfig; //导入依赖的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: before

import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig; //导入依赖的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.LocalUserServiceTestConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NotFoundException类代码示例发布时间:2022-05-21
下一篇:
Java VCFCodec类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap