Author: ieugen
Date: Mon Mar 12 00:45:25 2012
New Revision: 1299509

URL: http://svn.apache.org/viewvc?rev=1299509&view=rev
Log:
JAMES-1393

- updated tests to juni 4.x style
- added @Override and reformated code
Issue #JAMES-1393 - Upgrate all test suites to junit 4.10

Modified:
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessorTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
    
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/MailetConfigImplTest.java
 Mon Mar 12 00:45:25 2012
@@ -16,80 +16,78 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.impl;
 
 import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-
-import javax.mail.MessagingException;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
-import org.apache.james.mailetcontainer.impl.MailetConfigImpl;
-import org.apache.mailet.Mail;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
-public class MailetConfigImplTest extends TestCase{
+public class MailetConfigImplTest {
 
+    @Test
     public void testDotParamsFromXML() throws ConfigurationException {
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.load(new 
ByteArrayInputStream("<mailet><mail.debug>true</mail.debug></mailet>".getBytes()));
-        
-        MailetConfigImpl config = new MailetConfigImpl();
-        config.setConfiguration(builder);
-        
-        String param = config.getInitParameterNames().next();
-        assertEquals("mail.debug", param);
-        assertEquals("true", config.getInitParameter(param));
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.load(new 
ByteArrayInputStream("<mailet><mail.debug>true</mail.debug></mailet>".getBytes()));
+
+       MailetConfigImpl config = new MailetConfigImpl();
+       config.setConfiguration(builder);
+
+       String param = config.getInitParameterNames().next();
+       assertEquals("mail.debug", param);
+       assertEquals("true", config.getInitParameter(param));
     }
-    
+
+    @Test
     public void testDotParamsFromConfig() throws ConfigurationException {
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.addProperty("mail.debug", "true");
-        
-        MailetConfigImpl config = new MailetConfigImpl();
-        config.setConfiguration(builder);
-        
-        String param = config.getInitParameterNames().next();
-        assertEquals("mail.debug", param);
-        assertEquals("true", config.getInitParameter(param));
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.addProperty("mail.debug", "true");
+
+       MailetConfigImpl config = new MailetConfigImpl();
+       config.setConfiguration(builder);
+
+       String param = config.getInitParameterNames().next();
+       assertEquals("mail.debug", param);
+       assertEquals("true", config.getInitParameter(param));
     }
-    
+
     // See JAMES-1232
+    @Test
     public void testParamWithComma() throws ConfigurationException {
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.load(new 
ByteArrayInputStream("<mailet><whatever>value1,value2</whatever></mailet>".getBytes()));
-        
-        MailetConfigImpl config = new MailetConfigImpl();
-        config.setConfiguration(builder);
-        
-        String param = config.getInitParameterNames().next();
-        assertEquals("whatever", param);
-        assertEquals("value1,value2", config.getInitParameter(param));
-    } 
-    
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.load(new 
ByteArrayInputStream("<mailet><whatever>value1,value2</whatever></mailet>".getBytes()));
+
+       MailetConfigImpl config = new MailetConfigImpl();
+       config.setConfiguration(builder);
+
+       String param = config.getInitParameterNames().next();
+       assertEquals("whatever", param);
+       assertEquals("value1,value2", config.getInitParameter(param));
+    }
+
+    @Test
     public void testParamWithXmlSpace() throws ConfigurationException {
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.setDelimiterParsingDisabled(true);
-        builder.load(new ByteArrayInputStream("<mailet><whatever 
xml:space=\"preserve\"> some text </whatever></mailet>".getBytes()));
-
-        MailetConfigImpl config = new MailetConfigImpl();
-        config.setConfiguration(builder);
-
-        String param = config.getInitParameterNames().next();
-        assertEquals("whatever", param);
-        assertEquals(" some text ", config.getInitParameter(param));
-               
-        List<String> parms = new ArrayList<String>();
-        Iterator<String> iter = config.getInitParameterNames();
-        while (iter.hasNext())
-        {
-            parms.add(iter.next());
-        }
-        assertEquals(parms.size(), 1);             
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.setDelimiterParsingDisabled(true);
+       builder.load(new ByteArrayInputStream("<mailet><whatever 
xml:space=\"preserve\"> some text </whatever></mailet>".
+               getBytes()));
+
+       MailetConfigImpl config = new MailetConfigImpl();
+       config.setConfiguration(builder);
+
+       String param = config.getInitParameterNames().next();
+       assertEquals("whatever", param);
+       assertEquals(" some text ", config.getInitParameter(param));
+
+       List<String> parms = new ArrayList<String>();
+       Iterator<String> iter = config.getInitParameterNames();
+       while (iter.hasNext()) {
+           parms.add(iter.next());
+       }
+       assertEquals(parms.size(), 1);
     }
 }

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelCompositeProcessorTest.java
 Mon Mar 12 00:45:25 2012
