diff options
author | Conor Ward <conor.ward@est.tech> | 2019-05-14 14:44:57 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-05-14 14:44:57 +0000 |
commit | b9b250073348d5b9536cce92c22f92f74e827b57 (patch) | |
tree | 5061cac1a94e004fabc54027550cbc206a2ff83d | |
parent | 5a965147815d39f7825b2fc207e49bc470373129 (diff) | |
parent | 5e6a9f65049e8e8d39e8dcab227e5d75b328b173 (diff) |
Merge "Remove datarouter-node critical code smells"
13 files changed, 84 insertions, 35 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java index 30ad1618..991d8660 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilter.java @@ -74,7 +74,7 @@ public class DRNodeCadiFilter extends CadiFilter { try { resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI. Expecting <feed-publishing-url>/<fileid>."); } catch (IOException e) { - logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e.getMessage()); + logger.error("NODE0541 DRNodeCadiFilter.getFeedId: ", e); } return null; } @@ -88,7 +88,7 @@ public class DRNodeCadiFilter extends CadiFilter { try { resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Invalid request URI. Expecting <feed-publishing-url>/<fileid>. Possible missing fileid."); } catch (IOException e) { - logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e.getMessage()); + logger.error("NODE0542 DRNodeCadiFilter.getFeedId: ", e); } return null; } 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 501e489c..4c21b342 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 @@ -68,6 +68,24 @@ public class Delivery { this.pubid = pubid; this.spool = spool; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DelItem delItem = (DelItem) o; + return Objects.equals(pubid, delItem.pubid) && + Objects.equals(getSpool(), delItem.getSpool()); + } + + @Override + public int hashCode() { + return Objects.hash(pubid, getSpool()); + } } private double fdstart; @@ -246,6 +264,7 @@ public class Delivery { try { wait(nextcheck + 500 - now); } catch (Exception e) { + logger.error("InterruptedException", e); } now = System.currentTimeMillis(); } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java index bef8dab2..3d485878 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryQueue.java @@ -24,6 +24,8 @@ package org.onap.dmaap.datarouter.node; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.*; import java.util.*; @@ -64,6 +66,7 @@ import java.util.*; * failure timer is active or if no files are found in a directory scan. */ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { + private static EELFLogger logger = EELFManager.getInstance().getLogger(DeliveryQueue.class); private DeliveryQueueHelper deliveryQueueHelper; private DestInfo destinationInfo; private Hashtable<String, DeliveryTask> working = new Hashtable<>(); @@ -215,6 +218,7 @@ public class DeliveryQueue implements Runnable, DeliveryTaskHelper { try { pidtime = Long.parseLong(fname2.substring(0, dot)); } catch (Exception e) { + logger.error("Exception", e); } if (pidtime < 1000000000000L) { continue; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java index cca61707..018c3aff 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java @@ -127,7 +127,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> { hdrv.add(new String[]{h, v}); } } catch (Exception e) { - eelfLogger.error("Exception "+ Arrays.toString(e.getStackTrace()), e.getMessage()); + eelfLogger.error("Exception", e); } hdrs = hdrv.toArray(new String[hdrv.size()][]); url = deliveryTaskHelper.getDestURL(fileid); @@ -272,7 +272,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> { outputStream.close(); } catch (IOException e) { httpURLConnection.setRequestProperty("Decompression_Status", "FAILURE"); - eelfLogger.info("Could not decompress file"); + eelfLogger.info("Could not decompress file", e); sendFile(httpURLConnection); } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java index f7cedd22..534b2b35 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java @@ -71,7 +71,7 @@ public class IsFrom { hostAddrArray.add(addr.getHostAddress()); } } catch (UnknownHostException e) { - logger.error("IsFrom: UnknownHostEx: " + e.toString(), e.getMessage()); + logger.error("IsFrom: UnknownHostEx: " + e.toString(), e); } ips = hostAddrArray.toArray(new String[0]); logger.info("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips)); @@ -90,9 +90,9 @@ public class IsFrom { return true; } } catch (UnknownHostException e) { - logger.error("IsFrom: UnknownHostEx: " + e.toString(), e.getMessage()); + logger.error("IsFrom: UnknownHostEx: " + e.toString(), e); } catch (IOException e) { - logger.error("IsFrom: Failed to parse IP : " + ip + " : " + e.toString(), e.getMessage()); + logger.error("IsFrom: Failed to parse IP : " + ip + " : " + e.toString(), e); } return false; } 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 78a195b1..6ffb7604 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 @@ -22,6 +22,8 @@ ******************************************************************************/ package org.onap.dmaap.datarouter.node; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -43,7 +45,7 @@ import java.util.regex.Pattern; */ public class LogManager extends TimerTask { - + private EELFLogger logger = EELFManager.getInstance().getLogger(LogManager.class); private NodeConfigManager config; private Matcher isnodelog; private Matcher iseventlog; @@ -52,6 +54,7 @@ public class LogManager extends TimerTask { private String logdir; private class Uploader extends Thread implements DeliveryQueueHelper { + private EELFLogger logger = EELFManager.getInstance().getLogger(Uploader.class); public long getInitFailureTimer() { return (10000L); @@ -117,6 +120,7 @@ public class LogManager extends TimerTask { try { wait(10000); } catch (Exception e) { + logger.error("InterruptedException", e); } } @@ -148,6 +152,7 @@ public class LogManager extends TimerTask { lastqueued = br.readLine(); br.close(); } catch (Exception e) { + logger.error("Exception", e); } for (String fn : fns) { if (!isnodelog.reset(fn).matches()) { @@ -161,6 +166,7 @@ public class LogManager extends TimerTask { Files.createLink(Paths.get(uploaddir + "/" + pid), Paths.get(logdir + "/" + fn)); Files.createLink(Paths.get(uploaddir + "/" + pid + ".M"), Paths.get(uploaddir + "/.meta")); } catch (Exception e) { + logger.error("Exception", e); } } } @@ -173,6 +179,7 @@ public class LogManager extends TimerTask { (new File(uploaddir + "/.meta")).delete(); w.write(lastqueued + "\n"); } catch (Exception e) { + logger.error("Exception", e); } } } @@ -189,6 +196,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); } logdir = config.getLogDir(); uploaddir = logdir + "/.spool"; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java index 16099e62..884f7bf9 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeConfigManager.java @@ -121,7 +121,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { .getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties"))); } catch (Exception e) { NodeUtils.setIpAndFqdnForEelf("NodeConfigManager"); - eelfLogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR, System.getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")); + eelfLogger.error(EelfMsgs.MESSAGE_PROPERTIES_LOAD_ERROR, e, System.getProperty("org.onap.dmaap.datarouter.node.properties", "/opt/app/datartr/etc/node.properties")); } provurl = drNodeProperties.getProperty("ProvisioningURL", "https://dmaap-dr-prov:8443/internal/prov"); /* @@ -144,7 +144,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { provhost = (new URL(provurl)).getHost(); } catch (Exception e) { NodeUtils.setIpAndFqdnForEelf("NodeConfigManager"); - eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, provurl); + eelfLogger.error(EelfMsgs.MESSAGE_BAD_PROV_URL, e, provurl); System.exit(1); } eelfLogger.info("NODE0303 Provisioning server is " + provhost); @@ -218,42 +218,52 @@ public class NodeConfigManager implements DeliveryQueueHelper { try { initfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_INIT_RETRY_INTERVAL")) * 1000); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_INIT_RETRY_INTERVAL", e); } try { waitForFileProcessFailureTimer = (long) (Double.parseDouble(getProvParam("DELIVERY_FILE_PROCESS_INTERVAL")) * 1000); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_FILE_PROCESS_INTERVAL", e); } try { maxfailuretimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_RETRY_INTERVAL")) * 1000); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_MAX_RETRY_INTERVAL", e); } try { expirationtimer = (long) (Double.parseDouble(getProvParam("DELIVERY_MAX_AGE")) * 1000); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_MAX_AGE", e); } try { failurebackoff = Double.parseDouble(getProvParam("DELIVERY_RETRY_RATIO")); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_RETRY_RATIO", e); } try { deliverythreads = Integer.parseInt(getProvParam("DELIVERY_THREADS")); } catch (Exception e) { + eelfLogger.error("Error parsing DELIVERY_THREADS", e); } try { fairfilelimit = Integer.parseInt(getProvParam("FAIR_FILE_LIMIT")); } catch (Exception e) { + eelfLogger.error("Error parsing FAIR_FILE_LIMIT", e); } try { fairtimelimit = (long) (Double.parseDouble(getProvParam("FAIR_TIME_LIMIT")) * 1000); } catch (Exception e) { + eelfLogger.error("Error parsing FAIR_TIME_LIMIT", e); } try { fdpstart = Double.parseDouble(getProvParam("FREE_DISK_RED_PERCENT")) / 100.0; } catch (Exception e) { + eelfLogger.error("Error parsing FREE_DISK_RED_PERCENT", e); } try { fdpstop = Double.parseDouble(getProvParam("FREE_DISK_YELLOW_PERCENT")) / 100.0; } catch (Exception e) { + eelfLogger.error("Error parsing FREE_DISK_YELLOW_PERCENT", e); } if (fdpstart < 0.01) { fdpstart = 0.01; @@ -287,7 +297,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { } catch (Exception e) { NodeUtils.setIpAndFqdnForEelf("fetchconfigs"); eelfLogger.error(EelfMsgs.MESSAGE_CONF_FAILED, e.toString()); - eelfLogger.error("NODE0306 Configuration failed " + e.toString() + " - try again later", e.getMessage()); + eelfLogger.error("NODE0306 Configuration failed " + e.toString() + " - try again later", e); pfetcher.request(); } } @@ -842,7 +852,7 @@ public class NodeConfigManager implements DeliveryQueueHelper { } return type + "|" + aafInstance + "|" + action; } catch (Exception e) { - eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e.getMessage()); + eelfLogger.error("NODE0543 NodeConfigManager.getPermission: ", e); } return null; } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java index 058295d3..7a2691e4 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java @@ -56,7 +56,7 @@ public class NodeMain { try { in = getClass().getClassLoader().getResourceAsStream("drNodeCadi.properties"); } catch (Exception e) { - nodeMainLogger.error("Exception in Inner.getCadiProps() method " + e.getMessage()); + nodeMainLogger.error("Exception in Inner.getCadiProps() method ", e); } return in; } @@ -181,7 +181,7 @@ public class NodeMain { InputStream in = obj.getCadiProps(); cadiProperties.load(in); } catch (IOException e1) { - nodeMainLogger.error("NODE00005 Exception in NodeMain.Main() loading CADI properties " + e1.getMessage()); + nodeMainLogger.error("NODE00005 Exception in NodeMain.Main() loading CADI properties ", e1); } cadiProperties.setProperty("aaf_locate_url", nodeConfigManager.getAafURL()); nodeMainLogger.info("NODE00005 aaf_url set to - " + cadiProperties.getProperty("aaf_url")); @@ -199,7 +199,7 @@ public class NodeMain { server.start(); nodeMainLogger.info("NODE00006 Node Server started-" + server.getState()); } catch (Exception e) { - nodeMainLogger.info("NODE00006 Jetty failed to start. Reporting will we unavailable", e.getMessage()); + nodeMainLogger.info("NODE00006 Jetty failed to start. Reporting will we unavailable", e); } server.join(); nodeMainLogger.info("NODE00007 Node Server joined - " + server.getState()); diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java index a9842116..d665080b 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java @@ -117,7 +117,7 @@ public class NodeServlet extends HttpServlet { } } catch (IOException ioe) { - eelfLogger.error("IOException" + ioe.getMessage()); + eelfLogger.error("IOException", ioe); } String path = req.getPathInfo(); String qs = req.getQueryString(); @@ -158,7 +158,7 @@ public class NodeServlet extends HttpServlet { try { common(req, resp, true); } catch (IOException ioe) { - eelfLogger.error("IOException" + ioe.getMessage()); + eelfLogger.error("IOException", ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -176,7 +176,7 @@ public class NodeServlet extends HttpServlet { try { common(req, resp, false); } catch (IOException ioe) { - eelfLogger.error("IOException " + ioe.getMessage()); + eelfLogger.error("IOException", ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -437,7 +437,7 @@ public class NodeServlet extends HttpServlet { try { exlen = Long.parseLong(req.getHeader("Content-Length")); } catch (Exception e) { - eelfLogger.error("NODE00000 Exception common: " + e.getMessage()); + eelfLogger.error("NODE00000 Exception common", e); } StatusLog.logPubFail(pubid, feedid, logurl, req.getMethod(), ctype, exlen, data.length(), ip, user, ioe.getMessage()); //Fortify scan fixes - log forging @@ -520,7 +520,7 @@ public class NodeServlet extends HttpServlet { } } catch (IOException ioe) { eelfLogger.error("NODE0117 Unable to delete files (" + pubid + ", " + pubid + ".M) from DR Node: " - + config.getMyName() + ". Error: " + ioe.getMessage()); + + config.getMyName(), ioe); eelfLogger.info(EelfMsgs.EXIT); } } @@ -562,7 +562,8 @@ public class NodeServlet extends HttpServlet { return false; } } catch (NullPointerException npe) { - eelfLogger.error("NODE0114 " + errorMessage + " Error: Subscription " + subscriptionId + " does not exist"); + eelfLogger.error("NODE0114 " + errorMessage + " Error: Subscription " + subscriptionId + + " does not exist", npe); resp.sendError(HttpServletResponse.SC_NOT_FOUND); eelfLogger.info(EelfMsgs.EXIT); return false; diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java index 4601f99c..da84ae54 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeUtils.java @@ -126,7 +126,7 @@ public class NodeUtils { } } catch (Exception e) { setIpAndFqdnForEelf("getCanonicalName"); - eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_LOAD_ERROR, ksfile, e.toString()); + eelfLogger.error(EelfMsgs.MESSAGE_KEYSTORE_LOAD_ERROR, e, ksfile); return (null); } return (getCanonicalName(ks)); @@ -161,7 +161,7 @@ public class NodeUtils { } } } catch (Exception e) { - eelfLogger.error("NODE0402 Error extracting my name from my keystore file " + e.toString(), e.getMessage()); + eelfLogger.error("NODE0402 Error extracting my name from my keystore file " + e.toString(), e); } return (null); } @@ -283,7 +283,7 @@ public class NodeUtils { try { response.sendError(errorCode); } catch (IOException ioe) { - intlogger.error("IOException" + ioe.getMessage()); + intlogger.error("IOException", ioe); } } diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java index 7e4078f8..4cd650b0 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/RedirManager.java @@ -24,9 +24,12 @@ package org.onap.dmaap.datarouter.node; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; +import java.io.IOException; import java.io.OutputStream; import java.util.Hashtable; import java.util.Timer; @@ -35,7 +38,7 @@ import java.util.Timer; * Track redirections of subscriptions */ public class RedirManager { - + private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(RedirManager.class); private Hashtable<String, String> sid2primary = new Hashtable<String, String>(); private Hashtable<String, String> sid2secondary = new Hashtable<String, String>(); private String redirfile; @@ -63,6 +66,7 @@ public class RedirManager { os.write(sb.toString().getBytes()); } } catch (Exception e) { + eelfLogger.error("Exception", e); } } }; @@ -80,7 +84,7 @@ public class RedirManager { } } } catch (Exception e) { - // missing file is normal + eelfLogger.error("Missing file is normal", e); } } 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 c8a7bd0c..1be3408a 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 @@ -23,6 +23,8 @@ package org.onap.dmaap.datarouter.node; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.util.regex.*; import java.util.*; import java.io.*; @@ -33,6 +35,7 @@ import java.text.*; * Logging for data router delivery events (PUB/DEL/EXP) */ public class StatusLog { + private static EELFLogger eelfLogger = EELFManager.getInstance().getLogger(StatusLog.class); private static StatusLog instance = new StatusLog(); private HashSet<String> toship = new HashSet<String>(); private SimpleDateFormat filedate; @@ -49,6 +52,7 @@ public class StatusLog { try { filedate = new SimpleDateFormat("-yyyyMMddHHmm"); } catch (Exception e) { + eelfLogger.error("Exception", e); } } @@ -104,6 +108,7 @@ public class StatusLog { def = best * 1000; } } catch (Exception e) { + eelfLogger.error("Exception", e); } return (def); } @@ -133,6 +138,7 @@ public class StatusLog { try { instance.checkRoll(System.currentTimeMillis()); } catch (Exception e) { + eelfLogger.error("Exception", e); } return (instance.curfile); } @@ -149,6 +155,7 @@ public class StatusLog { os.write((NodeUtils.logts(new Date(now)) + '|' + s + '\n').getBytes()); os.flush(); } catch (IOException ioe) { + eelfLogger.error("IOException", ioe); } } diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java index 6dc334fc..fa868b26 100644 --- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java +++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java @@ -45,20 +45,18 @@ public class DeliveryQueueTest { DeliveryQueueHelper deliveryQueueHelper; private String dirPath = "/tmp/dir001/"; - private String FileName1 = "10000000000004.fileName.M"; + private String fileName = "10000000000004.fileName.M"; @Before public void setUp() { - when(destInfo.getSpool()).thenReturn("tmp"); + when(destInfo.getSpool()).thenReturn(dirPath); deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo); } @Test public void Given_New_DeliveryQueue_Directory_Is_Created_As_Defined_By_DestInfo() { - when(destInfo.getSpool()).thenReturn("tmp"); - File file = new File("tmp"); + File file = new File("/tmp"); assertTrue(file.exists()); - deleteFile("tmp"); } @Test @@ -75,7 +73,7 @@ public class DeliveryQueueTest { deliveryQueue = new DeliveryQueue(deliveryQueueHelper, destInfo); DeliveryTask nt = deliveryQueue.getNext(); assertEquals("10000000000004.fileName", nt.getPublishId()); - deleteFile(dirPath + FileName1); + deleteFile(dirPath + fileName); deleteFile(dirPath); } @@ -87,9 +85,7 @@ public class DeliveryQueueTest { private void prepareFiles() throws Exception { createFolder(dirPath); - createFile(FileName1, dirPath); - String[] files = new String[2]; - files[0] = dirPath + FileName1; + createFile(fileName, dirPath); } private void createFolder(String dirName) { |