Author: btellier
Date: Thu Dec 17 14:59:27 2015
New Revision: 1720583

URL: http://svn.apache.org/viewvc?rev=1720583&view=rev
Log:
JAMES-1618 GETSCRIPT should be RFC-5804 compliant

Added:
    
james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/GetScriptTest.java
    
james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test
Modified:
    
james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
    
james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
    
james/project/trunk/protocols/managesieve/src/test/java/org/apache/james/managesieve/core/CoreProcessorTestCase.java

Added: 
james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/GetScriptTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/GetScriptTest.java?rev=1720583&view=auto
==============================================================================
--- 
james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/GetScriptTest.java
 (added)
+++ 
james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/GetScriptTest.java
 Thu Dec 17 14:59:27 2015
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.james.mpt.testsuite;
+
+import com.google.inject.Inject;
+import org.apache.james.mpt.host.ManageSieveHostSystem;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Locale;
+
+public class GetScriptTest extends ManageSieveMPTTest {
+
+    @Inject
+    private static ManageSieveHostSystem hostSystem;
+
+    public GetScriptTest() throws Exception {
+        super(hostSystem);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Test
+    public void getScriptShouldWork() throws Exception {
+        scriptTest("getscript", Locale.US);
+    }
+}

Added: 
james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test?rev=1720583&view=auto
==============================================================================
--- 
james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test
 (added)
+++ 
james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/getscript.test
 Thu Dec 17 14:59:27 2015
@@ -0,0 +1,51 @@
+################################################################
+# 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.                                           #
+################################################################
+
+C: GETSCRIPT
+S: NO "Missing argument: script name"
+
+C: GETSCRIPT "foo"
+S: NO
+
+C: AUTHENTICATE "PLAIN"
+S: \+ ""
+C:  user password
+S: OK authentication successfull
+
+C: GETSCRIPT "foo"
+S: NO \(NONEXISTENT\) "There is no script by that name"
+
+C: PUTSCRIPT "mysievescript" {110+}
+C: require ["fileinto"];
+C:
+C: if envelope :contains "to" "tmartin+sent" {
+C:   fileinto "INBOX.sent";
+C: }
+S: OK
+
+C: GETSCRIPT "mysievescript"
+S: \{97\}
+S: require \["fileinto"\];
+S:
+S: if envelope :contains "to" "tmartin\+sent" \{
+S:   fileinto "INBOX.sent";
+S: \}
+S: OK
+
+

Modified: 
james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java?rev=1720583&r1=1720582&r2=1720583&view=diff
==============================================================================
--- 
james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
 (original)
+++ 
james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
 Thu Dec 17 14:59:27 2015
@@ -21,6 +21,7 @@ package org.apache.james.mpt.managesieve
 
 import org.apache.james.mpt.testsuite.AuthenticateTest;
 import org.apache.james.mpt.testsuite.CapabilityTest;
+import org.apache.james.mpt.testsuite.GetScriptTest;
 import org.apache.james.mpt.testsuite.HaveSpaceTest;
 import org.apache.james.mpt.testsuite.LogoutTest;
 import org.apache.james.mpt.testsuite.NoopTest;
@@ -44,7 +45,8 @@ import org.junit.runners.Suite;
     CapabilityTest.class,
     HaveSpaceTest.class,
     PutScriptTest.class,
-    SetActiveTest.class
+    SetActiveTest.class,
+    GetScriptTest.class
 })
 public class ManageSieveFileTest {
 }

Modified: 
james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java?rev=1720583&r1=1720582&r2=1720583&view=diff
==============================================================================
--- 
james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
 (original)
+++ 
james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
 Thu Dec 17 14:59:27 2015
@@ -106,7 +106,9 @@ public class CoreProcessor implements Co
     public String getScript(Session session, String name) throws 
AuthenticationRequiredException, ScriptNotFoundException, StorageException {
         authenticationCheck(session);
         try {
-            return 
IOUtils.toString(sieveRepository.getScript(session.getUser(), name));
+            String scriptContent = 
IOUtils.toString(sieveRepository.getScript(session.getUser(), name));
+            sieveRepository.getScript(session.getUser(), name);
+            return "{" + scriptContent.length() + "}" + "\r\n" + scriptContent;
         } catch (UserNotFoundException ex) {
             throw new ManageSieveRuntimeException(ex);
         } catch (IOException ex) {

Modified: 
james/project/trunk/protocols/managesieve/src/test/java/org/apache/james/managesieve/core/CoreProcessorTestCase.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/test/java/org/apache/james/managesieve/core/CoreProcessorTestCase.java?rev=1720583&r1=1720582&r2=1720583&view=diff
==============================================================================
--- 
james/project/trunk/protocols/managesieve/src/test/java/org/apache/james/managesieve/core/CoreProcessorTestCase.java
 (original)
+++ 
james/project/trunk/protocols/managesieve/src/test/java/org/apache/james/managesieve/core/CoreProcessorTestCase.java
 Thu Dec 17 14:59:27 2015
@@ -191,7 +191,7 @@ public class CoreProcessorTestCase {
                 return CONTENT;
             }
         });
-        assertThat(core.getScript(session, SCRIPT)).isEqualTo(CONTENT);
+        assertThat(core.getScript(session, 
SCRIPT)).isEqualTo("{"+CONTENT.length()+"}\r\n" + CONTENT);
     }
 
     @Test(expected = AuthenticationRequiredException.class)



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to