ensure we never check in autogenerated documentation or build artefacts
[jabaws.git] / testsrc / compbio / runner / _impl / MclTester.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 package compbio.runner._impl;\r
19 \r
20 import static org.testng.AssertJUnit.assertEquals;\r
21 import static org.testng.AssertJUnit.assertFalse;\r
22 import static org.testng.AssertJUnit.assertNotNull;\r
23 import static org.testng.AssertJUnit.assertTrue;\r
24 import static org.testng.AssertJUnit.fail;\r
25 \r
26 import java.text.ParseException;\r
27 \r
28 import org.ggf.drmaa.DrmaaException;\r
29 import org.ggf.drmaa.JobInfo;\r
30 import org.testng.annotations.Test;\r
31 \r
32 import compbio.engine.cluster.drmaa.ClusterUtil;\r
33 import compbio.engine.cluster.drmaa.JobRunner;\r
34 import compbio.engine.cluster.drmaa.StatisticManager;\r
35 import compbio.metadata.AllTestSuit;\r
36 import compbio.metadata.JobExecutionException;\r
37 import compbio.metadata.JobStatus;\r
38 import compbio.metadata.JobSubmissionException;\r
39 \r
40 public class MclTester {\r
41 \r
42         public static String test_input = "/homes/pvtroshin/mclReady_E-TABM-145_CorDesc-10_Spearman.txt";\r
43         public static String test_outfile = "/homes/pvtroshin/MCL-E-TABM-145_25-06-2009.txt";\r
44 \r
45         @Test()\r
46         public void testGetTestCommand() {\r
47                 System.out.println(Mcl.getTestCommand());\r
48         }\r
49 \r
50         @Test(enabled = false, groups = { AllTestSuit.test_group_cluster,\r
51                         AllTestSuit.test_group_runner })\r
52         public void testBuildCommand() {\r
53                 Mcl mcl = new Mcl(AllTestSuit.OUTPUT_DIR_ABSOLUTE);\r
54                 // TODO mcl.setInput(test_input).setOutput(test_outfile);\r
55                 // mcl.setParameters(Mcl.getTestParams());\r
56 \r
57                 try {\r
58                         JobRunner runner = JobRunner.getInstance(null);\r
59                         assertNotNull("Runner is NULL", runner);\r
60                         runner.executeJob();\r
61                         // assertNotNull("JobId is NULL", jobId1);\r
62                         JobStatus status = runner.getJobStatus();\r
63                         assertTrue("Session state is wrong", status == JobStatus.PENDING\r
64                                         || status == JobStatus.RUNNING);\r
65                         JobInfo info = runner.getJobInfo();\r
66                         assertNotNull("JobInfo is null", info);\r
67                         StatisticManager sm = new StatisticManager(info);\r
68                         assertNotNull("StatisticManager is null", sm);\r
69                         try {\r
70                                 String time_s = sm.getCalculationTime();\r
71                                 assertNotNull("Calculation time is null", time_s);\r
72                                 String exits = sm.getExitStatus();\r
73                                 assertNotNull("Exit status is null", exits);\r
74                                 int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
75                                                 .intValue();\r
76                                 assertEquals("Exist status is not 0", 0, exitsInt);\r
77                                 System.out.println(sm.getAllStats());\r
78 \r
79                         } catch (ParseException e) {\r
80                                 e.printStackTrace();\r
81                                 fail("Parse Exception: " + e.getLocalizedMessage());\r
82                         }\r
83 \r
84                         assertTrue("Process exited:", sm.hasExited());\r
85                         assertFalse("Process aborted:", sm.wasAborted());\r
86                         assertFalse("Process hasdump:", sm.hasDump());\r
87                         assertFalse("Process signaled:", sm.hasSignaled());\r
88 \r
89                 } catch (DrmaaException e) {\r
90                         e.printStackTrace();\r
91                         fail(e.getLocalizedMessage());\r
92                 } catch (JobSubmissionException e) {\r
93                         e.printStackTrace();\r
94                         fail(e.getLocalizedMessage());\r
95                 } catch (JobExecutionException e) {\r
96                         e.printStackTrace();\r
97                         fail(e.getLocalizedMessage());\r
98                 }\r
99         }\r
100 \r
101 }\r