Author: ieugen
Date: Mon Mar 12 00:30:52 2012
New Revision: 1299500

URL: http://svn.apache.org/viewvc?rev=1299500&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-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
    
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
 Mon Mar 12 00:30:52 2012
@@ -16,11 +16,9 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.api.mock;
 
 import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
@@ -29,24 +27,27 @@ public class ExceptionThrowingMailet imp
 
     private MailetConfig config;
 
+    @Override
     public void destroy() {
-
     }
 
+    @Override
     public MailetConfig getMailetConfig() {
-        return config;
+       return config;
     }
 
+    @Override
     public String getMailetInfo() {
-        return getClass().getName();
+       return getClass().getName();
     }
 
+    @Override
     public void init(MailetConfig config) throws MessagingException {
-        this.config = config;
+       this.config = config;
     }
 
+    @Override
     public void service(Mail arg0) throws MessagingException {
-        throw new MessagingException();
+       throw new MessagingException();
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
 Mon Mar 12 00:30:52 2012
@@ -16,13 +16,10 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.api.mock;
 
 import java.util.Collection;
-
 import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
@@ -31,23 +28,27 @@ public class ExceptionThrowingMatcher im
 
     private MatcherConfig config;
 
+    @Override
     public void destroy() {
     }
 
+    @Override
     public MatcherConfig getMatcherConfig() {
-        return config;
+       return config;
     }
 
+    @Override
     public String getMatcherInfo() {
-        return getClass().getName();
+       return getClass().getName();
     }
 
+    @Override
     public void init(MatcherConfig config) throws MessagingException {
-        this.config = config;
+       this.config = config;
     }
 
+    @Override
     public Collection match(Mail arg0) throws MessagingException {
-        throw new MessagingException();
+       throw new MessagingException();
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
 Mon Mar 12 00:30:52 2012
@@ -19,7 +19,6 @@
 package org.apache.james.mailetcontainer.api.mock;
 
 import javax.mail.MessagingException;
-
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.mailet.Mail;
 
@@ -29,19 +28,19 @@ public class MockMailProcessor implement
     private String newState = null;
 
     public MockMailProcessor(boolean shouldThrow) {
-        this.shouldThrow = shouldThrow;
+       this.shouldThrow = shouldThrow;
     }
 
     public MockMailProcessor(String newState) {
-        this.newState = newState;
+       this.newState = newState;
     }
 
+    @Override
     public void service(Mail mail) throws MessagingException {
-        if (shouldThrow) {
-            throw new MessagingException();
-        } else {
-            mail.setState(newState);
-        }
+       if (shouldThrow) {
+           throw new MessagingException();
+       } else {
+           mail.setState(newState);
+       }
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
 Mon Mar 12 00:30:52 2012
@@ -16,11 +16,9 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.api.mock;
 
 import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
@@ -29,24 +27,28 @@ public class MockMailet implements Maile
 
     private MailetConfig config;
 
+    @Override
     public void destroy() {
     }
 
+    @Override
     public MailetConfig getMailetConfig() {
-        return config;
+       return config;
     }
 
+    @Override
     public String getMailetInfo() {
-        return "";
+       return "";
     }
 
+    @Override
     public void init(MailetConfig config) throws MessagingException {
-        this.config = config;
+       this.config = config;
     }
 
+    @Override
     public void service(Mail mail) throws MessagingException {
-        String state = config.getInitParameter("state");
-        mail.setState(state);
+       String state = config.getInitParameter("state");
+       mail.setState(state);
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
 Mon Mar 12 00:30:52 2012
@@ -16,20 +16,12 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.api.mock;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import java.util.*;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 import javax.mail.internet.MimeMessage;
-
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -40,124 +32,145 @@ public class MockMailetContext implement
     private Map<String, Object> attributes = new HashMap<String, Object>();
     private List<Mail> mails = new ArrayList<Mail>();
 
+    @Override
     public void bounce(Mail arg0, String arg1) throws MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
 
     }
 
+    @Override
     public void bounce(Mail arg0, String arg1, MailAddress arg2) throws 
MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
 
     }
 
+    @Override
     public Object getAttribute(String arg0) {
-        return attributes.get(arg0);
+       return attributes.get(arg0);
     }
 
+    @Override
     public Iterator getAttributeNames() {
-        return attributes.keySet().iterator();
+       return attributes.keySet().iterator();
     }
 
     /**
      * Return an {@link Collection} which holds "mx.localhost" if the given 
host
      * was "localhost". Otherwise and empty {@link Collection} is returned
      */
+    @Override
     public Collection getMailServers(String host) {
-        List<String> servers = new ArrayList<String>();
-        if ("localhost".equalsIgnoreCase(host)) {
-            servers.add("mx.localhost");
-        }
-        return servers;
+       List<String> servers = new ArrayList<String>();
+       if ("localhost".equalsIgnoreCase(host)) {
+           servers.add("mx.localhost");
+       }
+       return servers;
     }
 
+    @Override
     public int getMajorVersion() {
-        return 0;
+       return 0;
     }
 
+    @Override
     public int getMinorVersion() {
-        return 0;
+       return 0;
     }
 
+    @Override
     public MailAddress getPostmaster() {
-        try {
-            return new MailAddress("postmaster@localhost");
-        } catch (AddressException e) {
-            // will never happen
-            return null;
-        }
+       try {
+           return new MailAddress("postmaster@localhost");
+       } catch (AddressException e) {
+           // will never happen
+           return null;
+       }
     }
 
+    @Override
     public Iterator getSMTPHostAddresses(String arg0) {
-        return new ArrayList<HostAddress>().iterator();
+       return new ArrayList<HostAddress>().iterator();
     }
 
+    @Override
     public String getServerInfo() {
-        return "Mock Server";
+       return "Mock Server";
     }
 
     /**
      * @see #isLocalUser(String)
      */
+    @Override
     public boolean isLocalEmail(MailAddress arg0) {
-        return isLocalUser(arg0.toString());
+       return isLocalUser(arg0.toString());
     }
 
     /**
      * Return true if "localhost" was given
      */
+    @Override
     public boolean isLocalServer(String server) {
-        return "localhost".equalsIgnoreCase(server);
+       return "localhost".equalsIgnoreCase(server);
     }
 
     /**
      * Return true if "localuser@localhost" was given
      */
+    @Override
     public boolean isLocalUser(String user) {
-        return "localuser@localhost".equalsIgnoreCase(user);
+       return "localuser@localhost".equalsIgnoreCase(user);
     }
 
+    @Override
     public void log(String msg) {
-        System.out.println(msg);
+       System.out.println(msg);
     }
 
+    @Override
     public void log(String arg0, Throwable arg1) {
-        System.out.println(arg0);
-        arg1.printStackTrace();
-
+       System.out.println(arg0);
+       arg1.printStackTrace();
     }
 
+    @Override
     public void removeAttribute(String arg0) {
-        attributes.remove(arg0);
+       attributes.remove(arg0);
     }
 
+    @Override
     public void sendMail(MimeMessage arg0) throws MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
 
     }
 
+    @Override
     public void sendMail(Mail mail) throws MessagingException {
-        mails.add(mail);
+       mails.add(mail);
     }
 
+    @Override
     public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2) 
