/* Copyright (c) 2009 Peter Troshin * * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache * License for more details. * * A copy of the license is in apache_license.txt. It is also available here: * @see: http://www.apache.org/licenses/LICENSE-2.0.txt * * Any republication or derived work distributed in source code form * must include this copyright and license notice. */ package compbio.runner._impl; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.fail; import java.text.ParseException; import org.ggf.drmaa.DrmaaException; import org.ggf.drmaa.JobInfo; import org.testng.annotations.Test; import compbio.engine.cluster.drmaa.ClusterUtil; import compbio.engine.cluster.drmaa.JobRunner; import compbio.engine.cluster.drmaa.StatisticManager; import compbio.metadata.AllTestSuit; import compbio.metadata.JobExecutionException; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; /** * TODO this needs fixing! Executable does not work * * @author pvtroshin * */ public class OBTester { public static String test_input = "/homes/pvtroshin/TO1381.fasta"; public static String test_outfile = "/homes/pvtroshin/TO1381.OB.out"; @Test public void testGetTestCommand() { System.out.println(OB.getTestCommand()); } @Test public void testGetTestArgsCommand() { System.out.println(new OB().getTestArgs()); } @Test(enabled = false, groups = { AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner }) public void testBuildCommand() { OB ob = new OB(AllTestSuit.OUTPUT_DIR_ABSOLUTE); // TODO ob.setInput(test_input).setOutput(test_outfile); // ob.setParameters(ob.getTestArgs()); try { JobRunner runner = JobRunner.getInstance(null); assertNotNull("Runner is NULL", runner); runner.executeJob(); // assertNotNull("Job id is null", jobId1); JobStatus status = runner.getJobStatus(); assertTrue("Status is not queing but " + status, status == JobStatus.PENDING || status == JobStatus.RUNNING); JobInfo info = runner.getJobInfo(); assertNotNull("JobInfo is null", info); StatisticManager sm = new StatisticManager(info); assertNotNull("Stat manager is null", sm); try { String time_s = sm.getCalculationTime(); assertNotNull("Time is null", time_s); float time = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(time_s) .floatValue(); String exits = sm.getExitStatus(); assertNotNull("Exit status is null", exits); int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) .intValue(); assertEquals("Exit status is not 0", 0, exitsInt); System.out.println(sm.getAllStats()); } catch (ParseException e) { e.printStackTrace(); fail("Parse Exception: " + e.getLocalizedMessage()); } assertTrue("Process exited:", sm.hasExited()); assertFalse("Process aborted:", sm.wasAborted()); assertFalse("Process hasdump:", sm.hasDump()); assertFalse("Process signaled:", sm.hasSignaled()); } catch (DrmaaException e) { e.printStackTrace(); fail("Drmaa exception: " + e.getLocalizedMessage()); } catch (JobSubmissionException e) { e.printStackTrace(); fail("JobSubmission failure: " + e.getLocalizedMessage()); } catch (JobExecutionException e) { e.printStackTrace(); fail("JobSubmission failure: " + e.getLocalizedMessage()); } } }