2 * Copyright (c) 2018 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
10 * ZTE - initial API and implementation and/or initial documentation
13 package org.onap.sdc.workflowdesigner.utils;
15 import static org.junit.Assert.assertEquals;
18 import java.io.IOException;
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Test;
27 public class FileCommonUtilsTest {
30 * @throws java.lang.Exception
33 public void setUp() throws Exception {}
36 * @throws java.lang.Exception
39 public void tearDown() throws Exception {}
42 * Test method for {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#readString(String)}
46 public final void readStringString() {
47 String fileName = "src\\test\\resources\\workflow\\template-test.bpmn20.xml";
48 File file = new File(fileName);
51 String s = FileCommonUtils.readString(fileName);
52 FileCommonUtils.write("test.xml", s);
53 assertEquals(s.isEmpty(), false);
54 } catch (IOException e) {
62 * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#write(String, String)}
66 public final void writeStringString() {
67 String fileName = "test.json";
68 String content = "{\"aaa\": \"节点\"}";
71 FileCommonUtils.write(fileName, content);
72 String s = FileCommonUtils.readString(fileName);
73 assertEquals(s, content);
74 } catch (IOException e) {
80 * {@link org.onap.sdc.workflowdesigner.utils.FileCommonUtils#writetoAbsoluteFile(String, String, String)}
84 public final void saveFileStringStringString() {
85 String fileName = "test1.json";
86 String content = "{\"aaa\": \"节点\"}";
89 FileCommonUtils.writetoAbsoluteFile(".", fileName, content);
90 String s = FileCommonUtils.readString(fileName);
91 assertEquals(s, content);
92 } catch (IOException e) {