首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于测试objectify的gwt junit

用于测试objectify的gwt junit
EN

Stack Overflow用户
提问于 2012-06-01 21:43:07
回答 1查看 685关注 0票数 1

我正在尝试使用gwt junit测试我的gwt应用程序,但似乎无法正确设置以测试objectify。所有的教程都演示了测试DataStore而不是objectify (这是更高级别的数据库服务),我的测试基类如下所示:

代码语言:javascript
复制
public class TestBase {
private static final LocalServiceTestHelper helper =
    new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
protected static ObjectifyFactory fact;

@BeforeClass
public static void setUp() {
    helper.setUp();
    fact = new ObjectifyFactory() {
        @Override
        public Objectify begin(ObjectifyOpts opts)
        {
            opts.setSessionCache(false);
            return super.begin(opts);
        }
    };

}

@AfterClass
public static void tearDown() {
    helper.tearDown();
}

}

然后我有扩展基类的类:

代码语言:javascript
复制
public class UserServiceTest extends TestBase{
private User inactiveUser;
private UserService us;
Objectify _ofy;

@Rule
public ExpectedException thrown = ExpectedException.none();


@Before
public void beforeTest() {   

    //Register the classes used in the test
    fact.register(User.class);


    us = new UserService();
    inactiveUser = new User();

}   

@Test
public void basicTest(){
    Objectify ofy = ObjectifyService.begin();
    ofy.put(inactiveUser); //This fails with exception: An exception occurred: com.google.apphosting.api.ApiProxy$CallNotFoundException 

            //My goal is to reach these test but "addUser" uses also objectify
    //UserService.addUser("shpungin@gmail.com", "bye");
    //assertNotNull(inactiveUser.get_id());
}

你知道我做错了什么吗?我找遍了互联网,没有找到任何解决方案(有些人甚至说要从.classpath中删除app-engine-sdk,但它似乎不起作用。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-02 00:31:31

我解决了这个问题。

尽管com.google.apphosting.api.ApiProxy应该是应用程序引擎的一部分,但是一些jars仍然需要放在.classpath中:

${SDK_ROOT}/lib/testing/appengine-testing.jar

${SDK_ROOT}/lib/impl/appengine-api.jar

${SDK_ROOT}/lib/impl/appengine-api-labs.jar

${SDK_ROOT}/lib/impl/appengine-api-stubs.jar //我错过了这个

另外,我把我的app-engine升级到了v1.6.4.1(也许这也有帮助)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10851440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档