@@ -24,9 +24,8 @@ import org.apache.commons.configuration.
 import org.apache.james.mailetcontainer.api.mock.MockMailetContext;
 import org.apache.james.mailetcontainer.api.mock.MockMailetLoader;
 import org.apache.james.mailetcontainer.api.mock.MockMatcherLoader;
-import org.apache.james.mailetcontainer.impl.camel.CamelCompositeProcessor;
-import 
org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessorTest;
 import org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor;
+import 
org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessorTest;
 import org.slf4j.LoggerFactory;
 
 public class CamelCompositeProcessorTest extends 
AbstractStateCompositeProcessorTest {

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessorTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessorTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessorTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/camel/CamelMailetProcessorTest.java
 Mon Mar 12 00:45:25 2012
@@ -25,7 +25,6 @@ import org.apache.commons.configuration.
 import org.apache.james.mailetcontainer.api.mock.MockMailetContext;
 import org.apache.james.mailetcontainer.api.mock.MockMailetLoader;
 import org.apache.james.mailetcontainer.api.mock.MockMatcherLoader;
-import org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessor;
 import org.apache.james.mailetcontainer.lib.AbstractStateMailetProcessorTest;
 import org.slf4j.Logger;

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/AndTest.java
 Mon Mar 12 00:45:25 2012
@@ -16,11 +16,12 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.impl.matchers;
 
-import org.apache.james.mailetcontainer.impl.matchers.And;
-import org.apache.james.mailetcontainer.impl.matchers.CompositeMatcher;
+import java.util.Arrays;
+import java.util.Collection;
+import javax.mail.MessagingException;
+import javax.mail.internet.ParseException;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
@@ -28,32 +29,20 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
-import javax.mail.MessagingException;
-import javax.mail.internet.ParseException;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-public class AndTest extends TestCase {
+public class AndTest {
 
     private FakeMailContext context;
     private FakeMail mockedMail;
-
     private CompositeMatcher matcher;
 
-    public AndTest(String arg0) throws UnsupportedEncodingException {
-        super(arg0);
-    }
-
     private void setupMockedMail() throws ParseException {
-        mockedMail = new FakeMail();
-        mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
-        new MailAddress("[email protected]"),
-        new MailAddress("[email protected]") }));
+       mockedMail = new FakeMail();
+       mockedMail.setRecipients(Arrays.asList(new MailAddress[]{
+                   new MailAddress("[email protected]"),
+                   new MailAddress("[email protected]")}));
 
     }
 
@@ -62,56 +51,52 @@ public class AndTest extends TestCase {
      * @throws MessagingException
      */
     private void setupMatcher() throws MessagingException {
-        context = new FakeMailContext();
-        matcher = new And();
-        FakeMatcherConfig mci = new FakeMatcherConfig("And",context);
-        matcher.init(mci);
-    }
-    
-    private void setupChild(String match) throws MessagingException
-    {
-        Matcher child = null;
-        if (match.equals("All"))
-        {
-            child = new All();
-        }
-        else
-        {
-            child = new RecipientIs();
-        }
-        FakeMatcherConfig sub = new FakeMatcherConfig(match,context);
-        child.init(sub);
-        matcher.add(child);
-        
+       context = new FakeMailContext();
+       matcher = new And();
+       FakeMatcherConfig mci = new FakeMatcherConfig("And", context);
+       matcher.init(mci);
+    }
+
+    private void setupChild(String match) throws MessagingException {
+       Matcher child = null;
+       if (match.equals("All")) {
+           child = new All();
+       } else {
+           child = new RecipientIs();
+       }
+       FakeMatcherConfig sub = new FakeMatcherConfig(match, context);
+       child.init(sub);
+       matcher.add(child);
+
     }
 
     // test if all recipients was returned
+    @Test
     public void testAndIntersectSameTwice() throws MessagingException {
-        setupMockedMail();
-        setupMatcher();
-        setupChild("[email protected]");
-        setupChild("[email protected]");
-        setupChild("All");
-            
-        Collection matchedRecipients = matcher.match(mockedMail);
-
-        assertNotNull(matchedRecipients);
-        assertEquals(1,matchedRecipients.size());
-        MailAddress address = (MailAddress)matchedRecipients.iterator().next();
-        assertEquals(address,"[email protected]");
+       setupMockedMail();
+       setupMatcher();
+       setupChild("[email protected]");
+       setupChild("[email protected]");
+       setupChild("All");
+
+       Collection matchedRecipients = matcher.match(mockedMail);
+
+       assertNotNull(matchedRecipients);
+       assertEquals(1, matchedRecipients.size());
+       MailAddress address = (MailAddress) matchedRecipients.iterator().next();
+       assertEquals(address, "[email protected]");
     }
-    
+
+    @Test
     public void testAndNoIntersect() throws MessagingException {
-        setupMockedMail();
-        setupMatcher();
-        setupChild("[email protected]");
-        setupChild("[email protected]");
-            
-        Collection matchedRecipients = matcher.match(mockedMail);
+       setupMockedMail();
+       setupMatcher();
+       setupChild("[email protected]");
+       setupChild("[email protected]");
 
-        assertNotNull(matchedRecipients);
-        assertEquals(0,matchedRecipients.size());
-    }
-    
+       Collection matchedRecipients = matcher.match(mockedMail);
 
+       assertNotNull(matchedRecipients);
+       assertEquals(0, matchedRecipients.size());
+    }
 }

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/OrTest.java
 Mon Mar 12 00:45:25 2012
