Improved Facade & integration test
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / integration / IntegrationTest.java
index 363dede6c55c89be2483176e3f99401446dce756..5416a2a05e887ee60b1a7e14631c6c22f82119b7 100644 (file)
@@ -34,7 +34,7 @@ public class IntegrationTest {
     private static final long CONNECTION_TIMEOUT = 2000;\r
 \r
     private InetAddress startupAddress;\r
-    private MockPlugin dummyPlugin;\r
+    private MockPlugin mockPlugin;\r
 \r
     /**\r
      * @throws UnknownHostException\r
@@ -50,25 +50,30 @@ public class IntegrationTest {
      */\r
     @Test\r
     public void testCommunication() throws Exception {\r
-        dummyPlugin = new MockPlugin();\r
+        mockPlugin = new MockPlugin();\r
         SwitchConnectionProviderImpl scpimpl = new SwitchConnectionProviderImpl();\r
+        scpimpl.setSwitchConnectionHandler(mockPlugin);\r
         List<ConnectionConfiguration> configs = new ArrayList<>();\r
         configs.add(new TestingConnConfigImpl(startupAddress, DEFAULT_PORT, DEFAULT_TLS_SUPPORT));\r
         scpimpl.configure(configs);\r
-        scpimpl.setSwitchConnectionHandler(dummyPlugin);\r
         scpimpl.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);\r
+        \r
         int amountOfCLients = 1;\r
-        List<SimpleClient> clients = createAndStartClient(amountOfCLients);\r
-        Thread.sleep(2000);\r
+        List<SimpleClient> clients = createAndStartClient(amountOfCLients, 24);\r
+        SimpleClient firstClient = clients.get(0);\r
+        firstClient.getAutomatedPartDone().get();\r
+        firstClient.getDataReceived().get();\r
+        disconnectClients(clients);\r
     }\r
     \r
     /**\r
      * @param amountOfCLients \r
+     * @param dataLimit TODO\r
      * @return new clients up and running\r
      * @throws InterruptedException\r
      * @throws ExecutionException\r
      */\r
-    private List<SimpleClient> createAndStartClient(int amountOfCLients)\r
+    private List<SimpleClient> createAndStartClient(int amountOfCLients, int dataLimit)\r
             throws InterruptedException, ExecutionException {\r
         List<SimpleClient> clientsHorde = new ArrayList<>();\r
         for (int i = 0; i < amountOfCLients; i++) {\r
@@ -77,6 +82,7 @@ public class IntegrationTest {
                     getClass().getResourceAsStream(OF_BINARY_MESSAGE_INPUT_TXT));\r
             sc.setSecuredClient(false);\r
             clientsHorde.add(sc);\r
+            sc.setDataLimit(dataLimit);\r
             sc.start();\r
         }\r
         for (SimpleClient sc : clientsHorde) {\r