1 package org.tizen.common.util;
3 import org.junit.After;
4 import org.junit.Before;
7 public class HostUtilTest {
9 private String packageName = HostUtilTest.class.getPackage().getName().replace('.', '/');
10 private String fileName = "test";
11 private String filePath = ClassLoader.getSystemResource(packageName + '/').getPath();
12 private String fullPath = filePath + fileName;
20 public void tearDown() {
25 * Test {@link HostUtil#getContents( String)}
27 * @throws Exception in case of failure in test
29 * @see HostUtil#getContents( String)
32 public void test_getContents() throws Exception {
33 Assert.notNull(HostUtil.getContents(fullPath));
34 Assert.isNull(HostUtil.getContents(null));
35 Assert.isNull(HostUtil.getContents("nullPath"));
39 * Test {@link HostUtil#exists( String)}
41 * @throws Exception in case of failure in test
43 * @see HostUtil#exists( String)
46 public void test_exists() throws Exception {
47 Assert.isTrue(HostUtil.exists(fullPath));
48 Assert.isFalse(HostUtil.exists(null));
49 Assert.isFalse(HostUtil.exists("nullPath"));
53 * Test {@link HostUtil#execute( String)}
55 * @throws Exception in case of failure in test
57 * @see HostUtil#execute( String)
60 public void test_execute() throws Exception {
61 Assert.isTrue(HostUtil.execute("cd"));
62 Assert.isFalse(HostUtil.execute(null));
63 Assert.isFalse(HostUtil.execute("notcommand"));
67 * Test {@link HostUtil#batchExecute( String)}
69 * @throws Exception in case of failure in test
71 * @see HostUtil#batchExecute( String)
74 public void test_batchExecute() throws Exception {
75 Assert.isFalse(HostUtil.batchExecute(null));
76 Assert.isTrue(HostUtil.batchExecute("cd"));
77 Assert.isFalse(HostUtil.batchExecute("notcommand"));
81 * Test {@link HostUtil#returnExecute( String)}
83 * @throws Exception in case of failure in test
85 * @see HostUtil#returnExecute( String)
88 public void test_returnExecute1() throws Exception {
89 Assert.isNull(HostUtil.returnExecute(null));
90 Assert.notNull(HostUtil.returnExecute("cd"));
94 * Test {@link HostUtil#returnExecute( String, String)}
96 * @throws Exception in case of failure in test
98 * @see HostUtil#returnExecute( String, String)
101 public void test_returnExecute2() throws Exception {
102 Assert.isNull(HostUtil.returnExecute(null, filePath));
103 Assert.notNull(HostUtil.returnExecute("cd", filePath));
107 * Test {@link HostUtil#executeWithConsole( String, String)}
109 * @throws Exception in case of failure in test
111 * @see HostUtil#executeWithConsole( String, String)
113 @Test(expected = Exception.class)
114 public void test_executeWithConsole() throws Exception {
115 HostUtil.executeWithConsole("notcommand", "viewname");