BUG-7464: eliminate console output 36/50236/2
authorRobert Varga <rovarga@cisco.com>
Tue, 10 Jan 2017 22:28:38 +0000 (23:28 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 10 Jan 2017 23:44:44 +0000 (23:44 +0000)
Use a Logger to log messages as needed instead of System.out,
fixing checkstyle warnings.

Change-Id: I07aa409856951e72a656ed35703ea29a05fd1397
Signed-off-by: Robert Varga <rovarga@cisco.com>
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java

index b575e915dcb9b1281988e423829dfa39bdb81743..4b2d78ad839524565b1e2d333a9068cf3ab339b4 100644 (file)
@@ -24,8 +24,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TestMultiThreadAddDelete {
+    private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadAddDelete.class);
     private static final int RETRIES = 1;
     private static final int N_THREADS = 7;
     private static final int COUNT = 50 * 1000;
@@ -85,11 +88,11 @@ public class TestMultiThreadAddDelete {
                                 if (j % N_THREADS == threadNo) {
                                     bt.put(Integer.valueOf(j), Integer.valueOf(j));
                                     if (!bt.containsKey(Integer.valueOf(j))) {
-                                        System.out.println(j);
+                                        LOG.error("Key {} not present", j);
                                     }
                                     bt.remove(Integer.valueOf(j));
                                     if (bt.containsKey(Integer.valueOf(j))) {
-                                        System.out.println(-j);
+                                        LOG.error("Key {} is still present", j);
                                     }
                                 }
                             }
index 1962882f86f0ac13f7f2b0a2accaf72ce02434af..bd1fbdae87e3aed4400328f32ec82c1e3a2dde43 100644 (file)
@@ -28,8 +28,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TestMultiThreadMapIterator {
+    private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadMapIterator.class);
     private static final int NTHREADS = 7;
 
     @Test
@@ -41,7 +44,7 @@ public class TestMultiThreadMapIterator {
             }
         }
 
-        // System.out.println("Size of initialized map is " + bt.size());
+        LOG.debug("Size of initialized map is {}", bt.size());
         int count = 0;
         {
             final ExecutorService es = Executors.newFixedThreadPool(NTHREADS);
@@ -79,11 +82,11 @@ public class TestMultiThreadMapIterator {
                         Object key = e.getKey();
                         if (accepts(threadNo, NTHREADS, key)) {
                             if (null == bt.get(key)) {
-                                // System.out.println(key);
+                                LOG.error("Key {} is not present", key);
                             }
                             it.remove();
                             if (null != bt.get(key)) {
-                                // System.out.println(key);
+                                LOG.error("Key {} is still present", key);
                             }
                             removed.put(key, key);
                         }
@@ -102,7 +105,7 @@ public class TestMultiThreadMapIterator {
         }
         for (final Object o : bt.keySet()) {
             if (!removed.contains(bt.get(o))) {
-                System.out.println("Not removed: " + o);
+                LOG.error("Not removed: {}", o);
             }
         }
         assertEquals(0, count);