001: package com.quadcap.pop3.client;
002:
003: /* Copyright 1997 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.io.*;
042: import java.util.*;
043:
044: import com.quadcap.util.Debug;
045: import com.quadcap.util.Util;
046:
047: /**
048: * Package level tests.
049: *
050: * @author Stan Bailes
051: */
052: public class Test {
053: /** For debugging, dump the multi-line response to System.out */
054: static void show(String label, InputStream is) throws IOException {
055: int ch = 0;
056: boolean eol = true;
057: while ((ch = is.read()) >= 0) {
058: if (eol)
059: System.out.print(label);
060: eol = (ch == '\n');
061: System.out.write(ch);
062: }
063: System.out.println("");
064: }
065:
066: /** For debugging, dump the parsed response line to System.out */
067: static void show(Vector v) throws IOException {
068: Enumeration e = v.elements();
069: System.out.write('{');
070: while (e.hasMoreElements()) {
071: System.out.write(Util.bytes(e.nextElement().toString()));
072: }
073: System.out.write('}');
074: }
075:
076: /** 'Session' class sanity testing. */
077: public static void test0(String args[]) throws Exception {
078: System.out.println("test0");
079: Session c = new Session("localhost", 110);
080: c.connect();
081: c.user("stan");
082: c.pass("stan");
083: show("[LIST] ", c.list());
084: show(c.list("1"));
085: show(c.list("2"));
086: show(c.stat());
087: show("[UIDL ]", c.uidl());
088: show(c.uidl("2"));
089: show("[RETR 1] ", c.retr("1"));
090: show("[TOP] ", c.top("1", 0));
091: //show(c.dele(1));
092: show("[LIST] ", c.list());
093: c.rset();
094: show("[LIST ]", c.list());
095: c.quit();
096: }
097:
098: public static void main(String args[]) {
099: String t = System.getProperty("tests");
100: Debug.debugMode = Debug.debugAll;
101: Debug.printLevel = 5;
102: try {
103: if (t.indexOf("0") >= 0)
104: test0(args);
105: } catch (Exception e) {
106: Debug.print(e);
107: }
108: }
109: }
|