camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roman.stumm" <roman.st...@gmx.de>
Subject Re: Testing a transacted route with CamelTestSupport
Date Wed, 17 Jul 2013 07:15:00 GMT
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.

Mime
View raw message