b8d4319cce8068bac21f96312ff1c74379bd2769
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-server / src / test / java / org / onap / sdc / workflowdesigner / utils / FileCommonUtilsTest.java
1 /**
2  * Copyright (c) 2017 ZTE Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the Apache License, Version 2.0
5  * and the Eclipse Public License v1.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     ZTE - initial API and implementation and/or initial documentation
11  */
12
13 package org.onap.sdc.workflowdesigner.utils;
14
15 import static org.junit.Assert.assertEquals;
16
17 import java.io.IOException;
18
19 import org.junit.After;
20 import org.junit.Before;
21 import org.junit.Test;
22
23 /**
24  *
25  */
26 public class FileCommonUtilsTest {
27
28   /**
29    * @throws java.lang.Exception
30    */
31   @Before
32   public void setUp() throws Exception {}
33
34   /**
35    * @throws java.lang.Exception
36    */
37   @After
38   public void tearDown() throws Exception {}
39
40   /**
41    * Test method for
42    * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(String, String)} .
43    */
44   @Test
45   public final void writeStringString() {
46     String fileName = "test.json";
47     String content = "{\"aaa\": \"节点\"}";
48
49     try {
50       FileCommonUtils.write(fileName, content);
51       String s = FileCommonUtils.readString(fileName);
52       assertEquals(s, content);
53     } catch (IOException e) {
54     }
55   }
56
57   /**
58    * Test method for
59    * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#writetoAbsoluteFile(String, String, String)}
60    * .
61    */
62   @Test
63   public final void saveFileStringStringString() {
64     String fileName = "test1.json";
65     String content = "{\"aaa\": \"节点\"}";
66
67     try {
68       FileCommonUtils.writetoAbsoluteFile(".", fileName, content);
69       String s = FileCommonUtils.readString(fileName);
70       assertEquals(s, content);
71     } catch (IOException e) {
72     }
73   }
74
75 }