Merge "Split unit and integration tests and add a profile to active integration tests."
authorMadhu Venugopal <mavenugo@gmail.com>
Sat, 9 Nov 2013 07:41:19 +0000 (07:41 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 9 Nov 2013 07:41:19 +0000 (07:41 +0000)
ovsdb/pom.xml
ovsdb/src/test/java/org/opendaylight/ovsdb/lib/message/OVSDBNettyFactoryIT.java [moved from ovsdb/src/test/java/org/opendaylight/ovsdb/lib/message/OVSDBNettyFactoryTest.java with 85% similarity]
ovsdb/src/test/resources/org/opendaylight/ovsdb/lib/message/integration-test.properties [new file with mode: 0644]
ovsdb/src/test/resources/org/opendaylight/ovsdb/lib/message/monitor_response1.json [moved from ovsdb/src/test/resources/org/opendaylight/ovsdb/obj/monitor_response1.json with 100% similarity]
ovsdb/src/test/resources/org/opendaylight/ovsdb/lib/message/monitor_response_sample.json [moved from ovsdb/src/test/resources/org/opendaylight/ovsdb/obj/monitor_response_sample.json with 100% similarity]

index 4677396ed6a6d383761d8d759a92f0822ef15b93..e1efbc922809777c5a41c6b58782c4a92d202371 100755 (executable)
@@ -14,6 +14,7 @@
     <properties>
         <java.version.source>1.7</java.version.source>
         <java.version.target>1.7</java.version.target>
+        <skip.integrationtest>true</skip.integrationtest>
     </properties>
 
     <build>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
-                 <skipTests>true</skipTests>
+                 <excludes>
+                   <!--  Exclude integration tests -->
+                   <exclude>**/*IT</exclude>
+                 </excludes>
+               </configuration>
+             </plugin>
+            <plugin>
+               <groupId>org.apache.maven.plugins</groupId>
+               <artifactId>maven-failsafe-plugin</artifactId>
+               <configuration>
+                <skipITs>${skip.integrationtest}</skipITs>
                </configuration>
              </plugin>
             <plugin>
           <version>1.0</version>
         </dependency>
     </dependencies>
+
+    <profiles>
+      <profile>
+      <id>integrationtest</id>
+      <activation>
+      </activation>
+      <properties>
+        <skip.integrationtest>false</skip.integrationtest>
+      </properties>
+    </profile>
+    </profiles>
 </project>
similarity index 85%
rename from ovsdb/src/test/java/org/opendaylight/ovsdb/lib/message/OVSDBNettyFactoryTest.java
rename to ovsdb/src/test/java/org/opendaylight/ovsdb/lib/message/OVSDBNettyFactoryIT.java
index 793735592d6ce47f066675ba7431d3f30f8bae0d..65bde156f4ae75629649e9b5cdb7855b96d1a715 100644 (file)
@@ -1,15 +1,21 @@
 package org.opendaylight.ovsdb.lib.message;
 
-import com.google.common.util.concurrent.ListenableFuture;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
 
 import org.apache.commons.collections.MapUtils;
+import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.sal.connection.ConnectionConstants;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
-import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
-import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
 import org.opendaylight.ovsdb.lib.message.operations.MutateOperation;
 import org.opendaylight.ovsdb.lib.message.operations.Operation;
@@ -30,19 +36,29 @@ import org.opendaylight.ovsdb.plugin.Connection;
 import org.opendaylight.ovsdb.plugin.ConnectionService;
 import org.opendaylight.ovsdb.plugin.InventoryService;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
+import com.google.common.util.concurrent.ListenableFuture;
 
-public class OVSDBNettyFactoryTest {
+public class OVSDBNettyFactoryIT {
     InventoryService inventoryService;
     private static String bridgeIdentifier = "br1";
+    private Properties props;
+
+    @Before
+    public void initialize() throws IOException {
+        InputStream is = this.getClass().getClassLoader()
+                .getResourceAsStream(
+                        "org/opendaylight/ovsdb/lib/message/integration-test.properties");
+        if (is == null) {
+            throw new IOException("Unable to load integration-test.properties");
+        }
+        props = new Properties();
+        props.load(is);
+
+    }
 
     @Test
-    public void testSome() throws InterruptedException, ExecutionException {
+    public void testSome() throws InterruptedException, ExecutionException,
+            IOException {
         ConnectionService connectionService = new ConnectionService();
         connectionService.init();
         inventoryService = new InventoryService();
@@ -50,24 +66,23 @@ public class OVSDBNettyFactoryTest {
         connectionService.setInventoryServiceInternal(inventoryService);
         Node.NodeIDType.registerIDType("OVS", String.class);
         Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
-        params.put(ConnectionConstants.ADDRESS, "192.168.56.101");
-        params.put(ConnectionConstants.PORT, "6634");
+        params.put(ConnectionConstants.ADDRESS,
+                props.getProperty("ovsdbserver.ipaddress"));
+        params.put(ConnectionConstants.PORT,
+                props.getProperty("ovsdbserver.port", "6640"));
         Node node = connectionService.connect("TEST", params);
         if (node == null) {
-            System.out.println("ERROR : Unable to connect to the host");
-            return;
+            throw new IOException("Unable to connect to the host");
         }
 
         Connection connection = connectionService.getConnection(node);
         if (connection == null) {
-            System.out.println("ERROR : Unable to connect to the host");
-            return;
+            throw new IOException("Unable to connect to the host");
         }
 
         OvsdbRPC ovsdb = connection.getRpc();
         if (ovsdb == null) {
-            System.out.println("ERROR : Unable to obtain RPC instance");
-            return;
+            throw new IOException("Unable to obtain RPC instance");
         }
 
         //GET DB-SCHEMA
@@ -144,7 +159,7 @@ public class OVSDBNettyFactoryTest {
 
         TransactBuilder transaction = new TransactBuilder();
         transaction.addOperations(new ArrayList<Operation>(
-                                  Arrays.asList(addSwitchRequest, addIntfRequest, addPortRequest, addBridgeRequest)));
+                Arrays.asList(addSwitchRequest, addIntfRequest, addPortRequest, addBridgeRequest)));
 
         ListenableFuture<List<OperationResult>> transResponse = ovsdb.transact(transaction);
         System.out.println("Transcation sent :");
diff --git a/ovsdb/src/test/resources/org/opendaylight/ovsdb/lib/message/integration-test.properties b/ovsdb/src/test/resources/org/opendaylight/ovsdb/lib/message/integration-test.properties
new file mode 100644 (file)
index 0000000..5f57dc2
--- /dev/null
@@ -0,0 +1,2 @@
+ovsdbserver.ipaddress=192.168.168.121
+ovsdbserver.port=6640
\ No newline at end of file