我在应用引擎 java jdo 中有一个跨组事务。
它在本地开发应用引擎服务器上运行良好。
但是,从单元测试中,我得到了一个java.lang.IllegalArgumentException: transactions on multiple entity groups only allowed in High Replication applications
.
是否可以使用 LocalServiceTestHelper 模拟高复制应用程序?
我正在使用 1.6.6。
这是我的课程,您可以按原样运行它来重现:
public class Ds2Test {
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
private static final PersistenceManagerFactory pmfXgInstance =
JDOHelper.getPersistenceManagerFactory("xg-transactions");
@Before
public void setUp() {
helper.setUp();
}
@After
public void tearDown() {
helper.tearDown();
}
@Test
public void testXgTransaction() throws Exception {
PersistenceManager xgPm = pmfXgInstance.getPersistenceManager();
Transaction xgTx = xgPm.currentTransaction();
xgTx.begin();
xgTx.commit();
xgPm.close();
}
}
这是 jdoconfig.xml 中的配置:
<persistence-manager-factory name="xg-transactions">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
<property name="datanucleus.appengine.datastoreEnableXGTransactions" value="true"/>
</persistence-manager-factory>
抛出异常xgTx.begin();