1 36 package org.columba.ristretto.imap.protocol; 37 38 import java.io.ByteArrayInputStream ; 39 import java.io.IOException ; 40 import java.io.InputStream ; 41 import java.io.SequenceInputStream ; 42 import java.util.Random ; 43 44 import junit.framework.TestCase; 45 46 import org.columba.ristretto.concurrency.Mutex; 47 import org.columba.ristretto.imap.IMAPDownloadThread; 48 import org.columba.ristretto.io.AsyncInputStream; 49 50 public class DownloadThreadTest extends TestCase { 51 byte[] test = new byte[100350]; 52 53 54 public void test1() throws IOException { 55 byte[] result = new byte[100350]; 56 String rest = "\r\n\r\n"; 57 InputStream source = new SequenceInputStream ( new ByteArrayInputStream ( test ), new ByteArrayInputStream ( rest.getBytes("US-ASCII"))); 58 59 AsyncInputStream in = IMAPDownloadThread.asyncDownload(source, 100350, new Mutex()); 60 61 for( int i=0; i<100350; i++) { 62 assertEquals(in.available(), test.length - i); 64 assertEquals(test[i], (byte) in.read()); 65 } 66 } 67 68 69 72 protected void setUp() throws Exception { 73 Random r = new Random (); 74 r.nextBytes(test); 75 } 76 } 77 | Popular Tags |