Unit testing Objectify事务在单元测试中失败

Unit testing Objectify事务在单元测试中失败,unit-testing,google-app-engine,transactions,objectify,Unit Testing,Google App Engine,Transactions,Objectify,非常简单的Objectify事务的单元测试总是失败: “仅在高复制应用程序中允许在多个实体组上进行事务处理”。只要案例中只使用了一个实体。 这样的事务在dev服务器和Google实例上都能很好地执行。所以我可能需要一些LocalServiceTestHelper调整。 有人能帮忙吗 下面是我的单元测试: @Test public void transactionTest() { // setup final LocalServiceTestHelper helper = new

非常简单的Objectify事务的单元测试总是失败: “仅在高复制应用程序中允许在多个实体组上进行事务处理”。只要案例中只使用了一个实体。 这样的事务在dev服务器和Google实例上都能很好地执行。所以我可能需要一些LocalServiceTestHelper调整。 有人能帮忙吗

下面是我的单元测试:

@Test
public void transactionTest() {
    // setup
    final LocalServiceTestHelper helper = new LocalServiceTestHelper(
            new LocalDatastoreServiceTestConfig(),
            new LocalMemcacheServiceTestConfig());      
    helper.setUp();
    Closeable session = ObjectifyService.begin();

    // test
    ofy().transactNew(new VoidWork() {
        @Override
        public void vrun() {
            User user = new User();
            ofy().save().entity(user).now();
        }
    });

    // teardown
    helper.tearDown();
    session.close();
    session = null;
}
以下是我得到的一个例外:

Mar 17, 2016 8:52:12 AM com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFO: Local Datastore initialized: 
Type: Master/Slave
Storage: In-memory
Mar 17, 2016 8:52:13 AM com.googlecode.objectify.impl.TransactorNo transactOnce
SEVERE: Rollback failed, suppressing error
java.lang.IllegalArgumentException: transactions on multiple entity groups only allowed in High Replication applications
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:54)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.convertException(DatastoreApiHelper.java:129)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:96)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:76)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:36)
at com.google.appengine.api.datastore.InternalTransactionV3.getHandle(InternalTransactionV3.java:43)
at com.google.appengine.api.datastore.InternalTransactionV3.getId(InternalTransactionV3.java:81)
at com.google.appengine.api.datastore.TransactionImpl.getId(TransactionImpl.java:111)
at com.google.appengine.api.datastore.TransactionStackImpl.getTransactionData(TransactionStackImpl.java:107)
at com.google.appengine.api.datastore.TransactionStackImpl.getFutures(TransactionStackImpl.java:117)
at com.google.appengine.api.datastore.TransactionImpl.rollbackAsync(TransactionImpl.java:188)
at com.google.appengine.api.datastore.TransactionImpl.rollback(TransactionImpl.java:181)
at com.googlecode.objectify.util.cmd.TransactionWrapper.rollback(TransactionWrapper.java:42)
at com.googlecode.objectify.impl.TransactorNo.transactOnce(TransactorNo.java:131)
at com.googlecode.objectify.impl.TransactorNo.transactNew(TransactorNo.java:97)
at com.googlecode.objectify.impl.ObjectifyImpl.transactNew(ObjectifyImpl.java:206)
at com.googlecode.objectify.impl.ObjectifyImpl.transactNew(ObjectifyImpl.java:198)
at cz.inited.ofy.controllers.TransactionTest.transactionTest(TransactionTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

您必须显式启用HRD-这在今天有点奇怪,因为主/从数据存储不再存在:

private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(
                new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy());

是否
LocalDatastoreServiceTestConfig().SetDefaultHighRepJobPolicyUnpliedJobPercentage(100)
help?我记得不久前JUnit测试中的Objectify事务有问题,但不记得确切的错误。