07-18-2012 02:43 PM
We have our own transaction mangager class that uses the TransactionHelper. Our Transaction manager changes the current transaction timeout and seems when our nuxeo system is running but not during Junit testing. I looked through the nuxeo documementation for information on configuring nuxeo unit tests but can't seem to get the configuration right so that the unit tests run the same way.
Do I need to be in an Operation or OperationMethod to be able to use the TransactionHelper? The Unit tests that run our existing Operations that try to change the transaction timeout are not able to set the time out in a unit test either.
I'm new to nuxeo, so sorry if this is a basic question, and the knowledgeable nuxeo developers at my company did not know the answer.
My Junit class's annotations are:
@RunWith(FeaturesRunner.class)
@Features({RuntimeFeature.class, CoreFeature.class})
@RepositoryConfig(type = BackendType.H2, user = "Administrator", init = DefaultRepositoryInit.class)
public class TransactionManagerTest {
and the test looks like this:
try {
javax.transaction.TransactionManager mgr = TransactionHelper.lookupTransactionManager();
Assert.assertNotNull(mgr);
} catch (NamingException e) {
e.printStackTrace(); }
try {
javax.transaction.UserTransaction user = TransactionHelper.lookupUserTransaction();
} catch (NamingException e) {
e.printStackTrace(); }
boolean results = TransactionHelper.startTransaction();
// Assert.assertTrue("started a Transaction using the Transaction Helper",results);
For the lookup tests i get the following:
DatabaseHelper: Database used for VCS tests: org.nuxeo.ecm.core.storage.sql.DatabaseH2
SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
javax.naming.NamingException: TransactionManager not found in JNDI
at org.nuxeo.runtime.transaction.TransactionHelper.lookupTransactionManager(TransactionHelper.java:129)
at com.jeppesen.gs.utils.transactions.TransactionManagerTest.testTransactions
snip...
and the TransactionHelper.startTransaction() returns false.
07-18-2012 03:06 PM
You need an actual transaction manager to be running for your tests. You can have one automatically created and registered in JNDI by adding to your list the feature TransactionalFeature
, and also add the following annotation to your test class if you want to manually manage transaction start/stop in the test methods:
@TransactionalConfig(autoStart = false)
07-18-2012 04:11 PM
Thanks, that worked (and now I know where to look for Features!) and I can create transactions but I'm getting the following warnings
07-19-2012 11:43 AM
You can ignore this error for now, it's legitimate to call createDocumentModel
without a transaction. We'll try to improve this message for the next release.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.