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
* <ol>
* <li> hello sent - 00000001
* <li> hello waiting - 00000002
- * <li> featuresrequest waiting - 00000003
- * <li> featuresreply sent - 00000003
+ * <li> features request waiting - 00000003
+ * <li> features reply sent - 00000003
* </ol>
* @return stack filled with Handshake messages
*/
* <ol>
* <li> hello sent - 00000001
* <li> hello waiting - 00000021
- * <li> featuresrequest waiting - 00000002
- * <li> featuresreply sent - 00000002
+ * <li> features request waiting - 00000002
+ * <li> features reply sent - 00000002
* </ol>
* @return stack filled with Handshake messages
*/
return stack;
}
+ /**
+ * Creates stack from XML file
+ * @return stack filled with Handshake messages
+ */
+ public static Deque<ClientEvent> getScenarioFromXml(String scenarioName, String scenarioFile) throws JAXBException, SAXException, IOException {
+ ScenarioService scenarioService = new ScenarioServiceImpl(scenarioFile);
+ Deque<ClientEvent> stack = new ArrayDeque<>();
+ for (Map.Entry<Integer, ClientEvent> clientEvent : scenarioService.getEventsFromScenario(scenarioService.unMarshallData(scenarioName)).entrySet()) {
+ stack.addFirst(clientEvent.getValue());
+ }
+ return stack;
+ }
+
/**
* Creates stack with handshake needed messages. XID of messages:
* <ol>
* <li> hello sent - 00000001
* <li> hello waiting - 00000002
- * <li> featuresrequest waiting - 00000003
- * <li> featuresreply sent - 00000003
+ * <li> features request waiting - 00000003
+ * <li> features reply sent - 00000003
* </ol>
* @param auxiliaryId auxiliaryId wanted in featuresReply message
* @return stack filled with Handshake messages (featuresReply with auxiliaryId set)