1 36 package org.columba.ristretto.log; 37 38 import java.io.ByteArrayOutputStream ; 39 import java.io.IOException ; 40 import java.io.OutputStream ; 41 import java.util.Arrays ; 42 43 import junit.framework.TestCase; 44 45 public class LogOutputStreamTest extends TestCase { 46 47 public void test1() throws IOException { 48 byte[] result = "C: This is a simple line".getBytes(); 49 byte[] test = "This is a simple line".getBytes(); 50 ByteArrayOutputStream log = new ByteArrayOutputStream (); 51 ByteArrayOutputStream out = new ByteArrayOutputStream (); 52 53 OutputStream logStream = new LogOutputStream( out, log); 54 55 logStream.write(test); 56 57 assertTrue( Arrays.equals( result, log.toByteArray())); 58 } 59 60 public void test2() throws IOException { 61 byte[] result = "C: This is a multiple\nC: line".getBytes(); 62 byte[] test = "This is a multiple\nline".getBytes(); 63 ByteArrayOutputStream log = new ByteArrayOutputStream (); 64 ByteArrayOutputStream out = new ByteArrayOutputStream (); 65 66 OutputStream logStream = new LogOutputStream( out, log); 67 68 logStream.write(test); 69 70 assertTrue( Arrays.equals( result, log.toByteArray())); 71 } 72 73 public void test3() throws IOException { 74 byte[] result = "C: This is a multiple\nC: line\n".getBytes(); 75 byte[] test = "This is a multiple\nline\n".getBytes(); 76 ByteArrayOutputStream log = new ByteArrayOutputStream (); 77 ByteArrayOutputStream out = new ByteArrayOutputStream (); 78 79 OutputStream logStream = new LogOutputStream( out, log); 80 81 logStream.write(test); 82 83 assertTrue( Arrays.equals( result, log.toByteArray())); 84 } 85 86 87 88 } 89 | Popular Tags |