Fix for testcases
[jabaws.git] / testsrc / compbio / engine / conf / PropertyHelperManagerTester.java
1 /* Copyright (c) 2009 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
4  * \r
5  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
6  *  Apache License version 2 as published by the Apache Software Foundation\r
7  * \r
8  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
9  *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
10  *  License for more details.\r
11  * \r
12  *  A copy of the license is in apache_license.txt. It is also available here:\r
13  * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 \r
19 package compbio.engine.conf;\r
20 \r
21 import static org.testng.Assert.assertNotNull;\r
22 import static org.testng.Assert.assertTrue;\r
23 \r
24 import java.io.File;\r
25 \r
26 import org.testng.annotations.BeforeClass;\r
27 import org.testng.annotations.Test;\r
28 \r
29 import compbio.metadata.AllTestSuit;\r
30 import compbio.util.PropertyHelper;\r
31 \r
32 public class PropertyHelperManagerTester {\r
33 \r
34         PropertyHelper ph;\r
35 \r
36         @BeforeClass(alwaysRun=true)\r
37         public void testLoadResources() {\r
38                 ph = PropertyHelperManager.getPropertyHelper();\r
39                 assertNotNull(ph);\r
40         }\r
41 \r
42         @Test(groups = AllTestSuit.test_group_cluster)\r
43         public void testClusterEngineConf() {\r
44                 // Below are the properties on cluster engine required for its\r
45                 // functioning\r
46                 validateDirProp("cluster.tmp.directory");\r
47         }\r
48 \r
49         void validateDirProp(String propName) {\r
50                 assertNotNull(ph);\r
51                 assertNotNull(ph.getProperty(propName));\r
52                 File tmp = new File(ph.getProperty(propName).trim());\r
53                 assertTrue(tmp.exists());\r
54                 assertTrue(tmp.isDirectory());\r
55                 assertTrue(tmp.canRead());\r
56                 assertTrue(tmp.canWrite());\r
57         }\r
58 \r
59         void validateExecFileProp(String propName) {\r
60                 validateFileProp(propName);\r
61                 File tmp = new File(ph.getProperty(propName));\r
62                 assertTrue(tmp.canExecute());\r
63         }\r
64 \r
65         void validateFileProp(String propName) {\r
66                 assertNotNull(ph.getProperty(propName));\r
67                 File tmp = new File(ph.getProperty(propName));\r
68                 assertTrue(tmp.exists());\r
69                 assertTrue(tmp.isFile());\r
70                 assertTrue(tmp.canRead());\r
71         }\r
72 \r
73         @Test\r
74         public void validateClustalConfiguration() {\r
75                 // Below are the properties on Clustal executable required for its\r
76                 // functioning\r
77                 // Executables could not be verified as full path is constructed only at\r
78                 // runtime\r
79                 assertNotNull("local.clustalw.bin.windows");\r
80                 assertNotNull("local.clustalw.bin");\r
81                 assertNotNull("cluster.clustalw.bin");\r
82                 validateFileProp("clustalw.presets.file");\r
83                 validateFileProp("clustalw.parameters.file");\r
84                 validateFileProp("clustalw.limits.file");\r
85         }\r
86 \r
87         @Test\r
88         public void validateMuscleConfiguration() {\r
89                 assertNotNull("local.muscle.bin.windows");\r
90                 assertNotNull("local.muscle.bin");\r
91                 assertNotNull("cluster.muscle.bin");\r
92                 validateFileProp("muscle.presets.file");\r
93                 validateFileProp("muscle.parameters.file");\r
94                 validateFileProp("muscle.limits.file");\r
95         }\r
96 \r
97         @Test\r
98         public void validateTcoffeeConfiguration() {\r
99                 assertNotNull("local.tcoffee.bin.windows");\r
100                 assertNotNull("local.tcoffee.bin");\r
101                 assertNotNull("cluster.tcoffee.bin");\r
102                 validateFileProp("tcoffee.presets.file");\r
103                 validateFileProp("tcoffee.parameters.file");\r
104                 validateFileProp("tcoffee.limits.file");\r
105         }\r
106 \r
107         @Test\r
108         public void validateMafftConfiguration() {\r
109                 assertNotNull("local.mafft.bin.windows");\r
110                 assertNotNull("local.mafft.bin");\r
111                 assertNotNull("cluster.mafft.bin");\r
112                 validateFileProp("mafft.presets.file");\r
113                 validateFileProp("mafft.parameters.file");\r
114                 validateFileProp("mafft.limits.file");\r
115         }\r
116 }\r