1 16 package scriptella; 17 18 import scriptella.execution.EtlExecutor; 19 import scriptella.execution.EtlExecutorException; 20 import scriptella.jdbc.QueryHelper; 21 import scriptella.spi.ParametersCallback; 22 import scriptella.spi.QueryCallback; 23 24 import java.sql.Connection ; 25 26 27 33 public class DBTableCopyTest extends DBTestCase { 34 37 public void test() throws EtlExecutorException { 38 final Connection con = getConnection("test"); 39 final EtlExecutor se = newEtlExecutor("DBTableCopyTest.xml"); 40 se.execute(); 41 42 QueryHelper s = new QueryHelper("select * from test2"); 43 final int n[] = new int[]{0}; 44 45 s.execute(con, 46 new QueryCallback() { 47 public void processRow(final ParametersCallback row) { 48 n[0]++; 49 assertEquals(n[0], row.getParameter("ID")); 50 if (n[0] == 3) { assertEquals("value", row.getParameter("value2")); 52 } else { 53 assertNull(row.getParameter("value2")); 54 } 55 } 56 }); 57 assertEquals(n[0], 3); 58 } 59 60 63 public void test2() throws EtlExecutorException { 64 final Connection con = getConnection("test"); 65 final Connection con2 = getConnection("test2"); 66 final EtlExecutor se = newEtlExecutor("DBTableCopyTest2.xml"); 67 se.execute(); 68 69 QueryHelper s = new QueryHelper("select * from test2"); 70 final int n[] = new int[]{0}; 71 72 s.execute(con2, 73 new QueryCallback() { 74 public void processRow(final ParametersCallback row) { 75 n[0]++; 76 assertEquals(n[0], row.getParameter("ID")); 77 } 78 }); 79 assertEquals(n[0], 3); 80 81 try { 82 new QueryHelper("select * from test2").execute(con, null); 83 fail("Test2 is absent in the 1st database"); 84 } catch (IllegalStateException e) { 85 } 87 } 88 } 89 | Popular Tags |