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.io.ByteArrayInputStream ; 25 import java.io.InputStream ; 26 import java.io.OutputStream ; 27 import java.net.URL ; 28 import java.sql.Connection ; 29 import java.util.Arrays ; 30 31 32 35 public class FilePropertiesTest extends DBTestCase { 36 private static final byte FILE[] = "test file/////".getBytes(); 37 38 public void test() throws EtlExecutorException { 39 final Connection con = getConnection("fileproptst"); 40 AbstractTestCase.testURLHandler = new TestURLHandler() { 41 public InputStream getInputStream(final URL u) { 42 return new ByteArrayInputStream (FILE); 43 } 44 45 public OutputStream getOutputStream(final URL u) { 46 throw new UnsupportedOperationException (); 47 } 48 49 public int getContentLength(final URL u) { 50 return FILE.length; 51 } 52 }; 53 54 final EtlExecutor se = newEtlExecutor(); 55 se.execute(); 56 57 QueryHelper q = new QueryHelper("select (select count(id) from t), c from t"); 58 q.execute(con, 59 new QueryCallback() { 60 public void processRow(final ParametersCallback rowEvaluator) { 61 final byte b[] = (byte[]) rowEvaluator.getParameter("c"); 62 assertTrue(Arrays.equals(FILE, b)); 63 assertEquals(3, rowEvaluator.getParameter("1")); } 65 }); 66 } 67 } 68 | Popular Tags |