Bug 2756 - Match model update
[openflowjava.git] / openflow-protocol-it / src / test / java / org / opendaylight / openflowjava / protocol / it / integration / MockPlugin.java
index b4f69bb021d054ab9eb65a78cbba8cdee49e457c..36a8d277f564e6c73626e0ca4a90998a21daa0df 100644 (file)
@@ -18,6 +18,7 @@ import java.util.concurrent.TimeoutException;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
+import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
@@ -48,7 +49,7 @@ import com.google.common.util.concurrent.SettableFuture;
  * @author michal.polkorab
  *
  */
-public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler, 
+public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler,
         SystemNotificationsListener, ConnectionReadyListener {
 
     protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class);
@@ -62,7 +63,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         finishedFuture = SettableFuture.create();
         LOGGER.debug("mockPlugin: "+System.identityHashCode(this));
     }
-    
+
     @Override
     public void onSwitchConnected(ConnectionAdapter connection) {
         LOGGER.debug("onSwitchConnected: " + connection);
@@ -100,19 +101,19 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     @Override
     public void onErrorMessage(ErrorMessage notification) {
         LOGGER.debug("Error message received");
-        
+
     }
 
     @Override
     public void onExperimenterMessage(ExperimenterMessage notification) {
         LOGGER.debug("Experimenter message received");
-        
+
     }
 
     @Override
     public void onFlowRemovedMessage(FlowRemovedMessage notification) {
         LOGGER.debug("FlowRemoved message received");
-        
+
     }
 
     @Override
@@ -137,7 +138,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         }).start();
 
     }
-    
+
     protected void getSwitchFeatures() {
         GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
         featuresBuilder.setVersion((short) 4);
@@ -169,7 +170,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
                 Future<Boolean> disconnect = adapter.disconnect();
                 disconnect.get();
                 LOGGER.debug("MockPlugin.shutdown() Disconnected");
-            } 
+            }
         } catch (Exception e) {
             LOGGER.error("MockPlugin.shutdown() exception caught: ", e.getMessage(), e);
         }
@@ -179,7 +180,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     @Override
     public void onMultipartReplyMessage(MultipartReplyMessage notification) {
         LOGGER.debug("MultipartReply message received");
-        
+
     }
 
     @Override
@@ -190,15 +191,15 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         LOGGER.debug("Reason: " + notification.getReason());
         LOGGER.debug("TableId: " + notification.getTableId());
         LOGGER.debug("Cookie: " + notification.getCookie());
-        LOGGER.debug("Class: " + notification.getMatch().getMatchEntries().get(0).getOxmClass());
-        LOGGER.debug("Field: " + notification.getMatch().getMatchEntries().get(0).getOxmMatchField());
+        LOGGER.debug("Class: " + notification.getMatch().getMatchEntry().get(0).getOxmClass());
+        LOGGER.debug("Field: " + notification.getMatch().getMatchEntry().get(0).getOxmMatchField());
         LOGGER.debug("Datasize: " + notification.getData().length);
     }
 
     @Override
     public void onPortStatusMessage(PortStatusMessage notification) {
         LOGGER.debug("MockPlugin.onPortStatusMessage() message received");
-        
+
     }
 
     @Override
@@ -225,11 +226,20 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     public int getIdleCounter() {
         return idleCounter;
     }
-    
+
     @Override
     public void onConnectionReady() {
         LOGGER.trace("MockPlugin().onConnectionReady()");
     }
 
-
+    /**
+     * Initiates connection to device
+     * @param switchConnectionProvider
+     * @param host - host IP
+     * @param port - port number 
+     */
+    public void initiateConnection(SwitchConnectionProviderImpl switchConnectionProvider, String host, int port) {
+        LOGGER.trace("MockPlugin().initiateConnection()");
+        switchConnectionProvider.initiateConnection(host, port);
+    }
 }