Author: norman
Date: Sat Jan 8 14:35:12 2011
New Revision: 1056716
URL: http://svn.apache.org/viewvc?rev=1056716&view=rev
Log:
Some better implementation for a mock
Modified:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
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=1056716&r1=1056715&r2=1056716&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
Sat Jan 8 14:35:12 2011
@@ -20,7 +20,6 @@
package org.apache.james.mailetcontainer.api.mock;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -34,7 +33,8 @@ import org.apache.mailet.MatcherConfig;
public class MockMatcher implements Matcher{
- private List<String> matches = new ArrayList<String>();
+ private int matchCount = 0;
+
private MatcherConfig config;
public void destroy() {
@@ -51,18 +51,17 @@ public class MockMatcher implements Matc
public void init(MatcherConfig config) throws MessagingException {
this.config = config;
- matches.addAll(Arrays.asList(config.getCondition().split(",")));
+ matchCount = Integer.parseInt(config.getCondition());
}
public Collection match(Mail mail) throws MessagingException {
List<MailAddress> match = new ArrayList<MailAddress>();
Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
- while (rcpts.hasNext()) {
+ while (rcpts.hasNext() && match.size() < matchCount) {
MailAddress addr = rcpts.next();
- if (matches.contains(addr.toString())) {
- match.add(addr);
- }
+ match.add(addr);
+
}
if (match.isEmpty()) {
return null;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]