@@ -19,35 +19,26 @@
 
 package org.apache.james.mailetcontainer.impl.matchers;
 
-import org.apache.james.mailetcontainer.impl.matchers.CompositeMatcher;
-import org.apache.james.mailetcontainer.impl.matchers.Or;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import javax.mail.MessagingException;
+import javax.mail.internet.ParseException;
 import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
-import javax.mail.MessagingException;
-import javax.mail.internet.ParseException;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-public class OrTest extends TestCase {
+public class OrTest {
 
     private FakeMail mockedMail;
 
     private CompositeMatcher matcher;
 
-    public OrTest(String arg0) throws UnsupportedEncodingException {
-        super(arg0);
-    }
-
     private void setupMockedMail() throws ParseException {
         mockedMail = new FakeMail();
         mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
@@ -78,6 +69,7 @@ public class OrTest extends TestCase {
     }
 
     // test if all recipients was returned
+    @Test
     public void testAllRecipientsReturned() throws MessagingException {
         setupMockedMail();
         setupMatcher();

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/impl/matchers/XorTest.java
 Mon Mar 12 00:45:25 2012
@@ -16,11 +16,13 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.impl.matchers;
 
-import org.apache.james.mailetcontainer.impl.matchers.CompositeMatcher;
-import org.apache.james.mailetcontainer.impl.matchers.Xor;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import javax.mail.MessagingException;
+import javax.mail.internet.ParseException;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
@@ -28,33 +30,20 @@ import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.mailet.base.test.FakeMatcherConfig;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
-import javax.mail.MessagingException;
-import javax.mail.internet.ParseException;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-public class XorTest extends TestCase {
+public class XorTest {
 
     private FakeMailContext context;
     private FakeMail mockedMail;
-
     private CompositeMatcher matcher;
 
-    public XorTest(String arg0) throws UnsupportedEncodingException {
-        super(arg0);
-    }
-
     private void setupMockedMail() throws ParseException {
-        mockedMail = new FakeMail();
-        mockedMail.setRecipients(Arrays.asList(new MailAddress[] {
-        new MailAddress("[email protected]"),
-        new MailAddress("[email protected]") }));
+       mockedMail = new FakeMail();
+       mockedMail.setRecipients(Arrays.asList(new MailAddress[]{
+                   new MailAddress("[email protected]"),
+                   new MailAddress("[email protected]")}));
 
     }
 
@@ -63,59 +52,55 @@ public class XorTest extends TestCase {
      * @throws MessagingException
      */
     private void setupMatcher() throws MessagingException {
-        context = new FakeMailContext();
-        matcher = new Xor();
-        FakeMatcherConfig mci = new FakeMatcherConfig("Xor",context);
-        matcher.init(mci);
-    }
-    
-    private void setupChild(String match) throws MessagingException
-    {
-        Matcher child = null;
-        if (match.equals("All"))
-        {
-            child = new All();
-        }
-        else
-        {
-            child = new RecipientIs();
-        }
-        FakeMatcherConfig sub = new FakeMatcherConfig(match,context);
-        child.init(sub);
-        matcher.add(child);
-        
+       context = new FakeMailContext();
+       matcher = new Xor();
+       FakeMatcherConfig mci = new FakeMatcherConfig("Xor", context);
+       matcher.init(mci);
+    }
+
+    private void setupChild(String match) throws MessagingException {
+       Matcher child = null;
+       if (match.equals("All")) {
+           child = new All();
+       } else {
+           child = new RecipientIs();
+       }
+       FakeMatcherConfig sub = new FakeMatcherConfig(match, context);
+       child.init(sub);
+       matcher.add(child);
+
     }
 
     // test if all recipients was returned
+    @Test
     public void testIntersectSame() throws MessagingException {
-        setupMockedMail();
-        setupMatcher();
-        setupChild("[email protected]");
-        setupChild("[email protected]");
-            
-        Collection matchedRecipients = matcher.match(mockedMail);
+       setupMockedMail();
+       setupMatcher();
+       setupChild("[email protected]");
+       setupChild("[email protected]");
+
+       Collection matchedRecipients = matcher.match(mockedMail);
 
-        assertNotNull(matchedRecipients);
-        assertEquals(0,matchedRecipients.size());
+       assertNotNull(matchedRecipients);
+       assertEquals(0, matchedRecipients.size());
     }
-    
+
+    @Test
     public void testNoIntersect() throws MessagingException {
-        setupMockedMail();
-        setupMatcher();
-        setupChild("[email protected]");
-        setupChild("[email protected]");
-            
-        Collection matchedRecipients = matcher.match(mockedMail);
-
-        assertNotNull(matchedRecipients);
-        assertEquals(2,matchedRecipients.size());
-        
-        Iterator iterator = matchedRecipients.iterator();
-        MailAddress address = (MailAddress)iterator.next();
-        assertEquals(address,"[email protected]");
-        address = (MailAddress)iterator.next();
-        assertEquals(address,"[email protected]");
+       setupMockedMail();
+       setupMatcher();
+       setupChild("[email protected]");
+       setupChild("[email protected]");
+
+       Collection matchedRecipients = matcher.match(mockedMail);
+
+       assertNotNull(matchedRecipients);
+       assertEquals(2, matchedRecipients.size());
+
+       Iterator iterator = matchedRecipients.iterator();
+       MailAddress address = (MailAddress) iterator.next();
+       assertEquals(address, "[email protected]");
+       address = (MailAddress) iterator.next();
+       assertEquals(address, "[email protected]");
     }
-    
-
 }

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateCompositeProcessorTest.java
 Mon Mar 12 00:45:25 2012
@@ -21,11 +21,7 @@ package org.apache.james.mailetcontainer
 import java.io.ByteArrayInputStream;
 import java.util.Arrays;
 import java.util.List;
-
 import javax.mail.MessagingException;
-
-import junit.framework.TestCase;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
@@ -33,129 +29,132 @@ import org.apache.james.core.MailImpl;
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.james.mailetcontainer.api.mock.MockMailProcessor;
 import org.apache.mailet.Mail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractStateCompositeProcessorTest extends TestCase{
+public abstract class AbstractStateCompositeProcessorTest {
 
-    
+    @Test
     public void testChooseRightProcessor() throws Exception {
-        AbstractStateCompositeProcessor processor = new 
AbstractStateCompositeProcessor() {
-            
-            @Override
-            protected MailProcessor createMailProcessor(final String state, 
HierarchicalConfiguration config) throws Exception {
-                return new MockMailProcessor("") {
-
-                    @Override
-                    public void service(Mail mail) throws MessagingException {
-                        // check if the right processor was selected depending 
on the state
-                        assertEquals(state, mail.getState());
-                        super.service(mail);
-                    }
-                    
-                };
-            }
-        };
-        Logger log = LoggerFactory.getLogger("MockLog");
-        // slf4j can't set programmatically any log level. It's just a facade
-        // log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
-        processor.setLog(log);
-        
processor.configure(createConfig(Arrays.asList("root","error","test")));
-        processor.init();
-        
-        try {
-            Mail mail1 = new MailImpl();
-            mail1.setState(Mail.DEFAULT);
-            Mail mail2 = new MailImpl();
-            mail2.setState(Mail.ERROR);
-
-            Mail mail3 = new MailImpl();
-            mail3.setState("test");
-
-            Mail mail4 = new MailImpl();
-            mail4.setState("invalid");
-            
-            processor.service(mail1);
-            processor.service(mail2);
-            processor.service(mail3);
-            
-            try {
-                processor.service(mail4);
-                fail("should fail because of no mapping to a processor for 
this state");
-            } catch (MessagingException e) {
-                
-            }
-            
-        } finally {
-            processor.dispose();
-        }
-        
+       AbstractStateCompositeProcessor processor = new 
AbstractStateCompositeProcessor() {
+
+           @Override
+           protected MailProcessor createMailProcessor(final String state, 
HierarchicalConfiguration config) throws
+                   Exception {
+               return new MockMailProcessor("") {
+
+                   @Override
+                   public void service(Mail mail) throws MessagingException {
+                       // check if the right processor was selected depending 
on the state
+                       assertEquals(state, mail.getState());
+                       super.service(mail);
+                   }
+               };
+           }
+       };
+       Logger log = LoggerFactory.getLogger("MockLog");
+       // slf4j can't set programmatically any log level. It's just a facade
+       // log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
+       processor.setLog(log);
+       processor.configure(createConfig(Arrays.asList("root", "error", 
"test")));
+       processor.init();
+
+       try {
+           Mail mail1 = new MailImpl();
+           mail1.setState(Mail.DEFAULT);
+           Mail mail2 = new MailImpl();
+           mail2.setState(Mail.ERROR);
+
+           Mail mail3 = new MailImpl();
+           mail3.setState("test");
+
+           Mail mail4 = new MailImpl();
+           mail4.setState("invalid");
+
+           processor.service(mail1);
+           processor.service(mail2);
+           processor.service(mail3);
+
+           try {
+               processor.service(mail4);
+               fail("should fail because of no mapping to a processor for this 
state");
+           } catch (MessagingException e) {
+           }
+
+       } finally {
+           processor.dispose();
+       }
+
     }
 
-    
-    protected abstract AbstractStateCompositeProcessor 
createProcessor(HierarchicalConfiguration config) throws 
ConfigurationException, Exception;
-    
-    
+    protected abstract AbstractStateCompositeProcessor 
createProcessor(HierarchicalConfiguration config) throws
+           ConfigurationException, Exception;
+
+    @Test
     public void testGhostProcessor() throws Exception {
-        AbstractStateCompositeProcessor processor = null;
+       AbstractStateCompositeProcessor processor = null;
+
+       try {
+           processor = createProcessor(createConfig(Arrays.asList("root", 
"error", "ghost")));
 
-        try {
-            processor = createProcessor(createConfig(Arrays.asList("root", 
"error", "ghost")));
+           fail("ghost processor should not be allowed");
+       } catch (ConfigurationException e) {
+           // expected
+       } finally {
+           if (processor != null) {
+               processor.dispose();
+           }
+       }
 
-            fail("ghost processor should not be allowed");
-        } catch (ConfigurationException e) {
-            // expected
-        } finally {
-            if (processor != null) {
-                processor.dispose();
-            }
-        }
-       
     }
-    
+
+    @Test
     public void testNoRootProcessor() throws Exception {
-        AbstractStateCompositeProcessor processor = null;
-        try {
-            processor = createProcessor(createConfig(Arrays.asList("test", 
"error")));
-            fail("root processor is needed");
-        } catch (ConfigurationException e) {
-            // expected
-        } finally {
-            if (processor != null) {
-                processor.dispose();
-            }
-        }
+       AbstractStateCompositeProcessor processor = null;
+       try {
+           processor = createProcessor(createConfig(Arrays.asList("test", 
"error")));
+           fail("root processor is needed");
+       } catch (ConfigurationException e) {
+           // expected
+       } finally {
+           if (processor != null) {
+               processor.dispose();
+           }
+       }
     }
-    
+
+    @Test
     public void testNoErrorProcessor() throws Exception {
-        AbstractStateCompositeProcessor processor = null;
-        try {
-            processor = createProcessor(createConfig(Arrays.asList("test", 
"root")));
-            fail("error processor is needed");
-        } catch (ConfigurationException e) {
-            // expected
-        } finally {
-            if (processor != null) {
-                processor.dispose();
-            }
-        }
+       AbstractStateCompositeProcessor processor = null;
+       try {
+           processor = createProcessor(createConfig(Arrays.asList("test", 
"root")));
+           fail("error processor is needed");
+       } catch (ConfigurationException e) {
+           // expected
+       } finally {
+           if (processor != null) {
+               processor.dispose();
+           }
+       }
     }
-    
+
     private HierarchicalConfiguration createConfig(List<String> states) throws 
ConfigurationException {
 
-        StringBuilder sb = new StringBuilder();
-        sb.append("<?xml version=\"1.0\"?>");
-        sb.append("<processors>");
-        for (int i = 0 ; i < states.size(); i++) {
-            sb.append("<processor state=\"");
-            sb.append(states.get(i));
-            sb.append("\"/>");
-        }
-        sb.append("</processors>");
-
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.load(new ByteArrayInputStream(sb.toString().getBytes()));
-        return builder;
+       StringBuilder sb = new StringBuilder();
+       sb.append("<?xml version=\"1.0\"?>");
+       sb.append("<processors>");
+       for (int i = 0; i < states.size(); i++) {
+           sb.append("<processor state=\"");
+           sb.append(states.get(i));
+           sb.append("\"/>");
+       }
+       sb.append("</processors>");
+
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.load(new ByteArrayInputStream(sb.toString().getBytes()));
+       return builder;
     }
-    
 }

Modified: 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java?rev=1299509&r1=1299508&r2=1299509&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
 (original)
+++ 
james/server/trunk/mailetcontainer-camel/src/test/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessorTest.java
 Mon Mar 12 00:45:25 2012
@@ -16,16 +16,13 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.lib;
 
 import java.io.ByteArrayInputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
-
 import javax.mail.MessagingException;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.configuration.HierarchicalConfiguration;
@@ -39,207 +36,224 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
+import static org.junit.Assert.*;
+import org.junit.Test;
 
-import junit.framework.TestCase;
-
-public abstract class AbstractStateMailetProcessorTest extends TestCase{
-
-    protected abstract AbstractStateMailetProcessor 
createProcessor(HierarchicalConfiguration configuration) throws 
ConfigurationException, Exception;
+public abstract class AbstractStateMailetProcessorTest {
 
+    protected abstract AbstractStateMailetProcessor 
createProcessor(HierarchicalConfiguration configuration) throws
+           ConfigurationException, Exception;
 
-    
-    private HierarchicalConfiguration createConfig(Class<?> matcherClass, 
Class<?> mailetClass, int count) throws ConfigurationException {
-        StringBuilder sb = new StringBuilder();
-        sb.append("<processor state=\"" + Mail.DEFAULT + "\">");
-        sb.append("<mailet 
match=\"").append(matcherClass.getName()).append("=").append(count).append("\"").append("
 class=\"").append(mailetClass.getName()).append("\">");
-        sb.append("<state>test</state>");
-        sb.append("</mailet>");
-        
-        sb.append("</processor>");
-        
-        DefaultConfigurationBuilder builder = new 
DefaultConfigurationBuilder();
-        builder.load(new ByteArrayInputStream(sb.toString().getBytes()));
-        return builder;
+    private HierarchicalConfiguration createConfig(Class<?> matcherClass, 
Class<?> mailetClass, int count) throws
+           ConfigurationException {
+       StringBuilder sb = new StringBuilder();
+       sb.append("<processor state=\"" + Mail.DEFAULT + "\">");
+       sb.append("<mailet 
match=\"").append(matcherClass.getName()).append("=").append(count).append("\"").append(
+               " class=\"").append(mailetClass.getName()).append("\">");
+       sb.append("<state>test</state>");
+       sb.append("</mailet>");
+
+       sb.append("</processor>");
+
+       DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+       builder.load(new ByteArrayInputStream(sb.toString().getBytes()));
+       return builder;
     }
-    
-    
+
+    @Test
     public void testSimpleRouting() throws ConfigurationException, Exception {
-        final CountDownLatch latch = new CountDownLatch(2);
-        final MailImpl mail = new MailImpl();
-        mail.setName(MailImpl.getId());
-        mail.setSender(new MailAddress("test@localhost"));
-        mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), 
new MailAddress("test2@localhost")));
-        
-        AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class, MockMailet.class, 1));
-        processor.addListener(new MailetProcessorListener() {
-                        
-            public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients, Collection<MailAddress> matches, long 
processTime, MessagingException e) {
-                if (MockMatcher.class.equals(m.getClass())) {
-                    assertEquals(mail.getName(), mailName);
-                    // match one recipient
-                    assertEquals(1, matches.size());
-                    assertNull(e);
-                    latch.countDown();
-                }
-
-            }
-            
-            public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
-                // check for class name as the terminating  mailet will kick 
in too
-
-                if (MockMailet.class.equals(m.getClass())) {
-                    //assertEquals(mail.getName(), mailName);
-                    assertEquals("test", state);
-                    assertNull(e);
-                    latch.countDown();
-                }
-            }
-        });
-       
-        assertEquals(Mail.DEFAULT, mail.getState());
-        processor.service(mail);
-        
-        
-        // the source mail should be ghosted as it reached the end of 
processor as only one recipient matched 
-        assertEquals(Mail.GHOST, mail.getState());
-        latch.await();
-        processor.destroy();
+       final CountDownLatch latch = new CountDownLatch(2);
+       final MailImpl mail = new MailImpl();
+       mail.setName(MailImpl.getId());
+       mail.setSender(new MailAddress("test@localhost"));
+       mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), new 
MailAddress("test2@localhost")));
+
+       AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class, MockMailet.class, 1));
+       processor.addListener(new MailetProcessorListener() {
+
+           @Override
+           public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients,
+                                    Collection<MailAddress> matches, long 
processTime, MessagingException e) {
+               if (MockMatcher.class.equals(m.getClass())) {
+                   assertEquals(mail.getName(), mailName);
+                   // match one recipient
+                   assertEquals(1, matches.size());
+                   assertNull(e);
+                   latch.countDown();
+               }
+
+           }
+
+           @Override
+           public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
+               // check for class name as the terminating  mailet will kick in 
too
+
+               if (MockMailet.class.equals(m.getClass())) {
+                   //assertEquals(mail.getName(), mailName);
+                   assertEquals("test", state);
+                   assertNull(e);
+                   latch.countDown();
+               }
+           }
+       });
+
+       assertEquals(Mail.DEFAULT, mail.getState());
+       processor.service(mail);
+
+
+       // the source mail should be ghosted as it reached the end of processor 
as only one recipient matched
+       assertEquals(Mail.GHOST, mail.getState());
+       latch.await();
+       processor.destroy();
 
     }
