diff options
author | 2018-03-27 19:39:30 +0800 | |
---|---|---|
committer | 2018-03-27 19:39:30 +0800 | |
commit | 85d1d33bbd8f32cbf581131180d62d61a2d4b0ee (patch) | |
tree | fd3d7d80f184d9f1ac56e97f2ee0103320c29ab6 /sdc-workflow-designer-server/src/test | |
parent | 53a0027afd07d532a0c5d8d51ecffbfd5995b773 (diff) |
Add Unit Test for FileCommonUtils
Add Unit Test for FileCommonUtils
Issue-ID: SDC-1078
Change-Id: Ib58fd14cf996eeea3cb8af82eb0f831d9ee40d3f
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src/test')
-rw-r--r-- | sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtilsTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
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);
+ }
}
/**
|