Next version of JABA
[jabaws.git] / testsrc / compbio / engine / cluster / drmaa / UtilTester.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.cluster.drmaa;\r
20 \r
21 import static org.testng.AssertJUnit.assertEquals;\r
22 import static org.testng.AssertJUnit.assertNotNull;\r
23 import static org.testng.AssertJUnit.fail;\r
24 \r
25 import java.text.ParseException;\r
26 \r
27 import org.testng.annotations.Test;\r
28 \r
29 import compbio.engine.cluster.drmaa.ClusterUtil;\r
30 \r
31 public class UtilTester {\r
32 \r
33         @Test\r
34         public void testParser() {\r
35                 try {\r
36                         Number n = ClusterUtil.CLUSTER_STAT_IN_SEC.parse("11.0000");\r
37                         assertNotNull(n);\r
38                         int t = n.intValue();\r
39                         assertEquals(11, t);\r
40                         n = ClusterUtil.CLUSTER_STAT_IN_SEC.parse("11.2300");\r
41                         assertNotNull(n);\r
42                         t = n.intValue();\r
43                         assertEquals(11, t);\r
44                         float f = n.floatValue();\r
45                         assertEquals(11.23f, f);\r
46                         n = ClusterUtil.CLUSTER_STAT_IN_SEC.parse("0.0310");\r
47                         assertNotNull(n);\r
48                         f = n.floatValue();\r
49                         assertEquals(0.031f, f);\r
50                 } catch (ParseException e) {\r
51                         e.printStackTrace();\r
52                         fail("Parsing failed: " + e.getMessage());\r
53                 }\r
54 \r
55         }\r
56 }\r