-    
+
+    @Test
     public void testSimpleRoutingMatchAll() throws ConfigurationException, 
Exception {
-        final CountDownLatch latch = new CountDownLatch(2);
-        final MailImpl mail = new MailImpl();
-        mail.setName(MailImpl.getId());
-        mail.setSender(new MailAddress("test@localhost"));
-        mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), 
new MailAddress("test2@localhost")));
-        
-        AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class, MockMailet.class, 2));
-        processor.addListener(new MailetProcessorListener() {
-                        
-            public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients, Collection<MailAddress> matches, long 
processTime, MessagingException e) {
-                if (MockMatcher.class.equals(m.getClass())) {
-                    assertEquals(mail.getName(), mailName);
-                    // match all recipient
-                    assertEquals(2, matches.size());
-                    assertNull(e);
-                    latch.countDown();
-                }
-
-            }
-            
-            public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
-                // check for class name as the terminating  mailet will kick 
in too
-
-                if (MockMailet.class.equals(m.getClass())) {
-                    // the name should be the same as we have a full match
-                    assertEquals(mail.getName(), mailName);
-                    assertEquals("test", state);
-                    assertNull(e);
-                    latch.countDown();
-                }
-            }
-        });
-       
-        assertEquals(Mail.DEFAULT, mail.getState());
-        processor.service(mail);
-        
-        
-        // the source mail should have the new state as it was a full match
-        assertEquals("test", mail.getState());
-        latch.await();
-        processor.destroy();
+       final CountDownLatch latch = new CountDownLatch(2);
+       final MailImpl mail = new MailImpl();
+       mail.setName(MailImpl.getId());
+       mail.setSender(new MailAddress("test@localhost"));
+       mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), new 
MailAddress("test2@localhost")));
+
+       AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class, MockMailet.class, 2));
+       processor.addListener(new MailetProcessorListener() {
+
+           @Override
+           public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients,
+                                    Collection<MailAddress> matches, long 
processTime, MessagingException e) {
+               if (MockMatcher.class.equals(m.getClass())) {
+                   assertEquals(mail.getName(), mailName);
+                   // match all recipient
+                   assertEquals(2, matches.size());
+                   assertNull(e);
+                   latch.countDown();
+               }
+
+           }
+
+           @Override
+           public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
+               // check for class name as the terminating  mailet will kick in 
too
+
+               if (MockMailet.class.equals(m.getClass())) {
+                   // the name should be the same as we have a full match
+                   assertEquals(mail.getName(), mailName);
+                   assertEquals("test", state);
+                   assertNull(e);
+                   latch.countDown();
+               }
+           }
+       });
+
+       assertEquals(Mail.DEFAULT, mail.getState());
+       processor.service(mail);
+
+
+       // the source mail should have the new state as it was a full match
+       assertEquals("test", mail.getState());
+       latch.await();
+       processor.destroy();
 
     }
