diff options
author | yangyan <yangyanyj@chinamobile.com> | 2018-03-20 17:24:16 +0800 |
---|---|---|
committer | yangyan <yangyanyj@chinamobile.com> | 2018-03-20 17:24:35 +0800 |
commit | 849c25e46eba70936966bb33e5741430f7ac2936 (patch) | |
tree | 0e4c9120a566375cae0af498ad3f2d42e49c5b63 | |
parent | c61edb4b613c8eeb415aa5b0227c2ab1d2055765 (diff) |
Add unit test
Issue-ID: VFC-836
Change-Id: Ie893da7ce8c6c85459644b4e5251460e6439b420
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
4 files changed, 57 insertions, 4 deletions
diff --git a/ems/boco/data/aaa.txt b/ems/boco/data/aaa.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ems/boco/data/aaa.txt diff --git a/ems/boco/data/bbb.txt b/ems/boco/data/bbb.txt index e69de29..458aab0 100644 --- a/ems/boco/data/bbb.txt +++ b/ems/boco/data/bbb.txt @@ -0,0 +1 @@ +test abc
\ No newline at end of file diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/CollectMsgReceiverThread.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/CollectMsgReceiverThread.java index d3ced48..89cf34b 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/CollectMsgReceiverThread.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/CollectMsgReceiverThread.java @@ -35,7 +35,6 @@ public class CollectMsgReceiverThread extends DriverThread { @Override public void dispose() { collectChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY); - taskService = TaskThreadService.getInstance(threadMaxNum); taskService.start(); diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtilTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtilTest.java index 2f3d637..171c041 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtilTest.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtilTest.java @@ -15,10 +15,17 @@ */ package org.onap.vfc.nfvo.emsdriver.collector.alarm; -import org.junit.Test; - import static org.junit.Assert.assertNotNull; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.junit.Test; + public class MessageUtilTest { @Test @@ -62,6 +69,52 @@ public class MessageUtilTest { assertNotNull(msg); } + + @Test + public void putloginMsg() { + String user = "test"; + String passwd = "test"; + Msg msg = MessageUtil.putLoginMsg(user, passwd); + assertNotNull(msg); + } - + @Test + public void putHeartBeatMsg() { + Msg msg = MessageUtil.putHeartBeatMsg(1); + assertNotNull(msg); + } + + @Test + public void readOneMsg(){ + try { + String fileName = System.getProperty("user.dir") + "/data/" + "bbb.txt"; + FileInputStream fis = new FileInputStream(fileName); + BufferedInputStream bis=new BufferedInputStream(fis); + Msg msg = MessageUtil.readOneMsg(bis); + assertNotNull(msg); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + System.out.println("File is not found"); + } catch (IOException e){ + System.out.println("There is IOException"); + } + } + + + + @Test + public void writeMsg(){ + try { + String msgBody = "Heartbeat"; + Msg msg = new Msg(msgBody,MsgType.ACK_HEARTBEAT); + String fileName = System.getProperty("user.dir") + "/data/" + "aaa.txt"; + FileOutputStream fos=new FileOutputStream(fileName); + BufferedOutputStream bos=new BufferedOutputStream(fos); + MessageUtil.writeMsg(msg, bos); + } catch (IOException e) { + // TODO Auto-generated catch block + System.out.println("There is IOException"); + } + + } } |