Objectify transaction fails in unit test

8 visninger
Gå til det første ulæste opslag

Jarda Pavlíček via StackOverflow

ulæst,
17. mar. 2016, 05.00.0417.03.2016
til google-appengin...@googlegroups.com

This unit test of very simple Objectify transaction always fail on: "transactions on multiple entity groups only allowed in High Replication applications". Whenever there is only one entity used in the case. Such a transaction is executed well on both dev server and Google instance. So I probably need some LocalServiceTestHelper tweaking. Can anybody help please?

Here is my unit test:

@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;
}

And here is the exception I get:

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)


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/36055676/objectify-transaction-fails-in-unit-test

stickfigure via StackOverflow

ulæst,
17. mar. 2016, 12.00.0817.03.2016
til google-appengin...@googlegroups.com

You must explicitly enable the HRD - which is a bit odd today since the master/slave datastore no longer exists:

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


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/36055676/objectify-transaction-fails-in-unit-test/36065690#36065690
Svar alle
Svar til forfatter
Videresend
0 nye opslag