Author: rdonkin
Date: Fri Jul 24 13:08:59 2009
New Revision: 797435
URL: http://svn.apache.org/viewvc?rev=797435&view=rev
Log:
JSIEVE-59 Switch to use alternative method
https://issues.apache.org/jira/browse/JSIEVE-59
Added:
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java
(with props)
Modified:
james/jsieve/trunk/main/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
Modified:
james/jsieve/trunk/main/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
URL:
http://svn.apache.org/viewvc/james/jsieve/trunk/main/src/main/java/org/apache/jsieve/commands/optional/FileInto.java?rev=797435&r1=797434&r2=797435&view=diff
==============================================================================
---
james/jsieve/trunk/main/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
(original)
+++
james/jsieve/trunk/main/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
Fri Jul 24 13:08:59 2009
@@ -65,13 +65,14 @@
// Only one fileinto per destination allowed, others should be
// discarded
- ListIterator actionsIter = mail.getActionsIterator();
boolean isDuplicate = false;
- while (actionsIter.hasNext()) {
- Action action = (Action) actionsIter.next();
+ for (final Action action: mail.getActions()) {
isDuplicate = (action instanceof ActionFileInto)
&& (((ActionFileInto) action).getDestination()
.equals(destination));
+ if (isDuplicate) {
+ break;
+ }
}
if (!isDuplicate)
Added:
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java
URL:
http://svn.apache.org/viewvc/james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java?rev=797435&view=auto
==============================================================================
---
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java
(added)
+++
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java
Fri Jul 24 13:08:59 2009
@@ -0,0 +1,78 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you 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.jsieve.commands.optional;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.jsieve.Argument;
+import org.apache.jsieve.Arguments;
+import org.apache.jsieve.BaseSieveContext;
+import org.apache.jsieve.ConfigurationManager;
+import org.apache.jsieve.ScriptCoordinate;
+import org.apache.jsieve.SieveContext;
+import org.apache.jsieve.StringListArgument;
+import org.apache.jsieve.TestList;
+import org.apache.jsieve.mail.ActionFileInto;
+import org.apache.jsieve.util.check.ScriptCheckMailAdapter;
+
+public class FileIntoTest extends TestCase {
+
+ FileInto subject;
+
+ ScriptCheckMailAdapter mockAdapter;
+ Arguments dummyArguments;
+ SieveContext dummyContext;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mockAdapter = new ScriptCheckMailAdapter();
+ List<String> stringList = new ArrayList<String>();
+ stringList.add("Whatever");
+ List<Argument> argumentList = new ArrayList<Argument>();
+ argumentList.add(new StringListArgument(stringList));
+ dummyArguments = new Arguments(argumentList, new
TestList(Collections.EMPTY_LIST));
+ ConfigurationManager configurationManager = new ConfigurationManager();
+ dummyContext = new BaseSieveContext(
+ configurationManager.getCommandManager(), configurationManager
+ .getComparatorManager(), configurationManager
+ .getTestManager(), LogFactory
+ .getLog(this.getClass()));
+ dummyContext.setCoordinate(new ScriptCoordinate(0, 0, 0, 0));
+ subject = new FileInto();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testFileIntoShouldNotAllowMultipleFileIntoActions() throws
Exception {
+ subject.execute(mockAdapter, dummyArguments, null, dummyContext);
+ assertEquals(1, mockAdapter.getActions().size());
+ assertTrue(mockAdapter.getActions().get(0) instanceof ActionFileInto);
+
+ subject.execute(mockAdapter, dummyArguments, null, dummyContext);
+ assertEquals(1, mockAdapter.getActions().size());
+ assertTrue(mockAdapter.getActions().get(0) instanceof ActionFileInto);
+ }
+}
Propchange:
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/commands/optional/FileIntoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]