Merge sources from S-Core's RSA git (release)
[sdk/ide/common-eplugin.git] / org.tizen.common / test / src / org / tizen / common / util / HostUtilTest.java
1 package org.tizen.common.util;
2
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.Test;
6
7 public class HostUtilTest {
8
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;
13
14     @Before
15     public void setUp() {
16
17     }
18
19     @After
20     public void tearDown() {
21
22     }
23     
24     /**
25      * Test {@link HostUtil#getContents( String)}
26      * 
27      * @throws Exception in case of failure in test
28      * 
29      * @see HostUtil#getContents( String)
30      */
31     @Test
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"));
36     }
37     
38     /**
39      * Test {@link HostUtil#exists( String)}
40      * 
41      * @throws Exception in case of failure in test
42      * 
43      * @see HostUtil#exists( String)
44      */
45     @Test
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"));
50     }
51     
52     /**
53      * Test {@link HostUtil#execute( String)}
54      * 
55      * @throws Exception in case of failure in test
56      * 
57      * @see HostUtil#execute( String)
58      */
59     @Test
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"));
64     }
65     
66     /**
67      * Test {@link HostUtil#batchExecute( String)}
68      * 
69      * @throws Exception in case of failure in test
70      * 
71      * @see HostUtil#batchExecute( String)
72      */
73     @Test
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"));
78     }
79     
80     /**
81      * Test {@link HostUtil#returnExecute( String)}
82      * 
83      * @throws Exception in case of failure in test
84      * 
85      * @see HostUtil#returnExecute( String)
86      */
87     @Test
88     public void test_returnExecute1() throws Exception {
89         Assert.isNull(HostUtil.returnExecute(null));
90         Assert.notNull(HostUtil.returnExecute("cd"));
91     }
92     
93     /**
94      * Test {@link HostUtil#returnExecute( String, String)}
95      * 
96      * @throws Exception in case of failure in test
97      * 
98      * @see HostUtil#returnExecute( String, String)
99      */
100     @Test
101     public void test_returnExecute2() throws Exception {
102         Assert.isNull(HostUtil.returnExecute(null, filePath));
103         Assert.notNull(HostUtil.returnExecute("cd", filePath));
104     }
105     
106     /**
107      * Test {@link HostUtil#executeWithConsole( String, String)}
108      * 
109      * @throws Exception in case of failure in test
110      * 
111      * @see HostUtil#executeWithConsole( String, String)
112      */
113     @Test(expected = Exception.class)
114     public void test_executeWithConsole() throws Exception {
115         HostUtil.executeWithConsole("notcommand", "viewname");        
116     }
117 }