geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r421852 [13/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/test/java/javax/mail/SimpleFolder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleFolder.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleFolder.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleFolder.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,183 @@
+/**
+ *
+ * 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.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleFolder extends Folder {
+    private static final Message[] MESSAGE_ARRAY = new Message[0];
+    private List _messages = new LinkedList();
+    private String _name;
+    public SimpleFolder(Store store) {
+        this(store, "SimpleFolder");
+    }
+    SimpleFolder(Store store, String name) {
+        super(store);
+        _name = name;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#appendMessages(javax.mail.Message[])
+     */
+    public void appendMessages(Message[] messages) throws MessagingException {
+        for (int i = 0; i < messages.length; i++) {
+            Message message = messages[i];
+            _messages.add(message);
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#close(boolean)
+     */
+    public void close(boolean expunge) throws MessagingException {
+        if (expunge) {
+            expunge();
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#create(int)
+     */
+    public boolean create(int type) throws MessagingException {
+        if (type == HOLDS_MESSAGES) {
+            return true;
+        } else {
+            throw new MessagingException("Cannot create folders that hold folders");
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#delete(boolean)
+     */
+    public boolean delete(boolean recurse) throws MessagingException {
+        _messages = new LinkedList();
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#exists()
+     */
+    public boolean exists() throws MessagingException {
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#expunge()
+     */
+    public Message[] expunge() throws MessagingException {
+        Iterator it = _messages.iterator();
+        List result = new LinkedList();
+        while (it.hasNext()) {
+            Message message = (Message) it.next();
+            if (message.isSet(Flags.Flag.DELETED)) {
+                it.remove();
+                result.add(message);
+            }
+        }
+        // run through and renumber the messages
+        for (int i = 0; i < _messages.size(); i++) {
+            Message message = (Message) _messages.get(i);
+            message.setMessageNumber(i);
+        }
+        return (Message[]) result.toArray(MESSAGE_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getFolder(java.lang.String)
+     */
+    public Folder getFolder(String name) throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getFullName()
+     */
+    public String getFullName() {
+        return getName();
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getMessage(int)
+     */
+    public Message getMessage(int id) throws MessagingException {
+        return (Message) _messages.get(id);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getMessageCount()
+     */
+    public int getMessageCount() throws MessagingException {
+        return _messages.size();
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getName()
+     */
+    public String getName() {
+        return _name;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getParent()
+     */
+    public Folder getParent() throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getPermanentFlags()
+     */
+    public Flags getPermanentFlags() {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getSeparator()
+     */
+    public char getSeparator() throws MessagingException {
+        return '/';
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#getType()
+     */
+    public int getType() throws MessagingException {
+        return HOLDS_MESSAGES;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#hasNewMessages()
+     */
+    public boolean hasNewMessages() throws MessagingException {
+        return false;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#isOpen()
+     */
+    public boolean isOpen() {
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#list(java.lang.String)
+     */
+    public Folder[] list(String pattern) throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#open(int)
+     */
+    public void open(int mode) throws MessagingException {
+        if (mode != HOLDS_MESSAGES) {
+            throw new MessagingException("SimpleFolder can only be opened with HOLDS_MESSAGES");
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Folder#renameTo(javax.mail.Folder)
+     */
+    public boolean renameTo(Folder newName) throws MessagingException {
+        _name = newName.getName();
+        return true;
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleTextMessage.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleTextMessage.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleTextMessage.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/SimpleTextMessage.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,336 @@
+/**
+ *
+ * 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.Arrays;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import javax.activation.DataHandler;
+import javax.mail.internet.InternetAddress;
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleTextMessage extends Message {
+    public static final Address[] ADDRESS_ARRAY = new Address[0];
+    private List _bcc = new LinkedList();
+    private List _cc = new LinkedList();
+    private String _description;
+    private Flags _flags = new Flags();
+    private List _from = new LinkedList();
+    private Date _received;
+    private Date _sent;
+    private String _subject;
+    private String _text;
+    private List _to = new LinkedList();
+    /**
+     * @param folder
+     * @param number
+     */
+    public SimpleTextMessage(Folder folder, int number) {
+        super(folder, number);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#addFrom(javax.mail.Address[])
+     */
+    public void addFrom(Address[] addresses) throws MessagingException {
+        _from.addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
+     */
+    public void addHeader(String name, String value)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
+     */
+    public void addRecipients(RecipientType type, Address[] addresses)
+        throws MessagingException {
+        getList(type).addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getAllHeaders()
+     */
+    public Enumeration getAllHeaders() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getContent()
+     */
+    public Object getContent() throws IOException, MessagingException {
+        return _text;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getContentType()
+     */
+    public String getContentType() throws MessagingException {
+        return "text/plain";
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getDataHandler()
+     */
+    public DataHandler getDataHandler() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getDescription()
+     */
+    public String getDescription() throws MessagingException {
+        return _description;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getDisposition()
+     */
+    public String getDisposition() throws MessagingException {
+        return Part.INLINE;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getFileName()
+     */
+    public String getFileName() throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getFlags()
+     */
+    public Flags getFlags() throws MessagingException {
+        return _flags;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getFrom()
+     */
+    public Address[] getFrom() throws MessagingException {
+        return (Address[]) _from.toArray(ADDRESS_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getHeader(java.lang.String)
+     */
+    public String[] getHeader(String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getInputStream()
+     */
+    public InputStream getInputStream()
+        throws IOException, MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getLineCount()
+     */
+    public int getLineCount() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    private List getList(RecipientType type) throws MessagingException {
+        List list;
+        if (type == RecipientType.TO) {
+            list = _to;
+        } else if (type == RecipientType.CC) {
+            list = _cc;
+        } else if (type == RecipientType.BCC) {
+            list = _bcc;
+        } else {
+            throw new MessagingException("Address type not understood");
+        }
+        return list;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getMatchingHeaders(String[] names)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getNonMatchingHeaders(String[] names)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getReceivedDate()
+     */
+    public Date getReceivedDate() throws MessagingException {
+        return _received;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getRecipients(javax.mail.Message.RecipientType)
+     */
+    public Address[] getRecipients(RecipientType type)
+        throws MessagingException {
+        return (Address[]) getList(type).toArray(ADDRESS_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getSentDate()
+     */
+    public Date getSentDate() throws MessagingException {
+        return _sent;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#getSize()
+     */
+    public int getSize() throws MessagingException {
+        return _text.length();
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#getSubject()
+     */
+    public String getSubject() throws MessagingException {
+        return _subject;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#isMimeType(java.lang.String)
+     */
+    public boolean isMimeType(String mimeType) throws MessagingException {
+        return mimeType.equals("text/plain") || mimeType.equals("text/*");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#removeHeader(java.lang.String)
+     */
+    public void removeHeader(String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#reply(boolean)
+     */
+    public Message reply(boolean replyToAll) throws MessagingException {
+        try {
+            SimpleTextMessage reply = (SimpleTextMessage) this.clone();
+            reply._to = new LinkedList(_from);
+            if (replyToAll) {
+                reply._to.addAll(_cc);
+            }
+            return reply;
+        } catch (CloneNotSupportedException e) {
+            throw new MessagingException(e.getMessage());
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#saveChanges()
+     */
+    public void saveChanges() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setContent(javax.mail.Multipart)
+     */
+    public void setContent(Multipart content) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
+     */
+    public void setContent(Object content, String type)
+        throws MessagingException {
+        setText((String) content);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
+     */
+    public void setDataHandler(DataHandler handler) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setDescription(java.lang.String)
+     */
+    public void setDescription(String description) throws MessagingException {
+        _description = description;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setDisposition(java.lang.String)
+     */
+    public void setDisposition(String disposition) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setFileName(java.lang.String)
+     */
+    public void setFileName(String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setFlags(javax.mail.Flags, boolean)
+     */
+    public void setFlags(Flags flags, boolean set) throws MessagingException {
+        if (set) {
+            _flags.add(flags);
+        } else {
+            _flags.remove(flags);
+        }
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setFrom()
+     */
+    public void setFrom() throws MessagingException {
+        setFrom(new InternetAddress("root@localhost"));
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setFrom(javax.mail.Address)
+     */
+    public void setFrom(Address address) throws MessagingException {
+        _from.clear();
+        _from.add(address);
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
+     */
+    public void setHeader(String name, String value)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
+     */
+    public void setRecipients(RecipientType type, Address[] addresses)
+        throws MessagingException {
+        List list = getList(type);
+        list.clear();
+        list.addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setSentDate(java.util.Date)
+     */
+    public void setSentDate(Date sent) throws MessagingException {
+        _sent = sent;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Message#setSubject(java.lang.String)
+     */
+    public void setSubject(String subject) throws MessagingException {
+        _subject = subject;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#setText(java.lang.String)
+     */
+    public void setText(String content) throws MessagingException {
+        _text = content;
+    }
+    /* (non-Javadoc)
+     * @see javax.mail.Part#writeTo(java.io.OutputStream)
+     */
+    public void writeTo(OutputStream out)
+        throws IOException, MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/TestData.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/TestData.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/TestData.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/TestData.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,119 @@
+/**
+ *
+ * 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.internet.MimeMessage;
+public class TestData {
+    public static Store getTestStore() {
+        return new Store(
+            getTestSession(),
+            new URLName("http://alex@test.com")) {
+            public Folder getDefaultFolder() throws MessagingException {
+                return getTestFolder();
+            }
+            public Folder getFolder(String name) throws MessagingException {
+                if (name.equals("test")) {
+                    return getTestFolder();
+                } else {
+                    return null;
+                }
+            }
+            public Folder getFolder(URLName name) throws MessagingException {
+                return getTestFolder();
+            }
+        };
+    }
+    public static Session getTestSession() {
+        return Session.getDefaultInstance(System.getProperties());
+    }
+    public static Folder getTestFolder() {
+        return new Folder(getTestStore()) {
+            public void appendMessages(Message[] messages)
+                throws MessagingException {
+            }
+            public void close(boolean expunge) throws MessagingException {
+            }
+            public boolean create(int type) throws MessagingException {
+                return false;
+            }
+            public boolean delete(boolean recurse) throws MessagingException {
+                return false;
+            }
+            public boolean exists() throws MessagingException {
+                return false;
+            }
+            public Message[] expunge() throws MessagingException {
+                return null;
+            }
+            public Folder getFolder(String name) throws MessagingException {
+                return null;
+            }
+            public String getFullName() {
+                return null;
+            }
+            public Message getMessage(int id) throws MessagingException {
+                return null;
+            }
+            public int getMessageCount() throws MessagingException {
+                return 0;
+            }
+            public String getName() {
+                return null;
+            }
+            public Folder getParent() throws MessagingException {
+                return null;
+            }
+            public Flags getPermanentFlags() {
+                return null;
+            }
+            public char getSeparator() throws MessagingException {
+                return 0;
+            }
+            public int getType() throws MessagingException {
+                return 0;
+            }
+            public boolean hasNewMessages() throws MessagingException {
+                return false;
+            }
+            public boolean isOpen() {
+                return false;
+            }
+            public Folder[] list(String pattern) throws MessagingException {
+                return null;
+            }
+            public void open(int mode) throws MessagingException {
+            }
+            public boolean renameTo(Folder newName) throws MessagingException {
+                return false;
+            }
+        };
+    }
+    public static Transport getTestTransport() {
+        return new Transport(
+            getTestSession(),
+            new URLName("http://host.name")) {
+            public void sendMessage(Message message, Address[] addresses)
+                throws MessagingException {
+                // TODO Auto-generated method stub
+            }
+        };
+    }
+    public static Message getMessage() {
+        return new MimeMessage(getTestFolder(), 1) {
+        };
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/URLNameTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/URLNameTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/URLNameTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/URLNameTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,358 @@
+/**
+ *
+ * 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.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class URLNameTest extends TestCase {
+    public URLNameTest(String name) {
+        super(name);
+    }
+
+    public void testURLNameString() {
+        String s;
+        URLName name;
+
+        s = "http://www.apache.org";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        s = "http://www.apache.org/file/file1#ref";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/file1", name.getFile());
+        assertEquals("ref", name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        s = "http://www.apache.org/file/";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/", name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        s = "http://john@www.apache.org/file/";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/", name.getFile());
+        assertNull(name.getRef());
+        assertEquals("john", name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        s = "http://john:doe@www.apache.org/file/";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/", name.getFile());
+        assertNull(name.getRef());
+        assertEquals("john", name.getUsername());
+        assertEquals("doe", name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        s = "file/file2";
+        name = new URLName(s);
+        assertNull(name.getProtocol());
+        assertNull(name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("file/file2", name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            name.getURL();
+            fail();
+        } catch (MalformedURLException e) {
+            // OK
+        }
+
+        name = new URLName((String) null);
+        assertNull( name.getProtocol());
+        assertNull(name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            name.getURL();
+            fail();
+        } catch (MalformedURLException e) {
+            // OK
+        }
+
+        name = new URLName("");
+        assertNull( name.getProtocol());
+        assertNull(name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            name.getURL();
+            fail();
+        } catch (MalformedURLException e) {
+            // OK
+        }
+    }
+
+    public void testURLNameAll() {
+        URLName name;
+        name = new URLName(null, null, -1, null, null, null);
+        assertNull(name.getProtocol());
+        assertNull(name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            name.getURL();
+            fail();
+        } catch (MalformedURLException e) {
+            // OK
+        }
+
+        name = new URLName("", "", -1, "", "", "");
+        assertNull(name.getProtocol());
+        assertNull(name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            name.getURL();
+            fail();
+        } catch (MalformedURLException e) {
+            // OK
+        }
+
+        name = new URLName("http", "www.apache.org", -1, null, null, null);
+        assertEquals("http://www.apache.org", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL("http://www.apache.org"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", 8080, "", "", "");
+        assertEquals("http://www.apache.org:8080", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(8080, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL("http://www.apache.org:8080"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", -1, "/file/file2", "", "");
+        assertEquals("http://www.apache.org/file/file2", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/file2", name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL("http://www.apache.org/file/file2"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", -1, "/file/file2", "john", "");
+        assertEquals("http://john@www.apache.org/file/file2", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/file2", name.getFile());
+        assertNull(name.getRef());
+        assertEquals("john", name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL("http://john@www.apache.org/file/file2"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", -1, "/file/file2", "john", "doe");
+        assertEquals("http://john:doe@www.apache.org/file/file2", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/file2", name.getFile());
+        assertNull(name.getRef());
+        assertEquals("john", name.getUsername());
+        assertEquals("doe", name.getPassword());
+        try {
+            assertEquals(new URL("http://john:doe@www.apache.org/file/file2"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", -1, "/file/file2", "", "doe");
+        assertEquals("http://www.apache.org/file/file2", name.toString());
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/file/file2", name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(new URL("http://www.apache.org/file/file2"), name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+    }
+
+    public void testURLNameURL() throws MalformedURLException {
+        URL url;
+        URLName name;
+
+        url = new URL("http://www.apache.org");
+        name = new URLName(url);
+        assertEquals("http", name.getProtocol());
+        assertEquals("www.apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertNull(name.getFile());
+        assertNull(name.getRef());
+        assertNull(name.getUsername());
+        assertNull(name.getPassword());
+        try {
+            assertEquals(url, name.getURL());
+        } catch (MalformedURLException e) {
+            fail();
+        }
+    }
+
+    public void testEquals() throws MalformedURLException {
+        URLName name1 = new URLName("http://www.apache.org");
+        assertEquals(name1, new URLName("http://www.apache.org"));
+        assertEquals(name1, new URLName(new URL("http://www.apache.org")));
+        assertEquals(name1, new URLName("http", "www.apache.org", -1, null, null, null));
+        assertEquals(name1, new URLName("http://www.apache.org#foo")); // wierd but ref is not part of the equals contract
+        assertTrue(!name1.equals(new URLName("http://www.apache.org:8080")));
+        assertTrue(!name1.equals(new URLName("http://cvs.apache.org")));
+        assertTrue(!name1.equals(new URLName("https://www.apache.org")));
+
+        name1 = new URLName("http://john:doe@www.apache.org");
+        assertEquals(name1, new URLName(new URL("http://john:doe@www.apache.org")));
+        assertEquals(name1, new URLName("http", "www.apache.org", -1, null, "john", "doe"));
+        assertTrue(!name1.equals(new URLName("http://john:xxx@www.apache.org")));
+        assertTrue(!name1.equals(new URLName("http://xxx:doe@www.apache.org")));
+        assertTrue(!name1.equals(new URLName("http://www.apache.org")));
+
+        assertEquals(new URLName("http://john@www.apache.org"), new URLName("http", "www.apache.org", -1, null, "john", null));
+        assertEquals(new URLName("http://www.apache.org"), new URLName("http", "www.apache.org", -1, null, null, "doe"));
+    }
+
+    public void testHashCode() {
+        URLName name1 = new URLName("http://www.apache.org/file");
+        URLName name2 = new URLName("http://www.apache.org/file#ref");
+        assertTrue(name1.equals(name2));
+        assertTrue(name1.hashCode() == name2.hashCode());
+    }
+
+    public void testNullProtocol() {
+        URLName name1 = new URLName(null, "www.apache.org", -1, null, null, null);
+        assertTrue(!name1.equals(name1));
+    }
+
+    public void testOpaqueSchemes() {
+        String s;
+        URLName name;
+
+        // not strictly opaque but no protocol handler installed
+        s = "foo://jdoe@apache.org/INBOX";
+        name = new URLName(s);
+        assertEquals(s, name.toString());
+        assertEquals("foo", name.getProtocol());
+        assertEquals("apache.org", name.getHost());
+        assertEquals(-1, name.getPort());
+        assertEquals("/INBOX", name.getFile());
+        assertNull(name.getRef());
+        assertEquals("jdoe", name.getUsername());
+        assertNull(name.getPassword());
+
+        // TBD as I am not sure what other URL formats to use
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/AllEventTests.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/AllEventTests.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/AllEventTests.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/AllEventTests.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,37 @@
+/**
+ *
+ * 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.event;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+/**
+ * @version $Rev$ $Date$
+ */
+public class AllEventTests {
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for javax.mail.event");
+        //$JUnit-BEGIN$
+        suite.addTest(new TestSuite(ConnectionEventTest.class));
+        suite.addTest(new TestSuite(FolderEventTest.class));
+        suite.addTest(new TestSuite(MessageChangedEventTest.class));
+        suite.addTest(new TestSuite(StoreEventTest.class));
+        suite.addTest(new TestSuite(MessageCountEventTest.class));
+        suite.addTest(new TestSuite(TransportEventTest.class));
+        //$JUnit-END$
+        return suite;
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/ConnectionEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/ConnectionEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/ConnectionEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/ConnectionEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * 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.event;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectionEventTest extends TestCase {
+    public static class ConnectionListenerTest implements ConnectionListener {
+        private int state = 0;
+        public void closed(ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.CLOSED;
+        }
+        public void disconnected(ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.DISCONNECTED;
+        }
+        public int getState() {
+            return state;
+        }
+        public void opened(ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.OPENED;
+        }
+    }
+    public ConnectionEventTest(String name) {
+        super(name);
+    }
+    private void doEventTests(int type) {
+        ConnectionEvent event = new ConnectionEvent(this, type);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getType());
+        ConnectionListenerTest listener = new ConnectionListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public void testEvent() {
+        doEventTests(ConnectionEvent.CLOSED);
+        doEventTests(ConnectionEvent.OPENED);
+        doEventTests(ConnectionEvent.DISCONNECTED);
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/FolderEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/FolderEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/FolderEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/FolderEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * 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.event;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class FolderEventTest extends TestCase {
+    public FolderEventTest(String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(FolderEvent.CREATED);
+        doEventTests(FolderEvent.RENAMED);
+        doEventTests(FolderEvent.DELETED);
+    }
+    private void doEventTests(int type) {
+        FolderEvent event = new FolderEvent(this, null, type);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getType());
+        FolderListenerTest listener = new FolderListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public static class FolderListenerTest implements FolderListener {
+        private int state = 0;
+        public void folderCreated(FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.CREATED;
+        }
+        public void folderDeleted(FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.DELETED;
+        }
+        public void folderRenamed(FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.RENAMED;
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageChangedEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageChangedEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageChangedEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageChangedEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.event;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageChangedEventTest extends TestCase {
+    public MessageChangedEventTest(String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(MessageChangedEvent.ENVELOPE_CHANGED);
+        doEventTests(MessageChangedEvent.FLAGS_CHANGED);
+    }
+    private void doEventTests(int type) {
+        MessageChangedEvent event = new MessageChangedEvent(this, type, null);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getMessageChangeType());
+        MessageChangedListenerTest listener = new MessageChangedListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public static class MessageChangedListenerTest
+        implements MessageChangedListener {
+        private int state = 0;
+        public void messageChanged(MessageChangedEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = event.getMessageChangeType();
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageCountEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageCountEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageCountEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/MessageCountEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,67 @@
+/**
+ *
+ * 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.event;
+import javax.mail.Folder;
+import javax.mail.TestData;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageCountEventTest extends TestCase {
+    public MessageCountEventTest(String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(MessageCountEvent.ADDED);
+        doEventTests(MessageCountEvent.REMOVED);
+        try {
+            doEventTests(-12345);
+            fail("Expected exception due to invalid type -12345");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+    private void doEventTests(int type) {
+        Folder folder = TestData.getTestFolder();
+        MessageCountEvent event =
+            new MessageCountEvent(folder, type, false, null);
+        assertEquals(folder, event.getSource());
+        assertEquals(type, event.getType());
+        MessageCountListenerTest listener = new MessageCountListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public static class MessageCountListenerTest
+        implements MessageCountListener {
+        private int state = 0;
+        public void messagesAdded(MessageCountEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = MessageCountEvent.ADDED;
+        }
+        public void messagesRemoved(MessageCountEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = MessageCountEvent.REMOVED;
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/StoreEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/StoreEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/StoreEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/StoreEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,62 @@
+/**
+ *
+ * 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.event;
+import javax.mail.Store;
+import javax.mail.TestData;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class StoreEventTest extends TestCase {
+    public StoreEventTest(String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(StoreEvent.ALERT);
+        doEventTests(StoreEvent.NOTICE);
+        try {
+            StoreEvent event = new StoreEvent(null, -12345, "Hello World");
+            fail(
+                "Expected exception due to invalid type "
+                    + event.getMessageType());
+        } catch (IllegalArgumentException e) {
+        }
+    }
+    private void doEventTests(int type) {
+        Store source = TestData.getTestStore();
+        StoreEvent event = new StoreEvent(source, type, "Hello World");
+        assertEquals(source, event.getSource());
+        assertEquals("Hello World", event.getMessage());
+        assertEquals(type, event.getMessageType());
+        StoreListenerTest listener = new StoreListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public static class StoreListenerTest implements StoreListener {
+        private int state = 0;
+        public void notification(StoreEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = event.getMessageType();
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/TransportEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/TransportEventTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/TransportEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/event/TransportEventTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,77 @@
+/**
+ *
+ * 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.event;
+import javax.mail.Address;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.TestData;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class TransportEventTest extends TestCase {
+    public TransportEventTest(String name) {
+        super(name);
+    }
+    public void testEvent() throws AddressException {
+        doEventTests(TransportEvent.MESSAGE_DELIVERED);
+        doEventTests(TransportEvent.MESSAGE_PARTIALLY_DELIVERED);
+        doEventTests(TransportEvent.MESSAGE_NOT_DELIVERED);
+    }
+    private void doEventTests(int type) throws AddressException {
+        Folder folder = TestData.getTestFolder();
+        Message message = TestData.getMessage();
+        Transport transport = TestData.getTestTransport();
+        Address[] sent = new Address[] { new InternetAddress("alex@here.com")};
+        Address[] empty = new Address[0];
+        TransportEvent event =
+            new TransportEvent(transport, type, sent, empty, empty, message);
+        assertEquals(transport, event.getSource());
+        assertEquals(type, event.getType());
+        TransportListenerTest listener = new TransportListenerTest();
+        event.dispatch(listener);
+        assertEquals("Unexpcted method dispatched", type, listener.getState());
+    }
+    public static class TransportListenerTest implements TransportListener {
+        private int state = 0;
+        public void messageDelivered(TransportEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = TransportEvent.MESSAGE_DELIVERED;
+        }
+        public void messagePartiallyDelivered(TransportEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = TransportEvent.MESSAGE_PARTIALLY_DELIVERED;
+        }
+        public void messageNotDelivered(TransportEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = TransportEvent.MESSAGE_NOT_DELIVERED;
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/AllInternetTests.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/AllInternetTests.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/AllInternetTests.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/AllInternetTests.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,34 @@
+/**
+ *
+ * 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.internet;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+/**
+ * @version $Rev$ $Date$
+ */
+public class AllInternetTests {
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for javax.mail.internet");
+        //$JUnit-BEGIN$
+        suite.addTest(new TestSuite(ContentTypeTest.class));
+        suite.addTest(new TestSuite(ParameterListTest.class));
+        suite.addTest(new TestSuite(InternetAddressTest.class));
+        //$JUnit-END$
+        return suite;
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentDispositionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentDispositionTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentDispositionTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentDispositionTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ * 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.internet;
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContentDispositionTest extends TestCase {
+
+    public ContentDispositionTest(String name) {
+        super(name);
+    }
+
+    public void testContentDisposition() throws ParseException {
+        ContentDisposition c;
+        c = new ContentDisposition();
+        assertNotNull(c.getParameterList());
+        assertNull(c.getParameterList().get("nothing"));
+        assertNull(c.getDisposition());
+        assertNull(c.toString());
+        c.setDisposition("inline");
+        assertEquals("inline",c.getDisposition());
+        c.setParameter("file","file.txt");
+        assertEquals("file.txt",c.getParameterList().get("file"));
+        assertEquals("inline; file=file.txt",c.toString());
+        c = new ContentDisposition("inline");
+        assertEquals(0,c.getParameterList().size());
+        assertEquals("inline",c.getDisposition());
+        c = new ContentDisposition("inline",new ParameterList(";charset=us-ascii;content-type=\"text/plain\""));
+        assertEquals("inline",c.getDisposition());
+        assertEquals("us-ascii",c.getParameter("charset"));
+        assertEquals("text/plain",c.getParameter("content-type"));
+        c = new ContentDisposition("attachment;content-type=\"text/html\";charset=UTF-8");
+        assertEquals("attachment",c.getDisposition());
+        assertEquals("UTF-8",c.getParameter("charset"));
+        assertEquals("text/html",c.getParameter("content-type"));
+    }
+
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentTypeTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentTypeTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentTypeTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/ContentTypeTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,144 @@
+/**
+ *
+ * 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.internet;
+import junit.framework.TestCase;
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContentTypeTest extends TestCase {
+    public ContentTypeTest(String arg0) {
+        super(arg0);
+    }
+    public void testContentType() throws ParseException {
+        ContentType type = new ContentType();
+        assertNull(type.getPrimaryType());
+        assertNull(type.getSubType());
+        assertNull(type.getParameter("charset"));
+    }
+
+    public void testContentTypeStringStringParameterList() throws ParseException {
+        ContentType type;
+        ParameterList list = new ParameterList(";charset=us-ascii");
+        type = new ContentType("text", "plain", list);
+        assertEquals("text", type.getPrimaryType());
+        assertEquals("plain", type.getSubType());
+        assertEquals("text/plain", type.getBaseType());
+        ParameterList parameterList = type.getParameterList();
+        assertEquals("us-ascii", parameterList.get("charset"));
+        assertEquals("us-ascii", type.getParameter("charset"));
+
+    }
+
+    public void testContentTypeString() throws ParseException {
+        ContentType type;
+        type = new ContentType("text/plain");
+        assertEquals("text", type.getPrimaryType());
+        assertEquals("plain", type.getSubType());
+        assertEquals("text/plain", type.getBaseType());
+        assertNotNull(type.getParameterList());
+        assertNull(type.getParameter("charset"));
+        type = new ContentType("image/audio;charset=us-ascii");
+        ParameterList parameterList = type.getParameterList();
+        assertEquals("image", type.getPrimaryType());
+        assertEquals("audio", type.getSubType());
+        assertEquals("image/audio", type.getBaseType());
+        assertEquals("us-ascii", parameterList.get("charset"));
+        assertEquals("us-ascii", type.getParameter("charset"));
+    }
+    public void testGetPrimaryType() throws ParseException {
+    }
+    public void testGetSubType() throws ParseException {
+    }
+    public void testGetBaseType() throws ParseException {
+    }
+    public void testGetParameter() throws ParseException {
+    }
+    public void testGetParameterList() throws ParseException {
+    }
+    public void testSetPrimaryType() throws ParseException {
+        ContentType type = new ContentType("text/plain");
+        type.setPrimaryType("binary");
+        assertEquals("binary", type.getPrimaryType());
+        assertEquals("plain", type.getSubType());
+        assertEquals("binary/plain", type.getBaseType());
+    }
+    public void testSetSubType() throws ParseException {
+        ContentType type = new ContentType("text/plain");
+        type.setSubType("html");
+        assertEquals("text", type.getPrimaryType());
+        assertEquals("html", type.getSubType());
+        assertEquals("text/html", type.getBaseType());
+    }
+    public void testSetParameter() throws ParseException {
+    }
+    public void testSetParameterList() throws ParseException {
+    }
+    public void testToString() throws ParseException {
+        ContentType type = new ContentType("text/plain");
+        assertEquals("text/plain", type.toString());
+        type.setParameter("foo", "bar");
+        assertEquals("text/plain; foo=bar", type.toString());
+        type.setParameter("bar", "me@apache.org");
+        assertEquals("text/plain; foo=bar; bar=\"me@apache.org\"", type.toString());
+    }
+    public void testMatchContentType() throws ParseException {
+        ContentType type = new ContentType("text/plain");
+
+        ContentType test = new ContentType("text/plain");
+
+        assertTrue(type.match(test));
+
+        test = new ContentType("TEXT/plain");
+        assertTrue(type.match(test));
+        assertTrue(test.match(type));
+
+        test = new ContentType("text/PLAIN");
+        assertTrue(type.match(test));
+        assertTrue(test.match(type));
+
+        test = new ContentType("text/*");
+        assertTrue(type.match(test));
+        assertTrue(test.match(type));
+
+        test = new ContentType("text/xml");
+        assertFalse(type.match(test));
+        assertFalse(test.match(type));
+
+        test = new ContentType("binary/plain");
+        assertFalse(type.match(test));
+        assertFalse(test.match(type));
+
+        test = new ContentType("*/plain");
+        assertFalse(type.match(test));
+        assertFalse(test.match(type));
+    }
+    public void testMatchString() throws ParseException {
+        ContentType type = new ContentType("text/plain");
+        assertTrue(type.match("text/plain"));
+        assertTrue(type.match("TEXT/plain"));
+        assertTrue(type.match("text/PLAIN"));
+        assertTrue(type.match("TEXT/PLAIN"));
+        assertTrue(type.match("TEXT/*"));
+
+        assertFalse(type.match("text/xml"));
+        assertFalse(type.match("binary/plain"));
+        assertFalse(type.match("*/plain"));
+        assertFalse(type.match(""));
+        assertFalse(type.match("text/plain/yada"));
+    }
+}

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

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

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

Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/HeaderTokenizerTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/HeaderTokenizerTest.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/HeaderTokenizerTest.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/test/java/javax/mail/internet/HeaderTokenizerTest.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,161 @@
+/**
+ *
+ * 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.internet;
+
+import javax.mail.internet.HeaderTokenizer.Token;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeaderTokenizerTest extends TestCase {
+    public void testTokenizer() throws ParseException {
+        Token t;
+        HeaderTokenizer ht;
+        ht =
+            new HeaderTokenizer("To: \"Geronimo List\" <geronimo-dev@apache.org>, \n\r Geronimo User <geronimo-user@apache.org>");
+        validateToken(ht.peek(), Token.ATOM, "To");
+        validateToken(ht.next(), Token.ATOM, "To");
+        validateToken(ht.peek(), ':', ":");
+        validateToken(ht.next(), ':', ":");
+        validateToken(ht.next(), Token.QUOTEDSTRING, "Geronimo List");
+        validateToken(ht.next(), '<', "<");
+        validateToken(ht.next(), Token.ATOM, "geronimo-dev");
+        validateToken(ht.next(), '@', "@");
+        validateToken(ht.next(), Token.ATOM, "apache");
+        validateToken(ht.next(), '.', ".");
+        validateToken(ht.next(), Token.ATOM, "org");
+        validateToken(ht.next(), '>', ">");
+        validateToken(ht.next(), ',', ",");
+        validateToken(ht.next(), Token.ATOM, "Geronimo");
+        validateToken(ht.next(), Token.ATOM, "User");
+        validateToken(ht.next(), '<', "<");
+        validateToken(ht.next(), Token.ATOM, "geronimo-user");
+        validateToken(ht.next(), '@', "@");
+        validateToken(ht.next(), Token.ATOM, "apache");
+        validateToken(ht.next(), '.', ".");
+        assertEquals("org>", ht.getRemainder());
+        validateToken(ht.peek(), Token.ATOM, "org");
+        validateToken(ht.next(), Token.ATOM, "org");
+        validateToken(ht.next(), '>', ">");
+        assertEquals(Token.EOF, ht.next().getType());
+        ht = new HeaderTokenizer("   ");
+        assertEquals(Token.EOF, ht.next().getType());
+        ht = new HeaderTokenizer("J2EE");
+        validateToken(ht.next(), Token.ATOM, "J2EE");
+        assertEquals(Token.EOF, ht.next().getType());
+        // test comments
+        doComment(true);
+        doComment(false);
+    }
+
+    public void testErrors() throws ParseException {
+        checkParseError("(Geronimo");
+        checkParseError("((Geronimo)");
+        checkParseError("\"Geronimo");
+        checkParseError("\"Geronimo\\");
+    }
+
+
+    public void testQuotedLiteral() throws ParseException {
+        checkTokenParse("\"\"", Token.QUOTEDSTRING, "");
+        checkTokenParse("\"\\\"\"", Token.QUOTEDSTRING, "\"");
+        checkTokenParse("\"\\\"\"", Token.QUOTEDSTRING, "\"");
+        checkTokenParse("\"A\r\nB\"", Token.QUOTEDSTRING, "AB");
+        checkTokenParse("\"A\nB\"", Token.QUOTEDSTRING, "A\nB");
+    }
+
+
+    public void testComment() throws ParseException {
+        checkTokenParse("()", Token.COMMENT, "");
+        checkTokenParse("(())", Token.COMMENT, "()");
+        checkTokenParse("(Foo () Bar)", Token.COMMENT, "Foo () Bar");
+        checkTokenParse("(\"Foo () Bar)", Token.COMMENT, "\"Foo () Bar");
+        checkTokenParse("(\\()", Token.COMMENT, "(");
+        checkTokenParse("(Foo \r\n Bar)", Token.COMMENT, "Foo  Bar");
+        checkTokenParse("(Foo \n Bar)", Token.COMMENT, "Foo \n Bar");
+    }
+
+    public void checkTokenParse(String text, int type, String value) throws ParseException {
+        HeaderTokenizer ht;
+        ht = new HeaderTokenizer(text, HeaderTokenizer.RFC822, false);
+        validateToken(ht.next(), type, value);
+    }
+
+
+    public void checkParseError(String text) throws ParseException {
+        Token t;
+        HeaderTokenizer ht;
+
+        ht = new HeaderTokenizer(text);
+        doNextError(ht);
+        ht = new HeaderTokenizer(text);
+        doPeekError(ht);
+    }
+
+    public void doNextError(HeaderTokenizer ht) {
+        try {
+            ht.next();
+            fail("Expected ParseException");
+        } catch (ParseException e) {
+        }
+    }
+
+    public void doPeekError(HeaderTokenizer ht) {
+        try {
+            ht.peek();
+            fail("Expected ParseException");
+        } catch (ParseException e) {
+        }
+    }
+
+
+    public void doComment(boolean ignore) throws ParseException {
+        HeaderTokenizer ht;
+        Token t;
+        ht =
+            new HeaderTokenizer(
+                "Apache(Geronimo)J2EE",
+                HeaderTokenizer.RFC822,
+                ignore);
+        validateToken(ht.next(), Token.ATOM, "Apache");
+        if (!ignore) {
+            validateToken(ht.next(), Token.COMMENT, "Geronimo");
+        }
+        validateToken(ht.next(), Token.ATOM, "J2EE");
+        assertEquals(Token.EOF, ht.next().getType());
+
+        ht =
+            new HeaderTokenizer(
+                "Apache(Geronimo (Project))J2EE",
+                HeaderTokenizer.RFC822,
+                ignore);
+        validateToken(ht.next(), Token.ATOM, "Apache");
+        if (!ignore) {
+            validateToken(ht.next(), Token.COMMENT, "Geronimo (Project)");
+        }
+        validateToken(ht.next(), Token.ATOM, "J2EE");
+        assertEquals(Token.EOF, ht.next().getType());
+    }
+
+    private void validateToken(HeaderTokenizer.Token token, int type, String value) {
+        assertEquals(token.getType(), type);
+        assertEquals(token.getValue(), value);
+    }
+}

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

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

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



Mime
View raw message