@@ -0,0 +1,2223 @@
+/**%0A * Project Distributed Transactions.%0A * Copyright Micha%C5%82 Szczygie%C5%82, 2013.%0A * Created at Dec 29, 2013.%0A */%0Apackage com.m4gik.busisess;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.sql.Timestamp;%0A%0Aimport org.junit.Test;%0Aimport org.springframework.test.context.transaction.AfterTransaction;%0Aimport org.springframework.test.context.transaction.BeforeTransaction;%0Aimport org.springframework.transaction.annotation.Transactional;%0A%0A/**%0A * %0A * This class test behavior during testing distributed transaction.%0A * %0A * @author m4gik %3Cmichal.szczygiel@wp.pl%3E%0A * %0A */%0Apublic class DistrbutedTransactionDataSourceTest extends BaseDataSourceTest %7B%0A%0A    @AfterTransaction%0A    public void checkPostConditions() %7B%0A%0A        int count = getJdbcWarehousePoland().queryForInt(%0A                %22SELECT COUNT(*) FROM DEPOT%22);%0A        // This change was rolled back by the test framework%0A        assertEquals(0, count);%0A%0A        count = getJdbcWarehouseFinland().queryForInt(%0A                %22SELECT COUNT(*) FROM DEPOT%22);%0A        // This rolled back as well because of the XA%0A        assertEquals(0, count);%0A%0A    %7D%0A%0A    @BeforeTransaction%0A    public void clearData() %7B%0A        getJdbcFinance().update(%22DELETE FROM REGISTER%22);%0A        getJdbcWarehouseFinland().update(%22DELETE FROM DEPOT%22);%0A        getJdbcWarehousePoland().update(%22DELETE FROM DEPOT%22);%0A    %7D%0A%0A    @Transactional%0A    @Test%0A    public void testInsertIntoTwoDataSources() throws Exception %7B%0A%0A        assertEquals(%0A                1,%0A                getJdbcFinance()%0A                        .update(%22INSERT INTO REGISTER (id, name, register_date, price) VALUES (?,?,?,?)%22,%0A                                0, %22stuff%22, (new Timestamp(0)), 16.0));%0A%0A        assertEquals(%0A                1,%0A                getJdbcWarehouseFinland()%0A                        .update(%22INSERT INTO DEPOT (id, name, depot_date, amount) VALUES (?,?,?,?)%22,%0A                                0, %22stuff%22, (new Timestamp(0)), 16.0));%0A%0A        assertEquals(%0A                1,%0A                getJdbcWarehousePoland()%0A                        .update(%22INSERT INTO DEPOT (id, name, depot_date, amount) VALUES (?,?,?,?)%22,%0A                                0, %22stuff%22, (new Timestamp(0)), 16.0));%0A%0A    %7D%0A%0A%7D%0A

Add test for distributed transaction for data sources