-    
-    
+
+    @Test
     public void testMatcherThrowException() throws ConfigurationException, 
Exception {
-        final CountDownLatch latch = new CountDownLatch(1);
-        final MailImpl mail = new MailImpl();
-        mail.setName(MailImpl.getId());
-        mail.setSender(new MailAddress("test@localhost"));
-        mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), 
new MailAddress("test2@localhost")));
-        
-        AbstractStateMailetProcessor processor = 
createProcessor(createConfig(ExceptionThrowingMatcher.class, MockMailet.class, 
0));
-        processor.addListener(new MailetProcessorListener() {
-                        
-            public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients, Collection<MailAddress> matches, long 
processTime, MessagingException e) {
-                if (ExceptionThrowingMatcher.class.equals(m.getClass())) {
-                    assertEquals(mail.getName(), mailName);
-                    // match no recipient because of the error
-                    assertNull(matches);
-                    assertNotNull(e);
-                    latch.countDown();
-                }
-
-            }
-            
-            public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
-               throw new RuntimeException("Should not call any mailet!");
-            }
-        });
-       
-        assertEquals(Mail.DEFAULT, mail.getState());
-        
-        boolean catched = false;
-        try {
-            processor.service(mail);
-        } catch (MessagingException e) {
-            catched = true;
-        }
-        assertTrue(catched);
-        
-        // the source mail should have state error as the exception was thrown
-        assertEquals(Mail.ERROR, mail.getState());
-        latch.await();
-        processor.destroy();
+       final CountDownLatch latch = new CountDownLatch(1);
+       final MailImpl mail = new MailImpl();
+       mail.setName(MailImpl.getId());
+       mail.setSender(new MailAddress("test@localhost"));
+       mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), new 
MailAddress("test2@localhost")));
+
+       AbstractStateMailetProcessor processor = 
createProcessor(createConfig(ExceptionThrowingMatcher.class,
+               MockMailet.class, 0));
+       processor.addListener(new MailetProcessorListener() {
+
+           @Override
+           public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients,
+                                    Collection<MailAddress> matches, long 
processTime, MessagingException e) {
+               if (ExceptionThrowingMatcher.class.equals(m.getClass())) {
+                   assertEquals(mail.getName(), mailName);
+                   // match no recipient because of the error
+                   assertNull(matches);
+                   assertNotNull(e);
+                   latch.countDown();
+               }
+
+           }
+
+           @Override
+           public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
+               throw new RuntimeException("Should not call any mailet!");
+           }
+       });
+
+       assertEquals(Mail.DEFAULT, mail.getState());
+
+       boolean catched = false;
+       try {
+           processor.service(mail);
+       } catch (MessagingException e) {
+           catched = true;
+       }
+       assertTrue(catched);
+
+       // the source mail should have state error as the exception was thrown
+       assertEquals(Mail.ERROR, mail.getState());
+       latch.await();
+       processor.destroy();
 
     }
