james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r385660 - in /james/server/trunk/src/test/org/apache/james: test/mock/mailet/MockMailContext.java test/mock/mailet/MockMailetConfig.java transport/LinearProcessorTest.java transport/mailets/AddFooterTest.java
Date Mon, 13 Mar 2006 21:16:24 GMT
Author: bago
Date: Mon Mar 13 13:16:22 2006
New Revision: 385660

URL: http://svn.apache.org/viewcvs?rev=385660&view=rev
Log:
Added a MockMailetConfig (implemented over a Properties object) to simplify mock mailet configuration.

Added:
    james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java
Modified:
    james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailContext.java
    james/server/trunk/src/test/org/apache/james/transport/LinearProcessorTest.java
    james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java

Modified: james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailContext.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailContext.java?rev=385660&r1=385659&r2=385660&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailContext.java (original)
+++ james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailContext.java Mon
Mar 13 13:16:22 2006
@@ -72,11 +72,12 @@
     }
 
     public void log(String message) {
-        // trivial implementation
+        System.out.println(message);
     }
 
     public void log(String message, Throwable t) {
-        // trivial implementation
+        System.out.println(message);
+        t.printStackTrace(System.out);
     }
 
     public void removeAttribute(String name) {

Added: james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java?rev=385660&view=auto
==============================================================================
--- james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java (added)
+++ james/server/trunk/src/test/org/apache/james/test/mock/mailet/MockMailetConfig.java Mon
Mar 13 13:16:22 2006
@@ -0,0 +1,61 @@
+/***********************************************************************
+ * Copyright (c) 1999-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.test.mock.mailet;
+
+import org.apache.mailet.MailetConfig;
+import org.apache.mailet.MailetContext;
+
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * MailetConfig over Properties
+ */
+public class MockMailetConfig extends Properties implements MailetConfig {
+
+    private String mailetName;
+    private MailetContext mc;
+
+    public MockMailetConfig(String mailetName, MailetContext mc) {
+        super();
+        this.mailetName = mailetName;
+        this.mc = mc;
+    }
+
+    public MockMailetConfig(String mailetName, MailetContext mc, Properties arg0) {
+        super(arg0);
+        this.mailetName = mailetName;
+        this.mc = mc;
+    }
+
+    public String getInitParameter(String name) {
+        return getProperty(name);
+    }
+
+    public Iterator getInitParameterNames() {
+        return keySet().iterator();
+    }
+
+    public MailetContext getMailetContext() {
+        return mc;
+    }
+
+    public String getMailetName() {
+        return mailetName;
+    }
+
+}

Modified: james/server/trunk/src/test/org/apache/james/transport/LinearProcessorTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/transport/LinearProcessorTest.java?rev=385660&r1=385659&r2=385660&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/transport/LinearProcessorTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/transport/LinearProcessorTest.java Mon Mar
13 13:16:22 2006
@@ -23,6 +23,7 @@
 import org.apache.james.core.MimeMessageWrapper;
 import org.apache.james.test.mock.james.MockSpoolRepository;
 import org.apache.james.test.mock.mailet.MockMailContext;
+import org.apache.james.test.mock.mailet.MockMailetConfig;
 import org.apache.james.transport.mailets.debug.DumpSystemErr;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.RecipientIs;
@@ -44,7 +45,6 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 
 import junit.framework.TestCase;
 
@@ -75,25 +75,8 @@
         
     }
     
-    private MailetConfig mockMailetConfig = new MailetConfig() {
-
-        public String getInitParameter(String name) {
-            return "";
-        }
-
-        public Iterator getInitParameterNames() {
-            return null;
-        }
-
-        public MailetContext getMailetContext() {
-            return mockContext;
-        }
-
-        public String getMailetName() {
-            return "Dummy";
-        }
-        
-    };
+    private MailetConfig mockMailetConfig = new MockMailetConfig("Dummy",mockContext);
+    
     private CheckerMailet checkerMailet;
     
     private class MyMailet extends GenericMailet {

Modified: james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java
URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java?rev=385660&r1=385659&r2=385660&view=diff
==============================================================================
--- james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java (original)
+++ james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java Mon
Mar 13 13:16:22 2006
@@ -17,8 +17,8 @@
 package org.apache.james.transport.mailets;
 
 import org.apache.james.core.MailImpl;
-import org.apache.james.core.MailetConfigImpl;
 import org.apache.james.test.mock.mailet.MockMailContext;
+import org.apache.james.test.mock.mailet.MockMailetConfig;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 
@@ -266,24 +266,10 @@
 
     private String processAddFooter(String asciisource, String footer)
             throws MessagingException, IOException {
-        Mailet mailet = new AddFooter() {
-            private String footer;
+        Mailet mailet = new AddFooter();
 
-            public String getInitParameter(String name) {
-                if ("text".equals(name)) {
-                    return footer;
-                }
-                return null;
-            }
-
-            public Mailet setFooter(String string) {
-                this.footer = string;
-                return this;
-            };
-        }.setFooter(footer);
-
-        MailetConfigImpl mci = new MailetConfigImpl();
-        mci.setMailetContext(new MockMailContext());
+        MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
+        mci.setProperty("text",footer);
 
         mailet.init(mci);
 



---------------------------------------------------------------------
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