You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "roman.stumm" <ro...@gmx.de> on 2013/07/17 09:15:00 UTC

Re: Testing a transacted route with CamelTestSupport

When I write a unit-test or use a test-spring.xml, I can use my
DummyTransactionManager like this:

 <bean id="transactionManager"
class="de.viaboxx.spring.DummyTransactionManager"/>

or programmatically:

class MyTest extends CamelTestSupport {

@Override
    protected CamelContext createCamelContext() throws Exception {
        CamelContext context = new
DefaultCamelContext(createSimpleRegistry());
        return context;
    }
    private Registry createSimpleRegistry() {
        registry = new SimpleRegistry(); 
        registry.put("transactionManager", new DummyTransactionManager());
        return registry;
    }
}

So I can use transacted() in camel-routes, but without accessing a
JMS-TransactionManager or any DataSource, just as a unit-test...

Here is the class:
public class DummyTransactionManager implements PlatformTransactionManager {
    public TransactionStatus getTransaction(TransactionDefinition
transactionDefinition)
            throws TransactionException {
        return new SimpleTransactionStatus();
    }

    public void commit(TransactionStatus transactionStatus) throws
TransactionException {
    }

    public void rollback(TransactionStatus transactionStatus) throws
TransactionException {

    }
}




--
View this message in context: http://camel.465427.n5.nabble.com/Testing-a-transacted-route-with-CamelTestSupport-tp5502129p5735768.html
Sent from the Camel - Users mailing list archive at Nabble.com.