-    
+
+    @Test
     public void testMailetThrowException() throws ConfigurationException, 
Exception {
-        final CountDownLatch latch = new CountDownLatch(2);
-        final MailImpl mail = new MailImpl();
-        mail.setName(MailImpl.getId());
-        mail.setSender(new MailAddress("test@localhost"));
-        mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), 
new MailAddress("test2@localhost")));
-        
-        AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class, ExceptionThrowingMailet.class, 
1));
-        processor.addListener(new MailetProcessorListener() {
-                        
-            public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients, Collection<MailAddress> matches, long 
processTime, MessagingException e) {
-                if (MockMatcher.class.equals(m.getClass())) {
-                    assertEquals(mail.getName(), mailName);
-                    // match one recipient
-                    assertEquals(1, matches.size());
-                    assertNull(e);
-                    latch.countDown();
-                }
-
-            }
-            
-            public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
-                if (ExceptionThrowingMailet.class.equals(m.getClass())) {
-                    // the name should be not the same as we have a part match
-                    assertFalse(mail.getName().equals(mailName));
-                    assertNotNull(e);
-                    assertEquals(Mail.ERROR, state);
-                    latch.countDown();
-                }
-            }
-        });
-       
-        assertEquals(Mail.DEFAULT, mail.getState());
-        
-        boolean catched = false;
-        try {
-            processor.service(mail);
-        } catch (MessagingException e) {
-            catched = true;
-        }
-        assertTrue(catched);
-        
-        latch.await();
-        processor.destroy();
+       final CountDownLatch latch = new CountDownLatch(2);
+       final MailImpl mail = new MailImpl();
+       mail.setName(MailImpl.getId());
+       mail.setSender(new MailAddress("test@localhost"));
+       mail.setRecipients(Arrays.asList(new MailAddress("test@localhost"), new 
MailAddress("test2@localhost")));
+
+       AbstractStateMailetProcessor processor = 
createProcessor(createConfig(MockMatcher.class,
+               ExceptionThrowingMailet.class, 1));
+       processor.addListener(new MailetProcessorListener() {
+
+           @Override
+           public void afterMatcher(Matcher m, String mailName, 
Collection<MailAddress> recipients,
+                                    Collection<MailAddress> matches, long 
processTime, MessagingException e) {
+               if (MockMatcher.class.equals(m.getClass())) {
+                   assertEquals(mail.getName(), mailName);
+                   // match one recipient
+                   assertEquals(1, matches.size());
+                   assertNull(e);
+                   latch.countDown();
+               }
+
+           }
+
+           @Override
+           public void afterMailet(Mailet m, String mailName, String state, 
long processTime, MessagingException e) {
+               if (ExceptionThrowingMailet.class.equals(m.getClass())) {
+                   // the name should be not the same as we have a part match
+                   assertFalse(mail.getName().equals(mailName));
+                   assertNotNull(e);
+                   assertEquals(Mail.ERROR, state);
+                   latch.countDown();
+               }
+           }
+       });
+
+       assertEquals(Mail.DEFAULT, mail.getState());
+
+       boolean catched = false;
+       try {
+           processor.service(mail);
+       } catch (MessagingException e) {
+           catched = true;
+       }
+       assertTrue(catched);
+
+       latch.await();
+       processor.destroy();
 
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to