Author: norman
Date: Tue May 30 02:26:45 2006
New Revision: 410228

URL: http://svn.apache.org/viewvc?rev=410228&view=rev
Log:
Correct a bug in MockMatcherConfig and add junit test for All matcher

Added:
    james/server/trunk/src/test/org/apache/james/transport/matchers/AllTest.java
Modified:
    
james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMatcherConfig.java

Modified: 
james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMatcherConfig.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMatcherConfig.java?rev=410228&r1=410227&r2=410228&view=diff
==============================================================================
--- 
james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMatcherConfig.java
 (original)
+++ 
james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMatcherConfig.java
 Tue May 30 02:26:45 2006
@@ -35,7 +35,12 @@
     }
 
     public String getCondition() {
-        return matcherName.substring(getMatcherName().length() + 1);
+        if (matcherName.contains("=")) {
+            return matcherName.substring(getMatcherName().length() + 1);
+
+        } else {
+            return null;
+        }
     }
 
     public MailetContext getMailetContext() {
@@ -43,7 +48,11 @@
     }
 
     public String getMatcherName() {
-        return matcherName.split("=")[0];
+        if (matcherName.contains("=")) {
+            return matcherName.split("=")[0];
+        } else {
+            return matcherName;
+        }
     }
 
 }

Added: 
james/server/trunk/src/test/org/apache/james/transport/matchers/AllTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/transport/matchers/AllTest.java?rev=410228&view=auto
==============================================================================
--- 
james/server/trunk/src/test/org/apache/james/transport/matchers/AllTest.java 
(added)
+++ 
james/server/trunk/src/test/org/apache/james/transport/matchers/AllTest.java 
Tue May 30 02:26:45 2006
@@ -0,0 +1,67 @@
+/***********************************************************************
+ * 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 org.apache.james.test.mock.mailet.MockMail;
+import org.apache.james.test.mock.mailet.MockMailContext;
+import org.apache.james.test.mock.mailet.MockMatcherConfig;
+
+import org.apache.mailet.Matcher;
+
+import javax.mail.MessagingException;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+public class AllTest extends TestCase {
+
+    private MockMail mockedMail;
+
+    private Matcher matcher;
+
+    public AllTest(String arg0) throws UnsupportedEncodingException {
+        super(arg0);
+    }
+
+    private void setupMockedMail() {
+        mockedMail = new MockMail();
+        mockedMail.setRecipients(Arrays.asList(new String[] {
+                "[EMAIL PROTECTED]", "[EMAIL PROTECTED]" }));
+
+    }
+
+    private void setupMatcher() throws MessagingException {
+        matcher = new All();
+        MockMatcherConfig mci = new MockMatcherConfig("All",
+                new MockMailContext());
+        matcher.init(mci);
+    }
+
+    // test if all recipients was returned
+    public void testAllRecipientsReturned() throws MessagingException {
+        setupMockedMail();
+        setupMatcher();
+
+        assertTrue(matcher.match(mockedMail) != null);
+        assertEquals(matcher.match(mockedMail).size(), mockedMail
+                .getRecipients().size());
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to