| 1 package com.quadcap.pop3.client; 2 3 40 41 import java.io.*; 42 import java.util.*; 43 44 import com.quadcap.util.Debug; 45 import com.quadcap.util.Util; 46 47 52 public class Test { 53 54 static void show(String label, InputStream is) throws IOException { 55 int ch = 0; 56 boolean eol = true; 57 while ((ch = is.read()) >= 0) { 58 if (eol) System.out.print(label); 59 eol = (ch == '\n'); 60 System.out.write(ch); 61 } 62 System.out.println(""); 63 } 64 65 66 static void show(Vector v) throws IOException { 67 Enumeration e = v.elements(); 68 System.out.write('{'); 69 while (e.hasMoreElements()) { 70 System.out.write(Util.bytes(e.nextElement().toString())); 71 } 72 System.out.write('}'); 73 } 74 75 76 public static void test0(String args[]) throws Exception { 77 System.out.println("test0"); 78 Session c = new Session("localhost", 110); 79 c.connect(); 80 c.user("stan"); 81 c.pass("stan"); 82 show("[LIST] ", c.list()); 83 show(c.list("1")); 84 show(c.list("2")); 85 show(c.stat()); 86 show("[UIDL ]", c.uidl()); 87 show(c.uidl("2")); 88 show("[RETR 1] ", c.retr("1")); 89 show("[TOP] ", c.top("1", 0)); 90 show("[LIST] ", c.list()); 92 c.rset(); 93 show("[LIST ]", c.list()); 94 c.quit(); 95 } 96 97 public static void main(String args[]) { 98 String t = System.getProperty("tests"); 99 Debug.debugMode = Debug.debugAll; 100 Debug.printLevel = 5; 101 try { 102 if (t.indexOf("0") >= 0) test0(args); 103 } catch (Exception e) { 104 Debug.print(e); 105 } 106 } 107 } 108 | Popular Tags |