From 85d1d33bbd8f32cbf581131180d62d61a2d4b0ee Mon Sep 17 00:00:00 2001 From: YuanHu Date: Tue, 27 Mar 2018 19:39:30 +0800 Subject: Add Unit Test for FileCommonUtils Add Unit Test for FileCommonUtils Issue-ID: SDC-1078 Change-Id: Ib58fd14cf996eeea3cb8af82eb0f831d9ee40d3f Signed-off-by: YuanHu --- .../utils/FileCommonUtilsTest.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sdc-workflow-designer-server/src/test') diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java index 39065056..aba1a319 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java @@ -14,7 +14,10 @@ package org.onap.sdc.workflowdesigner.utils; import static org.junit.Assert.assertEquals; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.StringBufferInputStream; import org.junit.After; import org.junit.Before; @@ -42,6 +45,23 @@ public class FileCommonUtilsTest { */ @Test public void testReadLines() { + String fileName = "src/test/resources/workflow/template-test.bpmn20.xml"; + File file = new File(fileName); + FileInputStream ins = null; + try { + ins = new FileInputStream(file); + String[] ss = FileCommonUtils.readLines(ins); + assertEquals(false, ss.length == 0); + + FileCommonUtils.write("template-test.bpmn20.xml", ss); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + FileCommonUtils.closeInputStream(ins); + } + } /** @@ -73,6 +93,16 @@ public class FileCommonUtilsTest { */ @Test public void testSaveFile() { + String fileName = "test3.json"; + String content = "{\"aaa\": \"节点\"}"; + StringBufferInputStream ins = null; + try { + ins = new StringBufferInputStream(content); + FileCommonUtils.saveFile(ins, ".", fileName); + } catch (IOException e) { + e.printStackTrace(); + FileCommonUtils.closeInputStream(ins); + } } /** -- cgit 1.2.3-korg