You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/06/22 20:10:03 UTC

svn commit: r416435 - /james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java

Author: norman
Date: Thu Jun 22 11:10:02 2006
New Revision: 416435

URL: http://svn.apache.org/viewvc?rev=416435&view=rev
Log:
Add UserIs matcher junit test

Added:
    james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java

Added: james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java?rev=416435&view=auto
==============================================================================
--- james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java (added)
+++ james/server/trunk/src/test/org/apache/james/transport/matchers/UserIsTest.java Thu Jun 22 11:10:02 2006
@@ -0,0 +1,86 @@
+/***********************************************************************
+ * Copyright (c) 2006 The Apache Software Foundation.                  *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You    *
+ * may obtain a copy of the License at:                                *
+ *                                                                     *
+ *     http://www.apache.org/licenses/LICENSE-2.0                      *
+ *                                                                     *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS,   *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
+ * implied.  See the License for the specific language governing       *
+ * permissions and limitations under the License.                      *
+ ***********************************************************************/
+
+package org.apache.james.transport.matchers;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.Matcher;
+
+public class UserIsTest extends AbstractRecipientIsTest {
+
+    private final String USER = "test";
+
+    public UserIsTest(String arg0) throws UnsupportedEncodingException {
+        super(arg0);
+    }
+
+    protected String getRecipientName() {
+        return USER;
+    }
+
+    // test if the recipients get returned as matched
+    public void testHostIsMatchedAllRecipients() throws MessagingException {
+        setRecipients(new MailAddress[] { new MailAddress(
+                "test@james.apache.org") });
+
+        setupMockedMail();
+        setupMatcher();
+
+        Collection matchedRecipients = matcher.match(mockedMail);
+
+        assertNotNull(matchedRecipients);
+        assertEquals(matchedRecipients.size(), mockedMail.getRecipients()
+                .size());
+    }
+
+    // test if one recipients get returned as matched
+    public void testHostIsMatchedOneRecipient() throws MessagingException {
+        setRecipients(new MailAddress[] {
+                new MailAddress("test@james.apache.org"),
+                new MailAddress("test2@james.apache.org") });
+
+        setupAll();
+
+        Collection matchedRecipients = matcher.match(mockedMail);
+
+        assertNotNull(matchedRecipients);
+        assertEquals(matchedRecipients.size(), 1);
+    }
+
+    // test if no recipient get returned cause it not match
+    public void testHostIsNotMatch() throws MessagingException {
+        setRecipients(new MailAddress[] {
+                new MailAddress("test2@james2.apache.org"),
+                new MailAddress("test2@james.apache.org") });
+
+        setupMockedMail();
+        setupMatcher();
+
+        Collection matchedRecipients = matcher.match(mockedMail);
+
+        assertEquals(matchedRecipients.size(), 0);
+    }
+
+    protected Matcher createMatcher() {
+        return new UserIs();
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org