1 16 package scriptella.driver.text; 17 18 import scriptella.AbstractTestCase; 19 import scriptella.execution.EtlExecutor; 20 import scriptella.execution.EtlExecutorException; 21 22 import java.io.ByteArrayInputStream ; 23 import java.io.ByteArrayOutputStream ; 24 import java.io.InputStream ; 25 import java.io.OutputStream ; 26 import java.io.UnsupportedEncodingException ; 27 import java.net.URL ; 28 29 35 public class TextScriptITest extends AbstractTestCase { 36 private ByteArrayOutputStream o1; 37 private ByteArrayOutputStream o2; 38 39 protected void setUp() throws Exception { 40 41 testURLHandler = new TestURLHandler() { 42 public InputStream getInputStream(final URL u) { 43 if (u.toString().endsWith("2")) { 44 throw new UnsupportedOperationException (); 45 } 46 return new ByteArrayInputStream ("a1\nb22b\n\rc333c".getBytes()); 47 } 48 49 public OutputStream getOutputStream(final URL u) { 50 if (u.toString().endsWith("2")) { 51 return o2 = new ByteArrayOutputStream (); 52 } else { 53 return o1 = new ByteArrayOutputStream (); 54 } 55 } 56 57 public int getContentLength(final URL u) { 58 return -1; 59 } 60 }; 61 } 62 63 64 public void test() throws EtlExecutorException, UnsupportedEncodingException { 65 EtlExecutor e = newEtlExecutor(); 66 e.execute(); 67 assertNotNull(o1); 68 assertEquals("Test Trim\n", new String (o1.toByteArray())); 69 assertNotNull(o2); 70 assertEquals("n1\rn22\rn333\r", new String (o2.toByteArray())); 71 72 } 73 74 } 75 | Popular Tags |