From 1b7527b26b653d95f53d7b033b58aca3444dde9e Mon Sep 17 00:00:00 2001 From: yangyan Date: Thu, 22 Mar 2018 17:45:01 +0800 Subject: solve test code bug Issue-ID: VFC-836 Change-Id: I515675d31f3f19c63c36fd5d592dc3d44e3652ba Signed-off-by: yangyan --- .../collector/alarm/AlarmTaskThreadTest.java | 20 +++++++++----------- .../emsdriver/collector/alarm/HeartBeatTest.java | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThreadTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThreadTest.java index 6b2b6c8..1031ff9 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThreadTest.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThreadTest.java @@ -27,15 +27,17 @@ public class AlarmTaskThreadTest { private AlarmTaskThread taskThread; private AlarmSocketServer server; + private Thread severThread; @Before public void setUp() throws IOException { - new Thread() { + severThread = new Thread(new Runnable(){ public void run() { server = new AlarmSocketServer(); server.socketServer(); } - }.start(); + }); + severThread.start(); CollectVo collectVo = new CollectVo(); collectVo.setIP("127.0.0.1"); collectVo.setPort("12345"); @@ -73,16 +75,12 @@ public class AlarmTaskThreadTest { @Test public void runAlarmTaskThread() { - try { - taskThread.run(); - Thread.sleep(10000); - taskThread.setStop(true); + taskThread.start(); + //Thread.sleep(3000); server.stop(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + severThread.stop(); + taskThread.setStop(true); + taskThread.close(); } } diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeatTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeatTest.java index 2ffb589..d93f51f 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeatTest.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeatTest.java @@ -43,7 +43,7 @@ public class HeartBeatTest { Socket socket = new Socket("127.0.0.1",12345); Msg msg = MessageUtil.putHeartBeatMsg(1); HeartBeat heartBeat = new HeartBeat(socket,msg); - heartBeat.run(); + heartBeat.start(); Thread.sleep(10); heartBeat.setStop(true); server.stop(); -- cgit 1.2.3-korg