Add testing dirs
[proteocache.git] / testsrc / compbio / metadata / OptionCombinatorTester.java
diff --git a/testsrc/compbio/metadata/OptionCombinatorTester.java b/testsrc/compbio/metadata/OptionCombinatorTester.java
new file mode 100644 (file)
index 0000000..6a85aeb
--- /dev/null
@@ -0,0 +1,102 @@
+/* Copyright (c) 2009 Peter Troshin\r
+ *  \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
+ * \r
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
+ *  Apache License version 2 as published by the Apache Software Foundation\r
+ * \r
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
+ */\r
+\r
+package compbio.metadata;\r
+\r
+import static org.testng.Assert.fail;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+\r
+import javax.xml.bind.JAXBException;\r
+\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.engine.conf.RunnerConfigMarshaller;\r
+import compbio.metadata.RunnerConfig;\r
+import compbio.runner.OptionCombinator;\r
+import compbio.runner.msa.ClustalW;\r
+import compbio.runner.msa.Mafft;\r
+import compbio.runner.msa.Muscle;\r
+\r
+public class OptionCombinatorTester {\r
+\r
+       static final String mafftConfigFile = AllTestSuit.TEST_DATA_PATH\r
+                       + "MafftParameters.xml";\r
+\r
+       static final String muscleConfigFile = AllTestSuit.TEST_DATA_PATH\r
+                       + "MuscleParameters.xml";\r
+\r
+       static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH\r
+                       + "ClustalParameters.xml";\r
+\r
+       RunnerConfig<Mafft> mafftConfig = null;\r
+       RunnerConfig<Mafft> muscleConfig = null;\r
+       RunnerConfig<Mafft> clustalConfig = null;\r
+\r
+       @BeforeMethod\r
+       @SuppressWarnings("unchecked")\r
+       void setup() {\r
+               try {\r
+                       RunnerConfigMarshaller<Mafft> mf = new RunnerConfigMarshaller<Mafft>(\r
+                                       RunnerConfig.class);\r
+                       mafftConfig = mf.read(\r
+                                       new FileInputStream(new File(mafftConfigFile)),\r
+                                       RunnerConfig.class);\r
+                       RunnerConfigMarshaller<Muscle> musclemarsh = new RunnerConfigMarshaller<Muscle>(\r
+                                       RunnerConfig.class);\r
+                       muscleConfig = musclemarsh.read(new FileInputStream(new File(\r
+                                       muscleConfigFile)), RunnerConfig.class);\r
+\r
+                       RunnerConfigMarshaller<ClustalW> clustalmarsh = new RunnerConfigMarshaller<ClustalW>(\r
+                                       RunnerConfig.class);\r
+                       clustalConfig = clustalmarsh.read(new FileInputStream(new File(\r
+                                       clustalConfigFile)), RunnerConfig.class);\r
+\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (JAXBException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
+       }\r
+\r
+       @Test\r
+       public void testgetAllOptions() {\r
+               OptionCombinator opc = new OptionCombinator(mafftConfig);\r
+               System.out.println(opc.getOptionsAtRandom());\r
+               OptionCombinator muscleOpc = new OptionCombinator(muscleConfig);\r
+               System.out.println("Mucle " + muscleOpc.getOptionsAtRandom());\r
+               OptionCombinator clustalOpc = new OptionCombinator(clustalConfig);\r
+               System.out.println("Clustal " + clustalOpc.getOptionsAtRandom());\r
+\r
+       }\r
+\r
+       @Test\r
+       public void testgetAllParameters() {\r
+               OptionCombinator opc = new OptionCombinator(mafftConfig);\r
+               System.out.println(opc.getAllParameters());\r
+               OptionCombinator muscleOpc = new OptionCombinator(muscleConfig);\r
+               System.out.println("Muscle : " + muscleOpc.getAllParameters());\r
+               OptionCombinator clustalOpc = new OptionCombinator(clustalConfig);\r
+               System.out.println("Clustal : " + clustalOpc.getAllParameters());\r
+       }\r
+}\r