+++ /dev/null
-/* 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.runner.msa;\r
-\r
-import static org.testng.Assert.assertEquals;\r
-import static org.testng.Assert.assertNotNull;\r
-import static org.testng.Assert.assertNull;\r
-import static org.testng.Assert.assertTrue;\r
-import static org.testng.Assert.fail;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-\r
-import javax.xml.bind.ValidationException;\r
-\r
-import org.testng.annotations.BeforeMethod;\r
-import org.testng.annotations.Test;\r
-\r
-import compbio.engine.AsyncExecutor;\r
-import compbio.engine.Configurator;\r
-import compbio.engine.FilePuller;\r
-import compbio.engine.SyncExecutor;\r
-import compbio.engine.client.ConfExecutable;\r
-import compbio.engine.client.ConfiguredExecutable;\r
-import compbio.engine.client.Executable;\r
-import compbio.engine.client.RunConfiguration;\r
-import compbio.engine.cluster.drmaa.ClusterRunner;\r
-import compbio.metadata.AllTestSuit;\r
-import compbio.metadata.ChunkHolder;\r
-import compbio.metadata.JobExecutionException;\r
-import compbio.metadata.JobSubmissionException;\r
-import compbio.metadata.LimitsManager;\r
-import compbio.metadata.PresetManager;\r
-import compbio.metadata.ResultNotAvailableException;\r
-import compbio.metadata.RunnerConfig;\r
-\r
-public class ProbconsTester {\r
-\r
- private Probcons probc;\r
-\r
- @BeforeMethod(groups = { AllTestSuit.test_group_cluster,\r
- AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\r
- public void init() {\r
- probc = new Probcons();\r
- probc.setInput(AllTestSuit.test_input); // .setOutput("Mafft.out").setError("mafft.progress");\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testSetInputTester() {\r
- Probcons mf = new Probcons();\r
- // System.out.println(mf.getParameters(null));\r
- mf.setInput("INNN");\r
- // System.out.println(mf.getParameters(null));\r
- mf.setError("ERRR");\r
- mf.setInput("INN222");\r
- mf.setOutput("OUT");\r
- // System.out.println(mf.getParameters(null));\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testExecute() {\r
- try {\r
- ConfiguredExecutable<Probcons> cmafft = Configurator\r
- .configureExecutable(probc, Executable.ExecProvider.Local);\r
- // option for sub matrix is not supported\r
- // cmafft.getParameters().setParam("--matrixfile", "PAM200");\r
- SyncExecutor sexecutor = Configurator.getSyncEngine(cmafft);\r
- sexecutor.executeJob();\r
- cmafft = (ConfiguredExecutable<Probcons>) sexecutor.waitForResult();\r
- assertNotNull(cmafft.getResults());\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void testPersistance() {\r
- try {\r
- Probcons mafft = new Probcons();\r
- mafft.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
- .setOutput("outtt.txt");\r
- assertEquals(mafft.getInput(), AllTestSuit.test_input);\r
- assertEquals(mafft.getError(), "errrr.txt");\r
- assertEquals(mafft.getOutput(), "outtt.txt");\r
- ConfiguredExecutable<Probcons> cmafft = Configurator\r
- .configureExecutable(mafft, Executable.ExecProvider.Local);\r
-\r
- SyncExecutor sexec = Configurator.getSyncEngine(cmafft);\r
- sexec.executeJob();\r
- ConfiguredExecutable<?> al = sexec.waitForResult();\r
- assertNotNull(al.getResults());\r
- // Save run configuration\r
- assertTrue(cmafft.saveRunConfiguration());\r
-\r
- // See if loaded configuration is the same as saved\r
- RunConfiguration loadedRun = RunConfiguration\r
- .load(new FileInputStream(new File(cmafft\r
- .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
- assertEquals(((ConfExecutable<Probcons>) cmafft)\r
- .getRunConfiguration(), loadedRun);\r
- // Load run configuration as ConfExecutable\r
- ConfiguredExecutable<Probcons> resurrectedCMafft = (ConfiguredExecutable<Probcons>) cmafft\r
- .loadRunConfiguration(new FileInputStream(new File(cmafft\r
- .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
- assertNotNull(resurrectedCMafft);\r
- // See in details whether executables are the same\r
- assertEquals(resurrectedCMafft.getExecutable(), mafft);\r
-\r
- // Finally rerun the job in the new task directory\r
- ConfiguredExecutable<Probcons> resmafft = Configurator\r
- .configureExecutable(resurrectedCMafft.getExecutable(),\r
- Executable.ExecProvider.Local);\r
-\r
- sexec = Configurator.getSyncEngine(resmafft,\r
- Executable.ExecProvider.Local);\r
- sexec.executeJob();\r
- al = sexec.waitForResult();\r
- assertNotNull(al);\r
-\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_cluster,\r
- AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\r
- public void testClusterExecute() {\r
- try {\r
- ConfiguredExecutable<Probcons> cmafft = Configurator\r
- .configureExecutable(probc, Executable.ExecProvider.Cluster);\r
- ClusterRunner sexecutor = (ClusterRunner) Configurator.getSyncEngine(\r
- cmafft, Executable.ExecProvider.Cluster);\r
- sexecutor.executeJob();\r
- ConfiguredExecutable<?> al = sexecutor.waitForResult();\r
- assertNotNull(al.getResults());\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner,\r
- AllTestSuit.test_group_non_windows })\r
- public void readStatistics() {\r
- Probcons probs = new Probcons();\r
- probs.setError("errrr.txt").setInput(AllTestSuit.test_input).setOutput(\r
- "outtt.txt");\r
- ConfiguredExecutable<Probcons> cprobs;\r
-\r
- try {\r
- cprobs = Configurator.configureExecutable(probs,\r
- Executable.ExecProvider.Local);\r
- AsyncExecutor sexec = Configurator.getAsyncEngine(cprobs);\r
- String jobId = sexec.submitJob(cprobs);\r
- FilePuller fw = FilePuller.newFilePuller(compbio.engine.client.EngineUtil\r
- .getFullPath(cprobs.getWorkDirectory(), cprobs.getError()),\r
- 256);\r
- ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
- assertNotNull(al.getResults());\r
- // Code below is performance dependent \r
- // thus cannot be moved up before the results is obtained\r
- int count = 0;\r
- long position = 0;\r
- fw.waitForFile(6);\r
- while (fw.hasMoreData()) {\r
- ChunkHolder ch = fw.pull(position);\r
- String chunk = ch.getChunk();\r
- position = ch.getNextPosition();\r
- System.out.print("CHUNK:" + chunk);\r
- count++;\r
- }\r
- assertTrue(count > 1, "TaskId:" + jobId);\r
-\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
- }\r
-\r
- @Test(groups = { AllTestSuit.test_group_runner })\r
- public void testConfigurationLoading() {\r
- try {\r
- RunnerConfig<Probcons> probsConfig = ConfExecutable\r
- .getRunnerOptions(Probcons.class);\r
- assertNotNull(probsConfig);\r
- assertTrue(probsConfig.getArguments().size() > 0);\r
-\r
- PresetManager<Probcons> probsPresets = ConfExecutable\r
- .getRunnerPresets(Probcons.class);\r
- assertNull(probsPresets);\r
-\r
- LimitsManager<Probcons> probsLimits = ConfExecutable\r
- .getRunnerLimits(Probcons.class);\r
- assertNotNull(probsLimits);\r
- assertTrue(probsLimits.getLimits().size() > 0);\r
- probsLimits.validate(probsPresets);\r
-\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (ValidationException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
- }\r
-}\r