james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1688159 - in /james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol: FileProtocolSessionBuilder.java ProtocolSession.java ProtocolSessionBuilder.java
Date Mon, 29 Jun 2015 08:56:42 GMT
Author: btellier
Date: Mon Jun 29 08:56:41 2015
New Revision: 1688159

URL: http://svn.apache.org/r1688159
Log:
MAILBOX-155 Adding WAIT instruction to MPT, requested by ElasticSearch indexation

Modified:
    james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/FileProtocolSessionBuilder.java
    james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
    james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSessionBuilder.java

Modified: james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/FileProtocolSessionBuilder.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/FileProtocolSessionBuilder.java?rev=1688159&r1=1688158&r2=1688159&view=diff
==============================================================================
--- james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/FileProtocolSessionBuilder.java
(original)
+++ james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/FileProtocolSessionBuilder.java
Mon Jun 29 08:56:41 2015
@@ -112,6 +112,13 @@ public class FileProtocolSessionBuilder
                     }
                     session.SL(sessionNumber, serverMsg, location, lastClientMsg);
                 }
+                else if (next.startsWith(WAIT)) {
+                    if (next.length() > 5) {
+                        session.WAIT(sessionNumber, Long.valueOf(next.substring(5)));
+                    } else {
+                        throw new Exception("Invalid line length on WAIT instruction : "
+ next);
+                    }
+                }
                 else if (next.startsWith(OPEN_UNORDERED_BLOCK_TAG)) {
                     List<String> unorderedLines = new ArrayList<String>(5);
                     next = reader.readLine();

Modified: james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java?rev=1688159&r1=1688158&r2=1688159&view=diff
==============================================================================
--- james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
(original)
+++ james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSession.java
Mon Jun 29 08:56:41 2015
@@ -179,6 +179,14 @@ public class ProtocolSession implements
     }
 
     /**
+     * adds a Wait condition
+     */
+    public void WAIT(int sessionNumber, long timeToWaitInMs) {
+        this.maxSessionNumber = Math.max(this.maxSessionNumber, sessionNumber);
+        testElements.add(new WaitElement(timeToWaitInMs));
+    }
+
+    /**
      * A client request, which write the specified message to a Writer.
      */
     private static class ClientRequest implements ProtocolElement {
@@ -474,6 +482,28 @@ public class ProtocolSession implements
         public boolean isClient() {
             return false;
         }
+    }
+
+    /**
+     * Allow you to wait a given time at a given point of the test script
+     */
+    private class WaitElement implements ProtocolElement {
+
+        private final long timeToWaitInMs;
+
+        public WaitElement(long timeToWaitInMs) {
+            this.timeToWaitInMs = timeToWaitInMs;
+        }
+
+        @Override
+        public void testProtocol(Session[] sessions, boolean continueAfterFailure) throws
Exception {
+            Thread.sleep(timeToWaitInMs);
+        }
+
+        @Override
+        public boolean isClient() {
+            return false;
+        }
     }
 
     /**

Modified: james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSessionBuilder.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSessionBuilder.java?rev=1688159&r1=1688158&r2=1688159&view=diff
==============================================================================
--- james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSessionBuilder.java
(original)
+++ james/mpt/trunk/core/src/main/java/org/apache/james/mpt/protocol/ProtocolSessionBuilder.java
Mon Jun 29 08:56:41 2015
@@ -38,7 +38,9 @@ import org.apache.james.mpt.api.Protocol
  * @version $Revision$
  */
 public class ProtocolSessionBuilder {
-    
+
+    public static final String WAIT = "WAIT";
+
     public static final String SERVER_CONTINUATION_TAG = "S: \\+";
 
     public static final String CLIENT_TAG = "C:";



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