Add TestWatcher so we know what test is running 51/13451/3
authorFlavio Fernandes <ffernand@redhat.com>
Mon, 8 Dec 2014 15:11:24 +0000 (10:11 -0500)
committerFlavio Fernandes <ffernand@redhat.com>
Mon, 8 Dec 2014 17:20:53 +0000 (12:20 -0500)
Patch 2:
  - move testWatcher to base class
  - convert System.out.println in OvsdbPluginV3IT to use logger

Patch 3:
  - remove logs from mocked class (they never get called due to mock)

Change-Id: I21902bcd7595b16c8951ca04d1883c0745da6ba0
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/OvsdbIntegrationTestBase.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3IT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/hardwarevtep/HardwareVTEPIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/openvswitch/OpenVSwitchIT.java

index a3cbc3732e3045be3373608a606a7ea08c9c0669..ea99862308545aca333f53f95df1c0e3ceee6c87 100644 (file)
@@ -36,6 +36,11 @@ import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -203,4 +208,22 @@ public abstract class OvsdbIntegrationTestBase {
         bundlesReady = true;
         LOG.info("Bundles loaded");
     }
+
+    /*
+     * Method adds a log as each test method starts and finishes. This is useful when
+     * the test suite is used because the suites only print a final summary.
+     */
+    @Rule
+    public TestRule watcher = new TestWatcher() {
+        @Override
+        protected void starting(Description description) {
+            LOG.info("TestWatcher: Starting test: {}",
+                     description.getDisplayName());
+        }
+
+        @Override
+        protected void finished(Description description) {
+            LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
+        }
+    };
 }
index df3bec442e1275f0f6f9147f7e40a7000837f148..029f498b846ca1101381f3f0d2459a1028ff024e 100644 (file)
@@ -143,7 +143,7 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
             identifier = connectionInfo.getRemoteAddress().getHostAddress()+":"+connectionInfo.getRemotePort();
         }
         assertEquals(Node.fromString("OVS|" + identifier), connectionService.getNodes().get(0));
-        System.out.println("Nodes = "+ connectionService.getNodes());
+        log.info("Nodes = "+ connectionService.getNodes());
         /*
          * Test sequence :
          * 1. Print Cache and Assert to make sure the bridge is not created yet.
@@ -204,7 +204,7 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
         Row bridgeRow = ovsdbConfigurationService.getRow(node, databaseName, bridge.getSchema().getName(), status.getUuid());
         assertNotNull(bridgeRow);
         bridge = connection.getClient().getTypedRowWrapper(Bridge.class, bridgeRow);
-        System.out.println("Bridge UUID "+bridge.getUuid()+" Status Uuid "+status.getUuid());
+        log.info("Bridge UUID "+bridge.getUuid()+" Status Uuid "+status.getUuid());
         assertEquals(bridge.getUuid(), status.getUuid());
 
         bridge = connection.getClient().createTypedRowWrapper(Bridge.class);
@@ -251,12 +251,12 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
 
     public void printCache() throws Exception {
         List<String> tables = ovsdbConfigurationService.getTables(node, databaseName);
-        System.out.println("Tables = "+tables);
+        log.info("Tables = "+tables);
         assertNotNull(tables);
         for (String table : tables) {
-            System.out.println("Table "+table);
+            log.info("Table "+table);
             ConcurrentMap<UUID, Row<GenericTableSchema>> rows = ovsdbConfigurationService.getRows(node, databaseName, table);
-            System.out.println(rows);
+            log.info(rows.toString());
         }
     }
 
index 105b046f228788757ec185a6d44f2313dbda9168..202f92d37036b8fef4eb65119236cc781a409ec4 100644 (file)
@@ -33,11 +33,7 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import junit.framework.Assert;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
 import org.junit.runner.RunWith;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
@@ -120,24 +116,6 @@ public class HardwareVTEPIT  extends OvsdbIntegrationTestBase {
         );
     }
 
-    /*
-     * Method adds a log as each test method starts and finishes. This is useful when
-     * the test suite is used because the suites only print a final summary.
-     */
-    @Rule
-    public TestRule watcher = new TestWatcher() {
-        @Override
-        protected void starting(Description description) {
-            LOG.info("TestWatcher: Starting test: {}",
-                    description.getDisplayName());
-        }
-
-        @Override
-        protected void finished(Description description) {
-            LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
-        }
-    };
-
     @Before
     public void setUp () throws ExecutionException, InterruptedException, IOException {
         areWeReady(bc);
index 2b787884fea7a2a4f171c5eb5bb82c2ad3352635..17f6e05361a99725270d123466f5af580747404c 100644 (file)
@@ -38,11 +38,7 @@ import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
 import org.junit.runner.RunWith;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
@@ -162,24 +158,6 @@ public class OpenVSwitchIT extends OvsdbIntegrationTestBase {
         );
     }
 
-    /*
-     * Method adds a log as each test method starts and finishes. This is useful when
-     * the test suite is used because the suites only print a final summary.
-     */
-    @Rule
-    public TestRule watcher = new TestWatcher() {
-        @Override
-        protected void starting(Description description) {
-            LOG.info("TestWatcher: Starting test: {}",
-                    description.getDisplayName());
-        }
-
-        @Override
-        protected void finished(Description description) {
-            LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
-        }
-    };
-
     @Before
     public void setUp () throws ExecutionException, InterruptedException, IOException {
         areWeReady(bc);