1 36 package org.columba.ristretto.coder; 37 38 import java.io.ByteArrayInputStream ; 39 import java.io.InputStream ; 40 41 import junit.framework.TestCase; 42 43 public class QuotedPrintableEncoderInputStreamTest extends TestCase { 44 45 public void testEncodedNone() throws Exception { 46 String input = "This is a\tTest"; 47 assertTrue(runEncoder(input).equals("This is a\tTest")); 48 } 49 50 public void testEncodedSimple() throws Exception { 51 String input = "This is a \u00dcest"; 52 assertTrue(runEncoder(input).equals("This is a =DCest")); 53 } 54 55 public void testEncodedWSBreak() throws Exception { 56 String input = "This is a \n\u00dcest "; 57 assertTrue(runEncoder(input).equals("This is a=20\r\n=DCest=20")); 58 } 59 60 public void testEncodedLongline() throws Exception { 61 String input = "This is a very long line that has in total some f\u00fcnfundsiebzig +1 characters"; 62 assertTrue(runEncoder(input).equals("This is a very long line that has in total some f=FCnfundsiebzig +1 charac=\r\nters")); 63 } 64 65 public void testVeryLongLine() throws Exception { 66 String input = "\n"+ 67 "> Kann sie als Word unm\u00e4glich per Mail schicken. Die screenshots und Quellcodes m\u00e4ssen ja komplett angeglichen werden. Entweder dann bei Euch \u00e4ber Standleitung runterziehen oder Netzwerk???\n"+ 68 ">\n\n"+ 69 "Test"; 70 runEncoder(input); 71 } 72 73 private String runEncoder(String input) throws Exception { 74 InputStream in = new QuotedPrintableEncoderInputStream( new ByteArrayInputStream ( input.getBytes("ISO-8859-1"))); 75 76 StringBuffer result = new StringBuffer (); 77 int next = in.read(); 78 while( next != -1 ) { 79 result.append((char) next); 80 next = in.read(); 81 } 82 in.close(); 83 return result.toString(); 84 } 85 } 86 | Popular Tags |