throws MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
 
     }
 
+    @Override
     public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2, 
String arg3) throws MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
 
     }
 
+    @Override
     public void setAttribute(String arg0, Object arg1) {
-        attributes.put(arg0, arg1);
+       attributes.put(arg0, arg1);
     }
 
+    @Override
     public void storeMail(MailAddress arg0, MailAddress arg1, MimeMessage 
arg2) throws MessagingException {
-        throw new UnsupportedOperationException("Not implemented");
+       throw new UnsupportedOperationException("Not implemented");
     }
 
     public List<Mail> getSentMails() {
-        return mails;
+       return mails;
     }
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
 Mon Mar 12 00:30:52 2012
@@ -19,7 +19,6 @@
 package org.apache.james.mailetcontainer.api.mock;
 
 import javax.mail.MessagingException;
-
 import org.apache.james.mailetcontainer.api.MailetLoader;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
@@ -27,16 +26,17 @@ import org.apache.mailet.MailetConfig;
 public class MockMailetLoader implements MailetLoader {
 
     @SuppressWarnings("unchecked")
+    @Override
     public Mailet getMailet(MailetConfig config) throws MessagingException {
-        try {
-            Class<Mailet> clazz = (Class<Mailet>) 
Thread.currentThread().getContextClassLoader().loadClass(config.getMailetName());
-            Mailet m = clazz.newInstance();
-            m.init(config);
-            return m;
-        } catch (Exception e) {
-            throw new MessagingException("Unable to load mailet " + 
config.getMailetName());
-        }
+       try {
+           Class<Mailet> clazz = (Class<Mailet>) 
Thread.currentThread().getContextClassLoader().loadClass(config.
+                   getMailetName());
+           Mailet m = clazz.newInstance();
+           m.init(config);
+           return m;
+       } catch (Exception e) {
+           throw new MessagingException("Unable to load mailet " + 
config.getMailetName());
+       }
 
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
 Mon Mar 12 00:30:52 2012
@@ -16,16 +16,13 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.mailetcontainer.api.mock;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.mail.MessagingException;
-
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
@@ -34,39 +31,41 @@ import org.apache.mailet.MatcherConfig;
 public class MockMatcher implements Matcher {
 
     private int matchCount = 0;
-
     private MatcherConfig config;
 
+    @Override
     public void destroy() {
-
     }
 
+    @Override
     public MatcherConfig getMatcherConfig() {
-        return config;
+       return config;
     }
 
+    @Override
     public String getMatcherInfo() {
-        return getClass().getName();
+       return getClass().getName();
     }
 
+    @Override
     public void init(MatcherConfig config) throws MessagingException {
-        this.config = config;
-        matchCount = Integer.parseInt(config.getCondition());
+       this.config = config;
+       matchCount = Integer.parseInt(config.getCondition());
     }
 
+    @Override
     public Collection match(Mail mail) throws MessagingException {
-        List<MailAddress> match = new ArrayList<MailAddress>();
+       List<MailAddress> match = new ArrayList<MailAddress>();
 
-        Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
-        while (rcpts.hasNext() && match.size() < matchCount) {
-            MailAddress addr = rcpts.next();
-            match.add(addr);
-
-        }
-        if (match.isEmpty()) {
-            return null;
-        }
-        return match;
+       Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
+       while (rcpts.hasNext() && match.size() < matchCount) {
+           MailAddress addr = rcpts.next();
+           match.add(addr);
+
+       }
+       if (match.isEmpty()) {
+           return null;
+       }
+       return match;
     }
-
 }

Modified: 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java?rev=1299500&r1=1299499&r2=1299500&view=diff
==============================================================================
--- 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
 (original)
+++ 
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
 Mon Mar 12 00:30:52 2012
@@ -19,7 +19,6 @@
 package org.apache.james.mailetcontainer.api.mock;
 
 import javax.mail.MessagingException;
-
 import org.apache.james.mailetcontainer.api.MatcherLoader;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
@@ -27,17 +26,18 @@ import org.apache.mailet.MatcherConfig;
 public class MockMatcherLoader implements MatcherLoader {
 
     @SuppressWarnings("unchecked")
+    @Override
     public Matcher getMatcher(MatcherConfig config) throws MessagingException {
 
-        try {
-            Class<Matcher> clazz = (Class<Matcher>) 
Thread.currentThread().getContextClassLoader().loadClass(config.getMatcherName());
-            Matcher m = clazz.newInstance();
-            m.init(config);
-            return m;
-        } catch (Exception e) {
-            throw new MessagingException("Unable to load matcher " + 
config.getMatcherName());
-        }
+       try {
+           Class<Matcher> clazz = (Class<Matcher>) 
Thread.currentThread().getContextClassLoader().loadClass(config.
+                   getMatcherName());
+           Matcher m = clazz.newInstance();
+           m.init(config);
+           return m;
+       } catch (Exception e) {
+           throw new MessagingException("Unable to load matcher " + 
config.getMatcherName());
+       }
 
     }
-
 }



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

Reply via email to