X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=simple-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fclients%2FScenarioFactory.java;fp=simple-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fclients%2FScenarioFactory.java;h=3e01cfa543a758bb21b602ff3aa4d5cfbc1a5c96;hb=03a603f148b36839d67288b57c6d814a9890c94f;hp=4e28c4cd74f58ced75b1b9ceb01ef2426e26e0ae;hpb=c54af80d10ca53721aa67020bba27ca9b893ea54;p=openflowjava.git diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 4e28c4cd..3e01cfa5 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -8,10 +8,15 @@ package org.opendaylight.openflowjava.protocol.impl.clients; +import java.io.IOException; import java.util.ArrayDeque; import java.util.Deque; +import java.util.Map; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.xml.sax.SAXException; + +import javax.xml.bind.JAXBException; /** * Class for providing prepared handshake scenario @@ -29,8 +34,8 @@ public final class ScenarioFactory { *
    *
  1. hello sent - 00000001 *
  2. hello waiting - 00000002 - *
  3. featuresrequest waiting - 00000003 - *
  4. featuresreply sent - 00000003 + *
  5. features request waiting - 00000003 + *
  6. features reply sent - 00000003 *
* @return stack filled with Handshake messages */ @@ -49,8 +54,8 @@ public final class ScenarioFactory { *
    *
  1. hello sent - 00000001 *
  2. hello waiting - 00000021 - *
  3. featuresrequest waiting - 00000002 - *
  4. featuresreply sent - 00000002 + *
  5. features request waiting - 00000002 + *
  6. features reply sent - 00000002 *
* @return stack filled with Handshake messages */ @@ -66,13 +71,26 @@ public final class ScenarioFactory { return stack; } + /** + * Creates stack from XML file + * @return stack filled with Handshake messages + */ + public static Deque getScenarioFromXml(String scenarioName, String scenarioFile) throws JAXBException, SAXException, IOException { + ScenarioService scenarioService = new ScenarioServiceImpl(scenarioFile); + Deque stack = new ArrayDeque<>(); + for (Map.Entry clientEvent : scenarioService.getEventsFromScenario(scenarioService.unMarshallData(scenarioName)).entrySet()) { + stack.addFirst(clientEvent.getValue()); + } + return stack; + } + /** * Creates stack with handshake needed messages. XID of messages: *
    *
  1. hello sent - 00000001 *
  2. hello waiting - 00000002 - *
  3. featuresrequest waiting - 00000003 - *
  4. featuresreply sent - 00000003 + *
  5. features request waiting - 00000003 + *
  6. features reply sent - 00000003 *
* @param auxiliaryId auxiliaryId wanted in featuresReply message * @return stack filled with Handshake messages (featuresReply with auxiliaryId set)