You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jl...@apache.org on 2022/05/03 12:22:12 UTC

svn commit: r1900504 [18/22] - in /geronimo/specs/trunk: ./ geronimo-activation_2.0_spec/ geronimo-activation_2.0_spec/src/ geronimo-activation_2.0_spec/src/main/ geronimo-activation_2.0_spec/src/main/java/ geronimo-activation_2.0_spec/src/main/java/ja...

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/FlagsTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import java.util.*;
+
+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(final String name) {
+        super(name);
+    }
+    /*
+     * @see TestCase#setUp()
+     */
+    @Override
+    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() {
+        final 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()) {
+            final Flags.Flag flag = (Flags.Flag) it.next();
+            assertFalse(flags.contains(flag));
+            flags.add(flag);
+            assertTrue(flags.contains(flag));
+        }
+        it = flagtypes.iterator();
+        while (it.hasNext()) {
+            final 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() {
+        final 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() {
+        final 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);
+        final 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);
+        final 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);
+        final Flags other = (Flags) flags.clone();
+        assertTrue(other != flags);
+        assertEquals(other, flags);
+    }
+
+    public void testClearSystemFlags() {
+        Flags f = new Flags();
+        f.add(Flags.Flag.ANSWERED);
+        f.add(Flags.Flag.DELETED);
+        f.add(Flags.Flag.DRAFT);
+        f.add(Flags.Flag.FLAGGED);
+        f.add(Flags.Flag.RECENT);
+        f.add(Flags.Flag.SEEN);
+        f.add("TEST");
+
+        f.clearSystemFlags();
+
+        assertEquals(0, f.getSystemFlags().length);
+        assertEquals(1, f.getUserFlags().length);
+        assertEquals("TEST", f.getUserFlags()[0]);
+    }
+
+    public void testClearuserFlags() {
+        Flags f = new Flags();
+        f.add(Flags.Flag.ANSWERED);
+        f.add(Flags.Flag.DELETED);
+        f.add(Flags.Flag.DRAFT);
+        f.add(Flags.Flag.FLAGGED);
+        f.add(Flags.Flag.RECENT);
+        f.add(Flags.Flag.SEEN);
+        f.add("TEST");
+
+        f.clearUserFlags();
+
+        assertEquals(6, f.getSystemFlags().length);
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.ANSWERED));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.DELETED));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.DRAFT));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.FLAGGED));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.RECENT));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.SEEN));
+        assertEquals(0, f.getUserFlags().length);
+    }
+
+    public void testRetainAllFlags() {
+        Flags f = new Flags();
+        f.add(Flags.Flag.ANSWERED);
+        f.add(Flags.Flag.DELETED);
+        f.add(Flags.Flag.DRAFT);
+        f.add(Flags.Flag.FLAGGED);
+        f.add(Flags.Flag.RECENT);
+        f.add(Flags.Flag.SEEN);
+        f.add("TEST");
+        f.add("FLAG");
+
+        Flags retain = new Flags();
+        retain.add(Flags.Flag.SEEN);
+        retain.add(Flags.Flag.ANSWERED);
+        retain.add("TEST");
+        retain.add("SUPER IMPORTANT");
+
+        f.retainAll(retain);
+
+        assertEquals(2, f.getSystemFlags().length);
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.ANSWERED));
+        assertTrue(Arrays.asList(f.getSystemFlags()).contains(Flags.Flag.SEEN));
+        assertEquals(1, f.getUserFlags().length);
+        assertEquals("TEST", f.getUserFlags()[0]);
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/HeaderTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HeaderTest extends TestCase {
+    public HeaderTest(final String name) {
+        super(name);
+    }
+    public void testHeader() {
+        final Header header = new Header("One", "Two");
+        assertEquals("One", header.getName());
+        assertEquals("Two", header.getValue());
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessageContextTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+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 {
+        }
+    }
+    */
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/MessagingExceptionTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Revision $ $Date$
+ */
+public class MessagingExceptionTest extends TestCase {
+    private RuntimeException e;
+    private MessagingException d;
+    private MessagingException c;
+    private MessagingException b;
+    private MessagingException a;
+    public MessagingExceptionTest(final String name) {
+        super(name);
+    }
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        //Initialize cause with null, make sure the getCause will not be affected
+        a = new MessagingException("A", null);
+        b = new MessagingException("B");
+        c = new MessagingException("C");
+        d = new MessagingException("D");
+        e = new RuntimeException("E");
+    }
+    
+    public void testMessagingExceptionString() {
+        assertEquals("A", a.getMessage());
+    }
+    
+    public void testNextException() {
+        assertTrue(a.setNextException(b));
+        assertEquals(b, a.getNextException());
+        assertEquals(b, a.getCause());
+        
+        assertTrue(a.setNextException(c));
+        assertEquals(b, a.getNextException());
+        assertEquals(c, b.getNextException());
+        assertEquals(c, b.getCause());
+        
+        assertTrue(a.setNextException(d));
+        
+        assertEquals(b, a.getNextException());
+        assertEquals(b, a.getCause());
+        
+        assertEquals(c, b.getNextException());
+        assertEquals(c, b.getCause());
+        
+        assertEquals(d, c.getNextException());
+        assertEquals(d, c.getCause());
+        
+        final String message = a.getMessage();
+        final int ap = message.indexOf("A");
+        final int bp = message.indexOf("B");
+        final 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(e));
+        assertFalse(a.setNextException(b));
+    }
+    
+    public void testNextExceptionWrong2() {
+        assertTrue(a.setNextException(e));
+        assertFalse(a.setNextException(b));
+    }
+    
+    public void testMessagingExceptionStringException() {
+        final MessagingException x = new MessagingException("X", a);
+        assertEquals("X (jakarta.mail.MessagingException: A)", x.getMessage());
+        assertEquals(a, x.getNextException());
+        assertEquals(a, x.getCause());
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/PasswordAuthenticationTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PasswordAuthenticationTest extends TestCase {
+    public PasswordAuthenticationTest(final String name) {
+        super(name);
+    }
+    public void testPA() {
+        final String user = String.valueOf(System.currentTimeMillis());
+        final String password = "JobbyJobbyJobby" + user;
+        final PasswordAuthentication pa = new PasswordAuthentication(user, password);
+        assertEquals(user, pa.getUserName());
+        assertEquals(password, pa.getPassword());
+    }
+    public void testPasswordAuthentication() {
+        final PasswordAuthentication pa = new PasswordAuthentication("Alex", "xelA");
+        assertEquals("Alex", pa.getUserName());
+        assertEquals("xelA", pa.getPassword());
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/QuotaTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class QuotaTest extends TestCase {
+
+    public void testQuota() throws MessagingException {
+        final 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);
+    }
+
+}
+
+

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SessionTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SessionTest extends TestCase {
+    public void testAddProvider() throws MessagingException {
+        final Properties props = System.getProperties();
+         // Get a Session object
+        final 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(final Session session, final URLName urlName) {
+            super(session, urlName);
+        }
+
+        @Override
+        public void sendMessage(final Message message, final Address[] addresses) throws MessagingException {
+            // do nothing
+        }
+
+        @Override
+        protected boolean protocolConnect(final String host, final int port, final String user, final String password) throws MessagingException {
+            return true; // always connect
+        }
+
+    }
+
+    static public class FooAddress extends Address {
+        public FooAddress() {
+        }
+
+        @Override
+        public String getType() {
+            return "foo";
+        }
+
+        @Override
+        public String toString() {
+            return "yada";
+        }
+
+
+        @Override
+        public boolean equals(final Object other) {
+            return true;
+        }
+    }
+}
+

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleFolder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleFolder.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleFolder.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleFolder.java Tue May  3 12:22:08 2022
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.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(final Store store) {
+        this(store, "SimpleFolder");
+    }
+    SimpleFolder(final Store store, final String name) {
+        super(store);
+        _name = name;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#appendMessages(jakarta.mail.Message[])
+     */
+    @Override
+    public void appendMessages(final Message[] messages) throws MessagingException {
+        for (int i = 0; i < messages.length; i++) {
+            final Message message = messages[i];
+            _messages.add(message);
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#close(boolean)
+     */
+    @Override
+    public void close(final boolean expunge) throws MessagingException {
+        if (expunge) {
+            expunge();
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#create(int)
+     */
+    @Override
+    public boolean create(final int type) throws MessagingException {
+        if (type == HOLDS_MESSAGES) {
+            return true;
+        } else {
+            throw new MessagingException("Cannot create folders that hold folders");
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#delete(boolean)
+     */
+    @Override
+    public boolean delete(final boolean recurse) throws MessagingException {
+        _messages = new LinkedList();
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#exists()
+     */
+    @Override
+    public boolean exists() throws MessagingException {
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#expunge()
+     */
+    @Override
+    public Message[] expunge() throws MessagingException {
+        final Iterator it = _messages.iterator();
+        final List result = new LinkedList();
+        while (it.hasNext()) {
+            final 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++) {
+            final Message message = (Message) _messages.get(i);
+            message.setMessageNumber(i);
+        }
+        return (Message[]) result.toArray(MESSAGE_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getFolder(java.lang.String)
+     */
+    @Override
+    public Folder getFolder(final String name) throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getFullName()
+     */
+    @Override
+    public String getFullName() {
+        return getName();
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getMessage(int)
+     */
+    @Override
+    public Message getMessage(final int id) throws MessagingException {
+        return (Message) _messages.get(id);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getMessageCount()
+     */
+    @Override
+    public int getMessageCount() throws MessagingException {
+        return _messages.size();
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getName()
+     */
+    @Override
+    public String getName() {
+        return _name;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getParent()
+     */
+    @Override
+    public Folder getParent() throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getPermanentFlags()
+     */
+    @Override
+    public Flags getPermanentFlags() {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getSeparator()
+     */
+    @Override
+    public char getSeparator() throws MessagingException {
+        return '/';
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#getType()
+     */
+    @Override
+    public int getType() throws MessagingException {
+        return HOLDS_MESSAGES;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#hasNewMessages()
+     */
+    @Override
+    public boolean hasNewMessages() throws MessagingException {
+        return false;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#isOpen()
+     */
+    @Override
+    public boolean isOpen() {
+        return true;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#list(java.lang.String)
+     */
+    @Override
+    public Folder[] list(final String pattern) throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#open(int)
+     */
+    @Override
+    public void open(final int mode) throws MessagingException {
+        if (mode != HOLDS_MESSAGES) {
+            throw new MessagingException("SimpleFolder can only be opened with HOLDS_MESSAGES");
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Folder#renameTo(jakarta.mail.Folder)
+     */
+    @Override
+    public boolean renameTo(final Folder newName) throws MessagingException {
+        _name = newName.getName();
+        return true;
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleTextMessage.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleTextMessage.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleTextMessage.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/SimpleTextMessage.java Tue May  3 12:22:08 2022
@@ -0,0 +1,358 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import jakarta.mail.internet.InternetAddress;
+
+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 jakarta.activation.DataHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleTextMessage extends Message {
+    public static final Address[] ADDRESS_ARRAY = new Address[0];
+    private final List _bcc = new LinkedList();
+    private final List _cc = new LinkedList();
+    private String _description;
+    private final Flags _flags = new Flags();
+    private final 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(final Folder folder, final int number) {
+        super(folder, number);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#addFrom(jakarta.mail.Address[])
+     */
+    @Override
+    public void addFrom(final Address[] addresses) throws MessagingException {
+        _from.addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#addHeader(java.lang.String, java.lang.String)
+     */
+    public void addHeader(final String name, final String value)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#addRecipients(jakarta.mail.Message.RecipientType, jakarta.mail.Address[])
+     */
+    @Override
+    public void addRecipients(final RecipientType type, final Address[] addresses)
+        throws MessagingException {
+        getList(type).addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getAllHeaders()
+     */
+    public Enumeration getAllHeaders() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getContent()
+     */
+    public Object getContent() throws IOException, MessagingException {
+        return _text;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getContentType()
+     */
+    public String getContentType() throws MessagingException {
+        return "text/plain";
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getDataHandler()
+     */
+    public DataHandler getDataHandler() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getDescription()
+     */
+    public String getDescription() throws MessagingException {
+        return _description;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getDisposition()
+     */
+    public String getDisposition() throws MessagingException {
+        return Part.INLINE;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getFileName()
+     */
+    public String getFileName() throws MessagingException {
+        return null;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getFlags()
+     */
+    @Override
+    public Flags getFlags() throws MessagingException {
+        return _flags;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getFrom()
+     */
+    @Override
+    public Address[] getFrom() throws MessagingException {
+        return (Address[]) _from.toArray(ADDRESS_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getHeader(java.lang.String)
+     */
+    public String[] getHeader(final String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getInputStream()
+     */
+    public InputStream getInputStream()
+        throws IOException, MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getLineCount()
+     */
+    public int getLineCount() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    private List getList(final 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 jakarta.mail.Part#getMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getMatchingHeaders(final String[] names)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getNonMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getNonMatchingHeaders(final String[] names)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getReceivedDate()
+     */
+    @Override
+    public Date getReceivedDate() throws MessagingException {
+        return _received;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getRecipients(jakarta.mail.Message.RecipientType)
+     */
+    @Override
+    public Address[] getRecipients(final RecipientType type)
+        throws MessagingException {
+        return (Address[]) getList(type).toArray(ADDRESS_ARRAY);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getSentDate()
+     */
+    @Override
+    public Date getSentDate() throws MessagingException {
+        return _sent;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#getSize()
+     */
+    public int getSize() throws MessagingException {
+        return _text.length();
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#getSubject()
+     */
+    @Override
+    public String getSubject() throws MessagingException {
+        return _subject;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#isMimeType(java.lang.String)
+     */
+    public boolean isMimeType(final String mimeType) throws MessagingException {
+        return mimeType.equals("text/plain") || mimeType.equals("text/*");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#removeHeader(java.lang.String)
+     */
+    public void removeHeader(final String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#reply(boolean)
+     */
+    @Override
+    public Message reply(final boolean replyToAll) throws MessagingException {
+        try {
+            final SimpleTextMessage reply = (SimpleTextMessage) this.clone();
+            reply._to = new LinkedList(_from);
+            if (replyToAll) {
+                reply._to.addAll(_cc);
+            }
+            return reply;
+        } catch (final CloneNotSupportedException e) {
+            throw new MessagingException(e.getMessage());
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#saveChanges()
+     */
+    @Override
+    public void saveChanges() throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setContent(jakarta.mail.Multipart)
+     */
+    public void setContent(final Multipart content) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setContent(java.lang.Object, java.lang.String)
+     */
+    public void setContent(final Object content, final String type)
+        throws MessagingException {
+        setText((String) content);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setDataHandler(jakarta.activation.DataHandler)
+     */
+    public void setDataHandler(final DataHandler handler) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setDescription(java.lang.String)
+     */
+    public void setDescription(final String description) throws MessagingException {
+        _description = description;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setDisposition(java.lang.String)
+     */
+    public void setDisposition(final String disposition) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setFileName(java.lang.String)
+     */
+    public void setFileName(final String name) throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setFlags(jakarta.mail.Flags, boolean)
+     */
+    @Override
+    public void setFlags(final Flags flags, final boolean set) throws MessagingException {
+        if (set) {
+            _flags.add(flags);
+        } else {
+            _flags.remove(flags);
+        }
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setFrom()
+     */
+    @Override
+    public void setFrom() throws MessagingException {
+        setFrom(new InternetAddress("root@localhost"));
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setFrom(jakarta.mail.Address)
+     */
+    @Override
+    public void setFrom(final Address address) throws MessagingException {
+        _from.clear();
+        _from.add(address);
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setHeader(java.lang.String, java.lang.String)
+     */
+    public void setHeader(final String name, final String value)
+        throws MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setRecipients(jakarta.mail.Message.RecipientType, jakarta.mail.Address[])
+     */
+    @Override
+    public void setRecipients(final RecipientType type, final Address[] addresses)
+        throws MessagingException {
+        final List list = getList(type);
+        list.clear();
+        list.addAll(Arrays.asList(addresses));
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setSentDate(java.util.Date)
+     */
+    @Override
+    public void setSentDate(final Date sent) throws MessagingException {
+        _sent = sent;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Message#setSubject(java.lang.String)
+     */
+    @Override
+    public void setSubject(final String subject) throws MessagingException {
+        _subject = subject;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#setText(java.lang.String)
+     */
+    public void setText(final String content) throws MessagingException {
+        _text = content;
+    }
+    /* (non-Javadoc)
+     * @see jakarta.mail.Part#writeTo(java.io.OutputStream)
+     */
+    public void writeTo(final OutputStream out)
+        throws IOException, MessagingException {
+        throw new UnsupportedOperationException("Method not implemented");
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/TestData.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/TestData.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/TestData.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/TestData.java Tue May  3 12:22:08 2022
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import jakarta.mail.internet.MimeMessage;
+
+public class TestData {
+    public static Store getTestStore() {
+        return new Store(
+            getTestSession(),
+            new URLName("http://alex@test.com")) {
+            @Override
+            public Folder getDefaultFolder() throws MessagingException {
+                return getTestFolder();
+            }
+            @Override
+            public Folder getFolder(final String name) throws MessagingException {
+                if (name.equals("test")) {
+                    return getTestFolder();
+                } else {
+                    return null;
+                }
+            }
+            @Override
+            public Folder getFolder(final URLName name) throws MessagingException {
+                return getTestFolder();
+            }
+        };
+    }
+    public static Session getTestSession() {
+        return Session.getDefaultInstance(System.getProperties());
+    }
+    public static Folder getTestFolder() {
+        return new Folder(getTestStore()) {
+            @Override
+            public void appendMessages(final Message[] messages)
+                throws MessagingException {
+            }
+            @Override
+            public void close(final boolean expunge) throws MessagingException {
+            }
+            @Override
+            public boolean create(final int type) throws MessagingException {
+                return false;
+            }
+            @Override
+            public boolean delete(final boolean recurse) throws MessagingException {
+                return false;
+            }
+            @Override
+            public boolean exists() throws MessagingException {
+                return false;
+            }
+            @Override
+            public Message[] expunge() throws MessagingException {
+                return null;
+            }
+            @Override
+            public Folder getFolder(final String name) throws MessagingException {
+                return null;
+            }
+            @Override
+            public String getFullName() {
+                return null;
+            }
+            @Override
+            public Message getMessage(final int id) throws MessagingException {
+                return null;
+            }
+            @Override
+            public int getMessageCount() throws MessagingException {
+                return 0;
+            }
+            @Override
+            public String getName() {
+                return null;
+            }
+            @Override
+            public Folder getParent() throws MessagingException {
+                return null;
+            }
+            @Override
+            public Flags getPermanentFlags() {
+                return null;
+            }
+            @Override
+            public char getSeparator() throws MessagingException {
+                return 0;
+            }
+            @Override
+            public int getType() throws MessagingException {
+                return 0;
+            }
+            @Override
+            public boolean hasNewMessages() throws MessagingException {
+                return false;
+            }
+            @Override
+            public boolean isOpen() {
+                return false;
+            }
+            @Override
+            public Folder[] list(final String pattern) throws MessagingException {
+                return null;
+            }
+            @Override
+            public void open(final int mode) throws MessagingException {
+            }
+            @Override
+            public boolean renameTo(final Folder newName) throws MessagingException {
+                return false;
+            }
+        };
+    }
+    public static Transport getTestTransport() {
+        return new Transport(
+            getTestSession(),
+            new URLName("http://host.name")) {
+            @Override
+            public void sendMessage(final Message message, final Address[] addresses)
+                throws MessagingException {
+            }
+        };
+    }
+    public static Message getMessage() {
+        return new MimeMessage(getTestFolder(), 1) {
+        };
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/URLNameTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class URLNameTest extends TestCase {
+    public URLNameTest(final 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 (final 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 (final 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 (final 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 (final 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 (final MalformedURLException e) {
+            fail();
+        }
+        
+        s = "http://john%40gmail.com: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@gmail.com", name.getUsername());
+        assertEquals("doe", name.getPassword());
+        try {
+            assertEquals(new URL(s), name.getURL());
+        } catch (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final 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 (final MalformedURLException e) {
+            fail();
+        }
+
+        name = new URLName("http", "www.apache.org", -1, "file/file2", "john@gmail.com", "doe");
+        assertEquals("http://john%40gmail.com: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@gmail.com", name.getUsername());
+        assertEquals("doe", name.getPassword());
+        try {
+            assertEquals(new URL("http://john%40gmail.com:doe@www.apache.org/file/file2"), name.getURL());
+        } catch (final 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 (final 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 (final 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() {
+        final URLName name1 = new URLName("http://www.apache.org/file");
+        final URLName name2 = new URLName("http://www.apache.org/file#ref");
+        assertTrue(name1.equals(name2));
+        assertTrue(name1.hashCode() == name2.hashCode());
+    }
+
+    public void testNullProtocol() {
+        final URLName name1 = new URLName(null, "www.apache.org", -1, null, null, null);
+        final URLName name2 = new URLName(null, "www.apache.org", -1, null, null, null);
+        assertTrue(!name2.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
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/AllEventTests.java Tue May  3 12:22:08 2022
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail.event;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AllEventTests {
+    public static Test suite() {
+        final TestSuite suite = new TestSuite("Test for jakarta.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;
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/ConnectionEventTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.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(final ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.CLOSED;
+        }
+        public void disconnected(final ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.DISCONNECTED;
+        }
+        public int getState() {
+            return state;
+        }
+        public void opened(final ConnectionEvent event) {
+            if (state != 0) {
+                fail("Recycled ConnectionListener");
+            }
+            state = ConnectionEvent.OPENED;
+        }
+    }
+    public ConnectionEventTest(final String name) {
+        super(name);
+    }
+    private void doEventTests(final int type) {
+        final ConnectionEvent event = new ConnectionEvent(this, type);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getType());
+        final 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);
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/FolderEventTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail.event;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FolderEventTest extends TestCase {
+    public FolderEventTest(final String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(FolderEvent.CREATED);
+        doEventTests(FolderEvent.RENAMED);
+        doEventTests(FolderEvent.DELETED);
+    }
+    private void doEventTests(final int type) {
+        final FolderEvent event = new FolderEvent(this, null, type);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getType());
+        final 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(final FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.CREATED;
+        }
+        public void folderDeleted(final FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.DELETED;
+        }
+        public void folderRenamed(final FolderEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = FolderEvent.RENAMED;
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageChangedEventTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail.event;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageChangedEventTest extends TestCase {
+    public MessageChangedEventTest(final String name) {
+        super(name);
+    }
+    public void testEvent() {
+        doEventTests(MessageChangedEvent.ENVELOPE_CHANGED);
+        doEventTests(MessageChangedEvent.FLAGS_CHANGED);
+    }
+    private void doEventTests(final int type) {
+        final MessageChangedEvent event = new MessageChangedEvent(this, type, null);
+        assertEquals(this, event.getSource());
+        assertEquals(type, event.getMessageChangeType());
+        final 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(final MessageChangedEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = event.getMessageChangeType();
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}

Added: geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java?rev=1900504&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java (added)
+++ geronimo/specs/trunk/geronimo-jakartamail_2.1_spec/src/test/java/jakarta/mail/event/MessageCountEventTest.java Tue May  3 12:22:08 2022
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 jakarta.mail.event;
+
+import jakarta.mail.Folder;
+import jakarta.mail.TestData;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageCountEventTest extends TestCase {
+    public MessageCountEventTest(final 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 (final IllegalArgumentException e) {
+        }
+    }
+    private void doEventTests(final int type) {
+        final Folder folder = TestData.getTestFolder();
+        final MessageCountEvent event =
+            new MessageCountEvent(folder, type, false, null);
+        assertEquals(folder, event.getSource());
+        assertEquals(type, event.getType());
+        final 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(final MessageCountEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = MessageCountEvent.ADDED;
+        }
+        public void messagesRemoved(final MessageCountEvent event) {
+            if (state != 0) {
+                fail("Recycled Listener");
+            }
+            state = MessageCountEvent.REMOVED;
+        }
+        public int getState() {
+            return state;
+        }
+    }
+}