From 5a55b790e8afa3131fd5f894e5d1b1e036dc4cd1 Mon Sep 17 00:00:00 2001 From: econwar Date: Mon, 24 Jun 2019 11:03:58 +0000 Subject: Add test cases for 65% branch coverage Format the Test classes to adhere to ONAP Java style Change-Id: I9efad3caa532c4db73bb20327d0356b3af5ed2b1 Issue-ID: DMAAP-1195 Signed-off-by: econwar --- .../main/java/org/onap/dmaap/datarouter/node/Delivery.java | 8 ++++---- .../main/java/org/onap/dmaap/datarouter/node/LogManager.java | 12 +++++++++--- .../main/java/org/onap/dmaap/datarouter/node/StatusLog.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'datarouter-node/src/main/java/org') diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java index df73c1e9..e4013240 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java @@ -28,7 +28,7 @@ import com.att.eelf.configuration.EELFManager; import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Objects; /** @@ -50,7 +50,7 @@ public class Delivery { private int threads; private int curthreads; private NodeConfigManager config; - private Hashtable dqs = new Hashtable<>(); + private HashMap dqs = new HashMap<>(); private DeliveryQueue[] queues = new DeliveryQueue[0]; private int qpos = 0; private long nextcheck; @@ -178,7 +178,7 @@ public class Delivery { DestInfo[] alldis = config.getAllDests(); DeliveryQueue[] nqs = new DeliveryQueue[alldis.length]; qpos = 0; - Hashtable ndqs = new Hashtable<>(); + HashMap ndqs = new HashMap<>(); for (DestInfo di : alldis) { String spl = di.getSpool(); DeliveryQueue dq = dqs.get(spl); @@ -266,7 +266,7 @@ public class Delivery { return false; } - private static class DelItem implements Comparable { + static class DelItem implements Comparable { private String pubid; private String spool; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java index 3277408c..903a0c5f 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/LogManager.java @@ -56,6 +56,8 @@ public class LogManager extends TimerTask { private String uploaddir; private String logdir; + private static final String EXCEPTION = "Exception"; + /** * Construct a log manager * @@ -68,7 +70,7 @@ public class LogManager extends TimerTask { isnodelog = Pattern.compile("node\\.log\\.\\d{8}").matcher(""); iseventlog = Pattern.compile("events-\\d{12}\\.log").matcher(""); } catch (Exception e) { - logger.error("Exception", e); + logger.error(EXCEPTION, e); } logdir = config.getLogDir(); uploaddir = logdir + "/.spool"; @@ -87,9 +89,12 @@ public class LogManager extends TimerTask { worker.poke(); } - private class Uploader extends Thread implements DeliveryQueueHelper { + public Uploader getWorker() { + return worker; + } + + class Uploader extends Thread implements DeliveryQueueHelper { - private static final String EXCEPTION = "Exception"; private static final String META = "/.meta"; private EELFLogger logger = EELFManager.getInstance().getLogger(Uploader.class); private DeliveryQueue dq; @@ -166,6 +171,7 @@ public class LogManager extends TimerTask { notify(); } + @Override public void run() { while (true) { scan(); diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java index e6165588..2d02fa66 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/StatusLog.java @@ -53,7 +53,7 @@ public class StatusLog { private long nexttime; private OutputStream os; private long intvl; - private NodeConfigManager config = NodeConfigManager.getInstance(); + private static NodeConfigManager config = NodeConfigManager.getInstance(); private StatusLog() { } -- cgit 1.2.3-korg