geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r421852 [12/15] - in /geronimo/specs/trunk: ./ geronimo-spec-j2ee/ geronimo-spec-javamail-1.3.1/ geronimo-spec-javamail-1.3.1/src/ geronimo-spec-javamail-1.4/ geronimo-spec-javamail-1.4/src/ geronimo-spec-javamail-1.4/src/main/ geronimo-spe...
Date Fri, 14 Jul 2006 10:02:29 GMT
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,275 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * An implementation of a FilterOutputStream that decodes the
+ * stream data in UU encoding format.  This version does the
+ * decoding "on the fly" rather than decoding a single block of
+ * data.  Since this version is intended for use by the MimeUtilty class,
+ * it also handles line breaks in the encoded data.
+ */
+public class UUDecoderStream extends FilterInputStream {
+    // maximum number of chars that can appear in a single line
+    protected static final int MAX_CHARS_PER_LINE = 45;
+
+    // our decoder for processing the data
+    protected UUEncoder decoder = new UUEncoder();
+
+    // a buffer for one decoding unit's worth of data (45 bytes).
+    protected byte[] decodedChars;
+    // count of characters in the buffer
+    protected int decodedCount = 0;
+    // index of the next decoded character
+    protected int decodedIndex = 0;
+
+    // indicates whether we've already processed the "begin" prefix.
+    protected boolean beginRead = false;
+
+
+    public UUDecoderStream(InputStream in) {
+        super(in);
+    }
+
+
+    /**
+     * Test for the existance of decoded characters in our buffer
+     * of decoded data.
+     *
+     * @return True if we currently have buffered characters.
+     */
+    private boolean dataAvailable() {
+        return decodedCount != 0;
+    }
+
+    /**
+     * Get the next buffered decoded character.
+     *
+     * @return The next decoded character in the buffer.
+     */
+    private byte getBufferedChar() {
+        decodedCount--;
+        return decodedChars[decodedIndex++];
+    }
+
+    /**
+     * Decode a requested number of bytes of data into a buffer.
+     *
+     * @return true if we were able to obtain more data, false otherwise.
+     */
+    private boolean decodeStreamData() throws IOException {
+        decodedIndex = 0;
+
+        // fill up a data buffer with input data
+        return fillEncodedBuffer() != -1;
+    }
+
+
+    /**
+     * Retrieve a single byte from the decoded characters buffer.
+     *
+     * @return The decoded character or -1 if there was an EOF condition.
+     */
+    private int getByte() throws IOException {
+        if (!dataAvailable()) {
+            if (!decodeStreamData()) {
+                return -1;
+            }
+        }
+        decodedCount--;
+        return decodedChars[decodedIndex++];
+    }
+
+    private int getBytes(byte[] data, int offset, int length) throws IOException {
+
+        int readCharacters = 0;
+        while (length > 0) {
+            // need data?  Try to get some
+            if (!dataAvailable()) {
+                // if we can't get this, return a count of how much we did get (which may be -1).
+                if (!decodeStreamData()) {
+                    return readCharacters > 0 ? readCharacters : -1;
+                }
+            }
+
+            // now copy some of the data from the decoded buffer to the target buffer
+            int copyCount = Math.min(decodedCount, length);
+            System.arraycopy(decodedChars, decodedIndex, data, offset, copyCount);
+            decodedIndex += copyCount;
+            decodedCount -= copyCount;
+            offset += copyCount;
+            length -= copyCount;
+            readCharacters += copyCount;
+        }
+        return readCharacters;
+    }
+
+    /**
+     * Verify that the first line of the buffer is a valid begin
+     * marker.
+     *
+     * @exception IOException
+     */
+    private void checkBegin() throws IOException {
+        // we only do this the first time we're requested to read from the stream.
+        if (beginRead) {
+            return;
+        }
+
+        // we might have to skip over lines to reach the marker.  If we hit the EOF without finding
+        // the begin, that's an error.
+        while (true) {
+            String line = readLine();
+            if (line == null) {
+                throw new IOException("Missing UUEncode begin command");
+            }
+
+            // is this our begin?
+            if (line.regionMatches(true, 0, "begin ", 0, 6)) {
+                // This is the droid we're looking for.....
+                beginRead = true;
+                return;
+            }
+        }
+    }
+
+
+    /**
+     * Read a line of data.  Returns null if there is an EOF.
+     *
+     * @return The next line read from the stream.  Returns null if we
+     *         hit the end of the stream.
+     * @exception IOException
+     */
+    protected String readLine() throws IOException {
+        decodedIndex = 0;
+        // get an accumulator for the data
+        StringBuffer buffer = new StringBuffer();
+
+        // now process a character at a time.
+        int ch = in.read();
+        while (ch != -1) {
+            // a naked new line completes the line.
+            if (ch == '\n') {
+                break;
+            }
+            // a carriage return by itself is ignored...we're going to assume that this is followed
+            // by a new line because we really don't have the capability of pushing this back .
+            else if (ch == '\r') {
+                ;
+            }
+            else {
+                // add this to our buffer
+                buffer.append((char)ch);
+            }
+            ch = in.read();
+        }
+
+        // if we didn't get any data at all, return nothing
+        if (ch == -1 && buffer.length() == 0) {
+            return null;
+        }
+        // convert this into a string.
+        return buffer.toString();
+    }
+
+
+    /**
+     * Fill our buffer of input characters for decoding from the
+     * stream.  This will attempt read a full buffer, but will
+     * terminate on an EOF or read error.  This will filter out
+     * non-Base64 encoding chars and will only return a valid
+     * multiple of 4 number of bytes.
+     *
+     * @return The count of characters read.
+     */
+    private int fillEncodedBuffer() throws IOException
+    {
+        checkBegin();
+        // reset the buffer position
+        decodedIndex = 0;
+
+        while (true) {
+
+            // we read these as character lines.  We need to be looking for the "end" marker for the
+            // end of the data.
+            String line = readLine();
+
+            // this should NOT be happening....
+            if (line == null) {
+                throw new IOException("Missing end in UUEncoded data");
+            }
+
+            // Is this the end marker?  EOF baby, EOF!
+            if (line.equalsIgnoreCase("end")) {
+                // this indicates we got nuttin' more to do.
+                return -1;
+            }
+
+            ByteArrayOutputStream out = new ByteArrayOutputStream(MAX_CHARS_PER_LINE);
+
+            byte [] lineBytes;
+            try {
+                lineBytes = line.getBytes("US-ASCII");
+            } catch (UnsupportedEncodingException e) {
+                throw new IOException("Invalid UUEncoding");
+            }
+
+            // decode this line
+            decodedCount = decoder.decode(lineBytes, 0, lineBytes.length, out);
+
+            // not just a zero-length line?
+            if (decodedCount != 0) {
+                // get the resulting byte array
+                decodedChars = out.toByteArray();
+                return decodedCount;
+            }
+        }
+    }
+
+
+    // in order to function as a filter, these streams need to override the different
+    // read() signature.
+
+    public int read() throws IOException
+    {
+        return getByte();
+    }
+
+
+    public int read(byte [] buffer, int offset, int length) throws IOException {
+        return getBytes(buffer, offset, length);
+    }
+
+
+    public boolean markSupported() {
+        return false;
+    }
+
+
+    public int available() throws IOException {
+        return ((in.available() / 4) * 3) + decodedCount;
+    }
+}
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUDecoderStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,147 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class UUEncode {
+    private static final Encoder encoder = new UUEncoder();
+
+    /**
+     * encode the input data producing a UUEncoded byte array.
+     *
+     * @return a byte array containing the UUEncoded data.
+     */
+    public static byte[] encode(
+        byte[]    data)
+    {
+        return encode(data, 0, data.length);
+    }
+
+    /**
+     * encode the input data producing a UUEncoded byte array.
+     *
+     * @return a byte array containing the UUEncoded data.
+     */
+    public static byte[] encode(
+        byte[]    data,
+        int       off,
+        int       length)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.encode(data, off, length, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception encoding UUEncoded string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * UUEncode the byte data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int encode(
+        byte[]         data,
+        OutputStream   out)
+        throws IOException
+    {
+        return encoder.encode(data, 0, data.length, out);
+    }
+
+    /**
+     * UUEncode the byte data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int encode(
+        byte[]         data,
+        int            off,
+        int            length,
+        OutputStream   out)
+        throws IOException
+    {
+        return encoder.encode(data, 0, data.length, out);
+    }
+
+    /**
+     * decode the UUEncoded input data. It is assumed the input data is valid.
+     *
+     * @return a byte array representing the decoded data.
+     */
+    public static byte[] decode(
+        byte[]    data)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.decode(data, 0, data.length, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception decoding UUEncoded string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * decode the UUEncided String data.
+     *
+     * @return a byte array representing the decoded data.
+     */
+    public static byte[] decode(
+        String    data)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.decode(data, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception decoding UUEncoded string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * decode the UUEncoded encoded String data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int decode(
+        String          data,
+        OutputStream    out)
+        throws IOException
+    {
+        return encoder.decode(data, out);
+    }
+}
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,241 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+public class UUEncoder implements Encoder {
+
+    // this is the maximum number of chars allowed per line, since we have to include a uuencoded length at
+    // the start of each line.
+    static private final int MAX_CHARS_PER_LINE = 45;
+
+
+    public UUEncoder()
+    {
+    }
+
+    /**
+     * encode the input data producing a UUEncoded output stream.
+     *
+     * @param data   The array of byte data.
+     * @param off    The starting offset within the data.
+     * @param length Length of the data to encode.
+     * @param out    The output stream the encoded data is written to.
+     *
+     * @return the number of bytes produced.
+     */
+    public int encode(byte[] data, int off, int length, OutputStream out) throws IOException
+    {
+        int byteCount = 0;
+
+        while (true) {
+            // keep writing complete lines until we've exhausted the data.
+            if (length > MAX_CHARS_PER_LINE) {
+                // encode another line and adjust the length and position
+                byteCount += encodeLine(data, off, MAX_CHARS_PER_LINE, out);
+                length -= MAX_CHARS_PER_LINE;
+                off += MAX_CHARS_PER_LINE;
+            }
+            else {
+                // last line.  Encode the partial and quit
+                byteCount += encodeLine(data, off, MAX_CHARS_PER_LINE, out);
+                break;
+            }
+        }
+        return byteCount;
+    }
+
+
+    /**
+     * Encode a single line of data (less than or equal to 45 characters).
+     *
+     * @param data   The array of byte data.
+     * @param off    The starting offset within the data.
+     * @param length Length of the data to encode.
+     * @param out    The output stream the encoded data is written to.
+     *
+     * @return The number of bytes written to the output stream.
+     * @exception IOException
+     */
+    private int encodeLine(byte[] data, int offset, int length, OutputStream out) throws IOException {
+        // write out the number of characters encoded in this line.
+        out.write((byte)((length & 0x3F) + ' '));
+        byte a;
+        byte b;
+        byte c;
+
+        // count the bytes written...we add 2, one for the length and 1 for the linend terminator.
+        int bytesWritten = 2;
+
+        for (int i = 0; i < length;) {
+            // set the padding defauls
+            b = 1;
+            c = 1;
+            // get the next 3 bytes (if we have them)
+            a = data[offset + i++];
+            if (i < length) {
+                b = data[offset + i++];
+                if (i < length) {
+                    c = data[offset + i++];
+                }
+            }
+
+            byte d1 = (byte)(((a >>> 2) & 0x3F) + ' ');
+            byte d2 = (byte)(((( a << 4) & 0x30) | ((b >>> 4) & 0x0F)) + ' ');
+            byte d3 = (byte)((((b << 2) & 0x3C) | ((c >>> 6) & 0x3)) + ' ');
+            byte d4 = (byte)((c & 0x3F) + ' ');
+
+            out.write(d1);
+            out.write(d2);
+            out.write(d3);
+            out.write(d4);
+
+            bytesWritten += 4;
+        }
+
+        // terminate with a linefeed alone
+        out.write('\n');
+
+        return bytesWritten;
+    }
+
+
+    /**
+     * decode the uuencoded byte data writing it to the given output stream
+     *
+     * @param data   The array of byte data to decode.
+     * @param off    Starting offset within the array.
+     * @param length The length of data to encode.
+     * @param out    The output stream used to return the decoded data.
+     *
+     * @return the number of bytes produced.
+     * @exception IOException
+     */
+    public int decode(byte[] data, int off, int length, OutputStream out) throws IOException
+    {
+        int bytesWritten = 0;
+
+        while (length > 0) {
+            int lineOffset = off;
+
+            // scan forward looking for a EOL terminator for the next line of data.
+            while (length > 0 && data[off] != '\n') {
+                off++;
+                length--;
+            }
+
+            // go decode this line of data
+            bytesWritten += decodeLine(data, lineOffset, off - lineOffset, out);
+
+            // the offset was left pointing at the EOL character, so step over that one before
+            // scanning again.
+            off++;
+            length--;
+        }
+        return bytesWritten;
+    }
+
+
+    /**
+     * decode a single line of uuencoded byte data writing it to the given output stream
+     *
+     * @param data   The array of byte data to decode.
+     * @param off    Starting offset within the array.
+     * @param length The length of data to decode (length does NOT include the terminating new line).
+     * @param out    The output stream used to return the decoded data.
+     *
+     * @return the number of bytes produced.
+     * @exception IOException
+     */
+    private int decodeLine(byte[] data, int off, int length, OutputStream out) throws IOException {
+        int count = data[off++];
+
+        // obtain and validate the count
+        if (count < ' ') {
+            throw new IOException("Invalid UUEncode line length");
+        }
+
+        count = (count - ' ') & 0x3F;
+
+        // get the rounded count of characters that should have been used to encode this.  The + 1 is for the
+        // length encoded at the beginning
+        int requiredLength = (((count * 8) + 5) / 6) + 1;
+        if (length < requiredLength) {
+            throw new IOException("UUEncoded data and length do not match");
+        }
+
+        int bytesWritten = 0;
+        // now decode the bytes.
+        while (bytesWritten < count) {
+            // even one byte of data requires two bytes to encode, so we should have that.
+            byte a = (byte)((data[off++] - ' ') & 0x3F);
+            byte b = (byte)((data[off++] - ' ') & 0x3F);
+            byte c = 0;
+            byte d = 0;
+
+            // do the first byte
+            byte first = (byte)(((a << 2) & 0xFC) | ((b >>> 4) & 3));
+            out.write(first);
+            bytesWritten++;
+
+            // still have more bytes to decode? do the second byte of the second.  That requires
+            // a third byte from the data.
+            if (bytesWritten < count) {
+                c = (byte)((data[off++] - ' ') & 0x3F);
+                byte second = (byte)(((b << 4) & 0xF0) | ((c >>> 2) & 0x0F));
+                out.write(second);
+                bytesWritten++;
+
+                // need the third one?
+                if (bytesWritten < count) {
+                    d = (byte)((data[off++] - ' ') & 0x3F);
+                    byte third = (byte)(((c << 6) & 0xC0) | (d & 0x3F));
+                    out.write(third);
+                    bytesWritten++;
+                }
+            }
+        }
+        return bytesWritten;
+    }
+
+
+    /**
+     * decode the UUEncoded String data writing it to the given output stream.
+     *
+     * @param data   The String data to decode.
+     * @param out    The output stream to write the decoded data to.
+     *
+     * @return the number of bytes produced.
+     * @exception IOException
+     */
+    public int decode(String data, OutputStream out) throws IOException
+    {
+        try {
+            // just get the byte data and decode.
+            byte[] bytes = data.getBytes("US-ASCII");
+            return decode(bytes, 0, bytes.length, out);
+        } catch (UnsupportedEncodingException e) {
+            throw new IOException("Invalid UUEncoding");
+        }
+    }
+}
+
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,201 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * An implementation of a FilterOutputStream that encodes the
+ * stream data in UUencoding format.  This version does the
+ * encoding "on the fly" rather than encoding a single block of
+ * data.  Since this version is intended for use by the MimeUtilty class,
+ * it also handles line breaks in the encoded data.
+ */
+public class UUEncoderStream extends FilterOutputStream {
+
+    // default values included on the "begin" prefix of the data stream.
+    protected static final int DEFAULT_MODE = 644;
+    protected static final String DEFAULT_NAME = "encoder.buf";
+
+    protected static final int MAX_CHARS_PER_LINE = 45;
+
+    // the configured name on the "begin" command.
+    protected String name;
+    // the configured mode for the "begin" command.
+    protected int mode;
+
+    // since this is a filtering stream, we need to wait until we have the first byte written for encoding
+    // to write out the "begin" marker.  A real pain, but necessary.
+    protected boolean beginWritten = false;
+
+
+    // our encoder utility class.
+    protected UUEncoder encoder = new UUEncoder();
+
+    // Data is generally written out in 45 character lines, so we're going to buffer that amount before
+    // asking the encoder to process this.
+
+    // the buffered byte count
+    protected int bufferedBytes = 0;
+
+    // we'll encode this part once it is filled up.
+    protected byte[] buffer = new byte[45];
+
+    /**
+     * Create a Base64 encoder stream that wraps a specifed stream
+     * using the default line break size.
+     *
+     * @param out    The wrapped output stream.
+     */
+    public UUEncoderStream(OutputStream out) {
+        this(out, DEFAULT_NAME, DEFAULT_MODE);
+    }
+
+
+    /**
+     * Create a Base64 encoder stream that wraps a specifed stream
+     * using the default line break size.
+     *
+     * @param out    The wrapped output stream.
+     * @param name   The filename placed on the "begin" command.
+     */
+    public UUEncoderStream(OutputStream out, String name) {
+        this(out, name, DEFAULT_MODE);
+    }
+
+
+    public UUEncoderStream(OutputStream out, String name, int mode) {
+        super(out);
+        // fill in the name and mode information.
+        this.name = name;
+        this.mode = mode;
+    }
+
+
+    private void checkBegin() throws IOException {
+        if (!beginWritten) {
+            // grumble...OutputStream doesn't directly support writing String data.  We'll wrap this in
+            // a PrintStream() to accomplish the task of writing the begin command.
+
+            PrintStream writer = new PrintStream(out);
+            // write out the stream with a CRLF marker
+            writer.print("begin " + mode + " " + name + "\r\n");
+            writer.flush();
+            beginWritten = true;
+        }
+    }
+
+    private void writeEnd() throws IOException {
+        PrintStream writer = new PrintStream(out);
+        // write out the stream with a CRLF marker
+        writer.print("\nend\r\n");
+        writer.flush();
+    }
+
+    private void flushBuffer() throws IOException {
+        // make sure we've written the begin marker first
+        checkBegin();
+        // ask the encoder to encode and write this out.
+        if (bufferedBytes != 0) {
+            encoder.encode(buffer, 0, bufferedBytes, out);
+            // reset the buffer count
+            bufferedBytes = 0;
+        }
+    }
+
+    private int bufferSpace() {
+        return MAX_CHARS_PER_LINE - bufferedBytes;
+    }
+
+    private boolean isBufferFull() {
+        return bufferedBytes >= MAX_CHARS_PER_LINE;
+    }
+
+
+    // in order for this to work, we need to override the 3 different signatures for write
+
+    public void write(int ch) throws IOException {
+        // store this in the buffer.
+        buffer[bufferedBytes++] = (byte)ch;
+
+        // if we filled this up, time to encode and write to the output stream.
+        if (isBufferFull()) {
+            flushBuffer();
+        }
+    }
+
+    public void write(byte [] data) throws IOException {
+        write(data, 0, data.length);
+    }
+
+    public void write(byte [] data, int offset, int length) throws IOException {
+        // first check to see how much space we have left in the buffer, and copy that over
+        int copyBytes = Math.min(bufferSpace(), length);
+
+        System.arraycopy(buffer, bufferedBytes, data, offset, copyBytes);
+        bufferedBytes += copyBytes;
+        offset += copyBytes;
+        length -= copyBytes;
+
+        // if we filled this up, time to encode and write to the output stream.
+        if (isBufferFull()) {
+            flushBuffer();
+        }
+
+        // we've flushed the leading part up to the line break.  Now if we have complete lines
+        // of data left, we can have the encoder process all of these lines directly.
+        if (length >= MAX_CHARS_PER_LINE) {
+            int fullLinesLength = (length / MAX_CHARS_PER_LINE) * MAX_CHARS_PER_LINE;
+            // ask the encoder to encode and write this out.
+            encoder.encode(data, offset, fullLinesLength, out);
+            offset += fullLinesLength;
+            length -= fullLinesLength;
+        }
+
+        // ok, now we're down to a potential trailing bit we need to move into the
+        // buffer for later processing.
+
+        if (length > 0) {
+            System.arraycopy(buffer, 0, data, offset, length);
+            bufferedBytes += length;
+            offset += length;
+            length -= length;
+        }
+    }
+
+    public void flush() throws IOException {
+        // flush any unencoded characters we're holding.
+        flushBuffer();
+        // write out the data end marker
+        writeEnd();
+        // and flush the output stream too so that this data is available.
+        out.flush();
+    }
+
+    public void close() throws IOException {
+        // flush all of the streams and close the target output stream.
+        flush();
+        out.close();
+    }
+
+}
+
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/UUEncoderStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,164 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Encoder for RFC1891 xtext.
+ *
+ * xtext strings are defined as
+ *
+ *    xtext = *( xchar / hexchar )
+ *
+ * where
+ *
+ *    xchar is any ASCII character in the range 33-126, EXCEPT
+ *    the characters "+" and "=".
+ *
+ *    hexchar is an ASCII "+" followed by two upper case
+ *    hexadecimal digits.
+ */
+public class XText
+{
+    private static final Encoder encoder = new XTextEncoder();
+
+    /**
+     * encode the input data producing an xtext  encoded byte array.
+     *
+     * @return a byte array containing the xtext encoded data.
+     */
+    public static byte[] encode(
+        byte[]    data)
+    {
+        return encode(data, 0, data.length);
+    }
+
+    /**
+     * encode the input data producing an xtext encoded byte array.
+     *
+     * @return a byte array containing the xtext encoded data.
+     */
+    public static byte[] encode(
+        byte[]    data,
+        int       off,
+        int       length)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.encode(data, off, length, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception encoding xtext string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * xtext encode the byte data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int encode(
+        byte[]         data,
+        OutputStream   out)
+        throws IOException
+    {
+        return encoder.encode(data, 0, data.length, out);
+    }
+
+    /**
+     * extext encode the byte data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int encode(
+        byte[]         data,
+        int            off,
+        int            length,
+        OutputStream   out)
+        throws IOException
+    {
+        return encoder.encode(data, 0, data.length, out);
+    }
+
+    /**
+     * decode the xtext encoded input data. It is assumed the input data is valid.
+     *
+     * @return a byte array representing the decoded data.
+     */
+    public static byte[] decode(
+        byte[]    data)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.decode(data, 0, data.length, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception decoding xtext string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * decode the xtext encoded String data - whitespace will be ignored.
+     *
+     * @return a byte array representing the decoded data.
+     */
+    public static byte[] decode(
+        String    data)
+    {
+        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
+
+        try
+        {
+            encoder.decode(data, bOut);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("exception decoding xtext string: " + e);
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * decode the xtext encoded String data writing it to the given output stream,
+     * whitespace characters will be ignored.
+     *
+     * @return the number of bytes produced.
+     */
+    public static int decode(
+        String          data,
+        OutputStream    out)
+        throws IOException
+    {
+        return encoder.decode(data, out);
+    }
+}
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XText.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,159 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.mail.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class XTextEncoder
+    implements Encoder
+{
+    protected final byte[] encodingTable =
+        {
+            (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7',
+            (byte)'8', (byte)'9', (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F'
+        };
+
+    /*
+     * set up the decoding table.
+     */
+    protected final byte[] decodingTable = new byte[128];
+
+    protected void initialiseDecodingTable()
+    {
+        for (int i = 0; i < encodingTable.length; i++)
+        {
+            decodingTable[encodingTable[i]] = (byte)i;
+        }
+    }
+
+    public XTextEncoder()
+    {
+        initialiseDecodingTable();
+    }
+
+    /**
+     * encode the input data producing an XText output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public int encode(
+        byte[]                data,
+        int                    off,
+        int                    length,
+        OutputStream    out)
+        throws IOException
+    {
+        int bytesWritten = 0;
+
+        for (int i = off; i < (off + length); i++)
+        {
+            int    v = data[i] & 0xff;
+            // character tha must be encoded?  Prefix with a '+' and encode in hex.
+            if (v < 33 || v > 126 || v == '+' || v == '+') {
+                out.write((byte)'+');
+                out.write(encodingTable[(v >>> 4)]);
+                out.write(encodingTable[v & 0xf]);
+                bytesWritten += 3;
+            }
+            else {
+                // add unchanged.
+                out.write((byte)v);
+                bytesWritten++;
+            }
+        }
+
+        return bytesWritten;
+    }
+
+
+    /**
+     * decode the xtext encoded byte data writing it to the given output stream
+     *
+     * @return the number of bytes produced.
+     */
+    public int decode(
+        byte[]                data,
+        int                    off,
+        int                    length,
+        OutputStream    out)
+        throws IOException
+    {
+        byte[]    bytes;
+        byte    b1, b2;
+        int        outLen = 0;
+
+        int        end = off + length;
+
+        int i = off;
+        while (i < end)
+        {
+            byte v = data[i++];
+            // a plus is a hex character marker, need to decode a hex value.
+            if (v == '+') {
+                b1 = decodingTable[data[i++]];
+                b2 = decodingTable[data[i++]];
+                out.write((b1 << 4) | b2);
+            }
+            else {
+                // copied over unchanged.
+                out.write(v);
+            }
+            // always just one byte added
+            outLen++;
+        }
+
+        return outLen;
+    }
+
+    /**
+     * decode the xtext encoded String data writing it to the given output stream.
+     *
+     * @return the number of bytes produced.
+     */
+    public int decode(
+        String                data,
+        OutputStream    out)
+        throws IOException
+    {
+        byte[]    bytes;
+        byte    b1, b2, b3, b4;
+        int        length = 0;
+
+        int        end = data.length();
+
+        int i = 0;
+        while (i < end)
+        {
+            char v = data.charAt(i++);
+            if (v == '+') {
+                b1 = decodingTable[data.charAt(i++)];
+                b2 = decodingTable[data.charAt(i++)];
+
+                out.write((b1 << 4) | b2);
+            }
+            else {
+                out.write((byte)v);
+            }
+            length++;
+        }
+
+        return length;
+    }
+}
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/org/apache/geronimo/mail/util/XTextEncoder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/default.address.map
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/default.address.map?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/default.address.map (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/default.address.map Fri Jul 14 03:02:19 2006
@@ -0,0 +1,25 @@
+##
+##
+##   Copyright 2006 The Apache Software Foundation
+##
+##   Licensed under the Apache License, Version 2.0 (the "License");
+##   you may not use this file except in compliance with the License.
+##   You may obtain a copy of the License at
+##
+##       http://www.apache.org/licenses/LICENSE-2.0
+##
+##   Unless required by applicable law or agreed to in writing, software
+##   distributed under the License is distributed on an "AS IS" BASIS,
+##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##   See the License for the specific language governing permissions and
+##   limitations under the License.
+##
+
+##
+## $Rev: 383149 $ $Date: 2006-03-04 11:11:08 -0500 (Sat, 04 Mar 2006) $
+##
+
+# only the single mapping for smtp is defined.
+rfc822=smtp
+
+

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/javamail.charset.map
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/javamail.charset.map?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/javamail.charset.map (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/javamail.charset.map Fri Jul 14 03:02:19 2006
@@ -0,0 +1,55 @@
+### Character set mapping table loaded and used by the javax.mail.internet.MimeUtility class.
+
+### java character sets to MIME character set map.  This must be the first table.
+
+8859_1		ISO-8859-1
+iso8859_1	ISO-8859-1
+
+8859_2		ISO-8859-2
+iso8859_2	ISO-8859-2
+
+8859_3		ISO-8859-3
+iso8859_3	ISO-8859-3
+
+8859_4		ISO-8859-4
+iso8859_4	ISO-8859-4
+
+8859_5		ISO-8859-5
+iso8859_5	ISO-8859-5
+
+8859_6		ISO-8859-6
+iso8859_6	ISO-8859-6
+
+8859_7		ISO-8859-7
+iso8859_7	ISO-8859-7
+
+8859_8		ISO-8859-8
+iso8859_8	ISO-8859-8
+
+8859_9		ISO-8859-9
+iso8859_9	ISO-8859-9
+
+SJIS		Shift_JIS
+MS932		Shift_JIS
+JIS		ISO-2022-JP
+ISO2022JP	ISO-2022-JP
+EUC_JP		euc-jp
+KOI8_R		koi8-r
+EUC_CN		euc-cn
+EUC_TW		euc-tw
+EUC_KR		euc-kr
+
+--Table terminator.  The "--" at the beginning and end are required --
+
+#### MIME to java character set map
+
+iso-2022-cn     ISO2022CN
+iso-2022-kr     ISO2022KR
+utf-8           UTF8
+utf8		UTF8
+ja_jp.iso2022-7 ISO2022JP
+ja_jp.eucjp     EUCJIS
+euc-kr          KSC5601
+euckr           KSC5601
+us-ascii        ISO-8859-1
+x-us-ascii      ISO-8859-1

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/mailcap
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/mailcap?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/mailcap (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/resources/META-INF/mailcap Fri Jul 14 03:02:19 2006
@@ -0,0 +1,20 @@
+#
+#  Copyright 2004,2005 The Apache Software Foundation.
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+text/plain;;		x-java-content-handler=org.apache.geronimo.mail.handlers.TextHandler
+text/xml;;		x-java-content-handler=org.apache.geronimo.mail.handlers.XMLHandler
+text/html;;		x-java-content-handler=org.apache.geronimo.mail.handlers.HtmlHandler
+message/rfc822;;	x-java-content-handler=org.apache.geronimo.mail.handlers.MessageHandler
+multipart/*;;		x-java-content-handler=org.apache.geronimo.mail.handlers.MultipartHandler; x-java-fallback-entry=true

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import javax.mail.event.AllEventTests;
+import javax.mail.internet.AllInternetTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+/**
+ * @version $Revision $ $Date$
+ */
+public class AllTests {
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for javax.mail");
+        //$JUnit-BEGIN$
+        suite.addTest(new TestSuite(FlagsTest.class));
+        suite.addTest(new TestSuite(HeaderTest.class));
+        suite.addTest(new TestSuite(MessagingExceptionTest.class));
+        suite.addTest(new TestSuite(URLNameTest.class));
+        suite.addTest(new TestSuite(PasswordAuthenticationTest.class));
+        suite.addTest(AllEventTests.suite());
+        suite.addTest(AllInternetTests.suite());
+        //$JUnit-END$
+        return suite;
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/AllTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,150 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class FlagsTest extends TestCase {
+    private List flagtypes;
+    private Flags flags;
+    /**
+     * Constructor for FlagsTest.
+     * @param arg0
+     */
+    public FlagsTest(String name) {
+        super(name);
+    }
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        flags = new Flags();
+        flagtypes = new LinkedList();
+        flagtypes.add(Flags.Flag.ANSWERED);
+        flagtypes.add(Flags.Flag.DELETED);
+        flagtypes.add(Flags.Flag.DRAFT);
+        flagtypes.add(Flags.Flag.FLAGGED);
+        flagtypes.add(Flags.Flag.RECENT);
+        flagtypes.add(Flags.Flag.SEEN);
+        Collections.shuffle(flagtypes);
+    }
+    public void testHashCode() {
+        int before = flags.hashCode();
+        flags.add("Test");
+        assertTrue(
+            "Before: " + before + ", now " + flags.hashCode(),
+            flags.hashCode() != before);
+        assertTrue(flags.hashCode() != 0);
+    }
+    /*
+     * Test for void add(Flag)
+     */
+    public void testAddAndRemoveFlag() {
+        Iterator it = flagtypes.iterator();
+        while (it.hasNext()) {
+            Flags.Flag flag = (Flags.Flag) it.next();
+            assertFalse(flags.contains(flag));
+            flags.add(flag);
+            assertTrue(flags.contains(flag));
+        }
+        it = flagtypes.iterator();
+        while (it.hasNext()) {
+            Flags.Flag flag = (Flags.Flag) it.next();
+            flags.remove(flag);
+            assertFalse(flags.contains(flag));
+        }
+    }
+    /*
+     * Test for void add(String)
+     */
+    public void testAddString() {
+        assertFalse(flags.contains("Frog"));
+        flags.add("Frog");
+        assertTrue(flags.contains("Frog"));
+        flags.remove("Frog");
+        assertFalse(flags.contains("Frog"));
+    }
+    /*
+     * Test for void add(Flags)
+     */
+    public void testAddFlags() {
+        Flags other = new Flags();
+        other.add("Stuff");
+        other.add(Flags.Flag.RECENT);
+        flags.add(other);
+        assertTrue(flags.contains("Stuff"));
+        assertTrue(flags.contains(Flags.Flag.RECENT));
+        assertTrue(flags.contains(other));
+        assertTrue(flags.contains(flags));
+        flags.add("Thing");
+        assertTrue(flags.contains("Thing"));
+        flags.remove(other);
+        assertFalse(flags.contains("Stuff"));
+        assertFalse(flags.contains(Flags.Flag.RECENT));
+        assertFalse(flags.contains(other));
+        assertTrue(flags.contains("Thing"));
+    }
+    /*
+     * Test for boolean equals(Object)
+     */
+    public void testEqualsObject() {
+        Flags other = new Flags();
+        other.add("Stuff");
+        other.add(Flags.Flag.RECENT);
+        flags.add(other);
+        assertEquals(flags, other);
+    }
+    public void testGetSystemFlags() {
+        flags.add("Stuff");
+        flags.add("Another");
+        flags.add(Flags.Flag.FLAGGED);
+        flags.add(Flags.Flag.RECENT);
+        Flags.Flag[] array = flags.getSystemFlags();
+        assertEquals(2, array.length);
+        assertTrue(
+            (array[0] == Flags.Flag.FLAGGED && array[1] == Flags.Flag.RECENT)
+                || (array[0] == Flags.Flag.RECENT
+                    && array[1] == Flags.Flag.FLAGGED));
+    }
+    public void testGetUserFlags() {
+        final String stuff = "Stuff";
+        final String another = "Another";
+        flags.add(stuff);
+        flags.add(another);
+        flags.add(Flags.Flag.FLAGGED);
+        flags.add(Flags.Flag.RECENT);
+        String[] array = flags.getUserFlags();
+        assertEquals(2, array.length);
+        assertTrue(
+            (array[0] == stuff && array[1] == another)
+                || (array[0] == another && array[1] == stuff));
+    }
+    public void testClone() throws CloneNotSupportedException {
+        flags.add("Thing");
+        flags.add(Flags.Flag.RECENT);
+        Flags other = (Flags) flags.clone();
+        assertTrue(other != flags);
+        assertEquals(other, flags);
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/FlagsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeaderTest extends TestCase {
+    public HeaderTest(String name) {
+        super(name);
+    }
+    public void testHeader() {
+        Header header = new Header("One", "Two");
+        assertEquals("One", header.getName());
+        assertEquals("Two", header.getValue());
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/HeaderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,275 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+
+import javax.activation.DataHandler;
+import javax.mail.internet.MimeMessage;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageContextTest extends TestCase {
+    public void testNothing() {
+    }
+    /*
+    public void testMessageContext() {
+        Part p;
+        MessageContext mc;
+        p = new TestPart();
+        mc = new MessageContext(p);
+        assertSame(p, mc.getPart());
+        assertNull(mc.getMessage());
+        assertNull(mc.getSession());
+
+        Session s = Session.getDefaultInstance(null);
+        MimeMessage m = new MimeMessage(s);
+        p = new TestMultipart(m);
+        mc = new MessageContext(p);
+        assertSame(p, mc.getPart());
+        assertSame(m,mc.getMessage());
+        assertSame(s,mc.getSession());
+
+    }
+    private static class TestMultipart extends Multipart implements Part {
+        public TestMultipart(Part p) {
+            parent = p;
+        }
+        public void writeTo(OutputStream out) throws IOException, MessagingException {
+        }
+        public void addHeader(String name, String value) throws MessagingException {
+        }
+        public Enumeration getAllHeaders() throws MessagingException {
+            return null;
+        }
+        public Object getContent() throws IOException, MessagingException {
+            return null;
+        }
+        public DataHandler getDataHandler() throws MessagingException {
+            return null;
+        }
+        public String getDescription() throws MessagingException {
+            return null;
+        }
+        public String getDisposition() throws MessagingException {
+            return null;
+        }
+        public String getFileName() throws MessagingException {
+            return null;
+        }
+        public String[] getHeader(String name) throws MessagingException {
+            return null;
+        }
+        public InputStream getInputStream() throws IOException, MessagingException {
+            return null;
+        }
+        public int getLineCount() throws MessagingException {
+            return 0;
+        }
+        public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
+            return null;
+        }
+        public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
+            return null;
+        }
+        public int getSize() throws MessagingException {
+            return 0;
+        }
+        public boolean isMimeType(String mimeType) throws MessagingException {
+            return false;
+        }
+        public void removeHeader(String name) throws MessagingException {
+        }
+        public void setContent(Multipart content) throws MessagingException {
+        }
+        public void setContent(Object content, String type) throws MessagingException {
+        }
+        public void setDataHandler(DataHandler handler) throws MessagingException {
+        }
+        public void setDescription(String description) throws MessagingException {
+        }
+        public void setDisposition(String disposition) throws MessagingException {
+        }
+        public void setFileName(String name) throws MessagingException {
+        }
+        public void setHeader(String name, String value) throws MessagingException {
+        }
+        public void setText(String content) throws MessagingException {
+        }
+    }
+    private static class TestBodyPart extends BodyPart {
+        public TestBodyPart(Multipart p) {
+            super();
+            parent = p;
+        }
+        public void addHeader(String name, String value)
+            throws MessagingException {
+        }
+        public Enumeration getAllHeaders() throws MessagingException {
+            return null;
+        }
+        public Object getContent() throws IOException, MessagingException {
+            return null;
+        }
+        public String getContentType() throws MessagingException {
+            return null;
+        }
+        public DataHandler getDataHandler() throws MessagingException {
+            return null;
+        }
+        public String getDescription() throws MessagingException {
+            return null;
+        }
+        public String getDisposition() throws MessagingException {
+            return null;
+        }
+        public String getFileName() throws MessagingException {
+            return null;
+        }
+        public String[] getHeader(String name) throws MessagingException {
+            return null;
+        }
+        public InputStream getInputStream()
+            throws IOException, MessagingException {
+            return null;
+        }
+        public int getLineCount() throws MessagingException {
+            return 0;
+        }
+        public Enumeration getMatchingHeaders(String[] names)
+            throws MessagingException {
+            return null;
+        }
+        public Enumeration getNonMatchingHeaders(String[] names)
+            throws MessagingException {
+            return null;
+        }
+        public int getSize() throws MessagingException {
+            return 0;
+        }
+        public boolean isMimeType(String mimeType) throws MessagingException {
+            return false;
+        }
+        public void removeHeader(String name) throws MessagingException {
+        }
+        public void setContent(Multipart content) throws MessagingException {
+        }
+        public void setContent(Object content, String type)
+            throws MessagingException {
+        }
+        public void setDataHandler(DataHandler handler)
+            throws MessagingException {
+        }
+        public void setDescription(String description)
+            throws MessagingException {
+        }
+        public void setDisposition(String disposition)
+            throws MessagingException {
+        }
+        public void setFileName(String name) throws MessagingException {
+        }
+        public void setHeader(String name, String value)
+            throws MessagingException {
+        }
+        public void setText(String content) throws MessagingException {
+        }
+        public void writeTo(OutputStream out)
+            throws IOException, MessagingException {
+        }
+    }
+    private static class TestPart implements Part {
+        public void addHeader(String name, String value)
+            throws MessagingException {
+        }
+        public Enumeration getAllHeaders() throws MessagingException {
+            return null;
+        }
+        public Object getContent() throws IOException, MessagingException {
+            return null;
+        }
+        public String getContentType() throws MessagingException {
+            return null;
+        }
+        public DataHandler getDataHandler() throws MessagingException {
+            return null;
+        }
+        public String getDescription() throws MessagingException {
+            return null;
+        }
+        public String getDisposition() throws MessagingException {
+            return null;
+        }
+        public String getFileName() throws MessagingException {
+            return null;
+        }
+        public String[] getHeader(String name) throws MessagingException {
+            return null;
+        }
+        public InputStream getInputStream()
+            throws IOException, MessagingException {
+            return null;
+        }
+        public int getLineCount() throws MessagingException {
+            return 0;
+        }
+        public Enumeration getMatchingHeaders(String[] names)
+            throws MessagingException {
+            return null;
+        }
+        public Enumeration getNonMatchingHeaders(String[] names)
+            throws MessagingException {
+            return null;
+        }
+        public int getSize() throws MessagingException {
+            return 0;
+        }
+        public boolean isMimeType(String mimeType) throws MessagingException {
+            return false;
+        }
+        public void removeHeader(String name) throws MessagingException {
+        }
+        public void setContent(Multipart content) throws MessagingException {
+        }
+        public void setContent(Object content, String type)
+            throws MessagingException {
+        }
+        public void setDataHandler(DataHandler handler)
+            throws MessagingException {
+        }
+        public void setDescription(String description)
+            throws MessagingException {
+        }
+        public void setDisposition(String disposition)
+            throws MessagingException {
+        }
+        public void setFileName(String name) throws MessagingException {
+        }
+        public void setHeader(String name, String value)
+            throws MessagingException {
+        }
+        public void setText(String content) throws MessagingException {
+        }
+        public void writeTo(OutputStream out)
+            throws IOException, MessagingException {
+        }
+    }
+    */
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessageContextTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,69 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import junit.framework.TestCase;
+/**
+ * @version $Revision $ $Date$
+ */
+public class MessagingExceptionTest extends TestCase {
+    private RuntimeException d;
+    private MessagingException c;
+    private MessagingException b;
+    private MessagingException a;
+    public MessagingExceptionTest(String name) {
+        super(name);
+    }
+    protected void setUp() throws Exception {
+        super.setUp();
+        a = new MessagingException("A");
+        b = new MessagingException("B");
+        c = new MessagingException("C");
+        d = new RuntimeException("D");
+    }
+    public void testMessagingExceptionString() {
+        assertEquals("A", a.getMessage());
+    }
+    public void testNextException() {
+        assertTrue(a.setNextException(b));
+        assertEquals(b, a.getNextException());
+        assertTrue(a.setNextException(c));
+        assertEquals(b, a.getNextException());
+        assertEquals(c, b.getNextException());
+        String message = a.getMessage();
+        int ap = message.indexOf("A");
+        int bp = message.indexOf("B");
+        int cp = message.indexOf("C");
+        assertTrue("A does not contain 'A'", ap != -1);
+        assertTrue("B does not contain 'B'", bp != -1);
+        assertTrue("C does not contain 'C'", cp != -1);
+    }
+    public void testNextExceptionWrong() {
+        assertTrue(a.setNextException(d));
+        assertFalse(a.setNextException(b));
+    }
+    public void testNextExceptionWrong2() {
+        assertTrue(a.setNextException(d));
+        assertFalse(a.setNextException(b));
+    }
+    public void testMessagingExceptionStringException() {
+        MessagingException x = new MessagingException("X", a);
+        assertEquals("X (javax.mail.MessagingException: A)", x.getMessage());
+        assertEquals(a, x.getNextException());
+        assertEquals(a, x.getCause());
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/MessagingExceptionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class PasswordAuthenticationTest extends TestCase {
+    public PasswordAuthenticationTest(String name) {
+        super(name);
+    }
+    public void testPA() {
+        String user = String.valueOf(System.currentTimeMillis());
+        String password = "JobbyJobbyJobby" + user;
+        PasswordAuthentication pa = new PasswordAuthentication(user, password);
+        assertEquals(user, pa.getUserName());
+        assertEquals(password, pa.getPassword());
+    }
+    public void testPasswordAuthentication() {
+        PasswordAuthentication pa = new PasswordAuthentication("Alex", "xelA");
+        assertEquals("Alex", pa.getUserName());
+        assertEquals("xelA", pa.getPassword());
+    }
+}

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/PasswordAuthenticationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+
+import javax.mail.MessagingException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class QuotaTest extends TestCase {
+
+    public void testQuota() throws MessagingException {
+        Quota quota = new Quota("Fred");
+
+        assertEquals(quota.quotaRoot, "Fred");
+        assertNull(quota.resources);
+
+        quota.setResourceLimit("Storage", 20000);
+
+        assertNotNull(quota.resources);
+        assertTrue(quota.resources.length == 1);
+        assertEquals(quota.resources[0].name, "Storage");
+        assertEquals(quota.resources[0].usage, 0);
+        assertEquals(quota.resources[0].limit, 20000);
+
+        quota.setResourceLimit("Storage", 30000);
+
+        assertNotNull(quota.resources);
+        assertTrue(quota.resources.length == 1);
+        assertEquals(quota.resources[0].name, "Storage");
+        assertEquals(quota.resources[0].usage, 0);
+        assertEquals(quota.resources[0].limit, 30000);
+
+        quota.setResourceLimit("Folders", 5);
+
+        assertNotNull(quota.resources);
+        assertTrue(quota.resources.length == 2);
+        assertEquals(quota.resources[0].name, "Storage");
+        assertEquals(quota.resources[0].usage, 0);
+        assertEquals(quota.resources[0].limit, 30000);
+
+        assertEquals(quota.resources[1].name, "Folders");
+        assertEquals(quota.resources[1].usage, 0);
+        assertEquals(quota.resources[1].limit, 5);
+    }
+
+}
+
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/QuotaTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.mail;
+
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SessionTest extends TestCase {
+
+
+    public void testAddProvider() throws MessagingException {
+        Properties props = System.getProperties();
+         // Get a Session object
+        Session mailSession = Session.getDefaultInstance(props, null);
+
+        mailSession.addProvider(new Provider(Provider.Type.TRANSPORT, "foo", NullTransport.class.getName(), "Apache", "Java 1.4 Test"));
+
+        // retrieve the transport
+        Transport trans = mailSession.getTransport("foo");
+
+        assertTrue(trans instanceof NullTransport);
+
+        mailSession.setProtocolForAddress("foo", "foo");
+
+        trans = mailSession.getTransport(new FooAddress());
+
+        assertTrue(trans instanceof NullTransport);
+    }
+
+
+    static public class NullTransport extends Transport {
+        public NullTransport(Session session, URLName urlName) {
+            super(session, urlName);
+        }
+
+        public void sendMessage(Message message, Address[] addresses) throws MessagingException {
+            // do nothing
+        }
+
+        protected boolean protocolConnect(String host, int port, String user, String password) throws MessagingException {
+            return true; // always connect
+        }
+
+    }
+
+
+    static public class FooAddress extends Address {
+        public FooAddress() {
+        }
+
+        public String getType() {
+            return "foo";
+        }
+
+        public String toString() {
+            return "yada";
+        }
+
+
+        public boolean equals(Object other) {
+            return true;
+        }
+    }
+}
+

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SessionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message