Add test device connections utility
[openflowjava.git] / simple-client / src / main / java / org / opendaylight / openflowjava / protocol / impl / clients / ScenarioFactory.java
index f0e5b9cffbf958f7de182bcaf137beee038bbc39..4e28c4cd74f58ced75b1b9ceb01ef2426e26e0ae 100644 (file)
@@ -25,8 +25,8 @@ public final class ScenarioFactory {
     }
 
     /**
-     * Creates stack with handshake needed messages.
-     * <ol> XID of messages:
+     * Creates stack with handshake needed messages. XID of messages:
+     * <ol>
      *   <li> hello sent - 00000001
      *   <li> hello waiting - 00000002
      *   <li> featuresrequest waiting - 00000003
@@ -45,8 +45,30 @@ public final class ScenarioFactory {
     }
 
     /**
-     * Creates stack with handshake needed messages.
-     * <ol> XID of messages:
+     * Creates stack with handshake needed messages. XID of messages:
+     * <ol>
+     *   <li> hello sent - 00000001
+     *   <li> hello waiting - 00000021
+     *   <li> featuresrequest waiting - 00000002
+     *   <li> featuresreply sent - 00000002
+     * </ol>
+     * @return stack filled with Handshake messages
+     */
+    public static Deque<ClientEvent> createHandshakeScenarioWithBarrier() {
+        Deque<ClientEvent> stack = new ArrayDeque<>();
+        stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
+        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12"))); //Hello message 21
+        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
+        stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 02 "
+                + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03")));
+        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 14 00 08 00 00 00 00"))); //Barrier request
+        stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 15 00 08 00 00 00 04"))); //Barrier reply
+        return stack;
+    }
+
+    /**
+     * Creates stack with handshake needed messages. XID of messages:
+     * <ol>
      *   <li> hello sent - 00000001
      *   <li> hello waiting - 00000002
      *   <li> featuresrequest waiting - 00000003