james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r413450 - in /james/server/trunk/src: java/org/apache/james/transport/matchers/RecipientIsRegex.java test/org/apache/james/transport/matchers/RecipientIsRegexTest.java
Date Sun, 11 Jun 2006 14:23:37 GMT
Author: norman
Date: Sun Jun 11 07:23:36 2006
New Revision: 413450

URL: http://svn.apache.org/viewvc?rev=413450&view=rev
Log:
Throw exception on empty pattern.
Add junit test for this

Modified:
    james/server/trunk/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java
    james/server/trunk/src/test/org/apache/james/transport/matchers/RecipientIsRegexTest.java

Modified: james/server/trunk/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java?rev=413450&r1=413449&r2=413450&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java
(original)
+++ james/server/trunk/src/java/org/apache/james/transport/matchers/RecipientIsRegex.java
Sun Jun 11 07:23:36 2006
@@ -47,7 +47,7 @@
 
     public void init() throws javax.mail.MessagingException {
         String patternString = getCondition();
-        if (patternString == null) {
+        if ((patternString == null) || (patternString.equals("")) ) {
             throw new MessagingException("Pattern is missing");
         }
         

Modified: james/server/trunk/src/test/org/apache/james/transport/matchers/RecipientIsRegexTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/transport/matchers/RecipientIsRegexTest.java?rev=413450&r1=413449&r2=413450&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/transport/matchers/RecipientIsRegexTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/transport/matchers/RecipientIsRegexTest.java
Sun Jun 11 07:23:36 2006
@@ -98,12 +98,29 @@
             setupAll();
             matchedRecipients = matcher.match(mockedMail);
         } catch (MessagingException m) {
-            m.printStackTrace();
             regexException = m.getMessage();
         }
 
         assertNull(matchedRecipients);
         assertEquals(regexException, exception);
+
+    }
+
+    // test if an exception was thrown cause the regex was invalid
+    public void testThrowExceptionWithEmptyPattern() throws MessagingException {
+        boolean catchException = false;
+
+        setRecipients(new MailAddress[] {
+                new MailAddress("test@james2.apache.org"),
+                new MailAddress("test2@james2.apache.org") });
+        setRegex("");
+
+        try {
+            setupAll();
+        } catch (MessagingException m) {
+            catchException = true;
+        }
+        assertTrue(catchException);
 
     }
 



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


Mime
View raw message