import au.org.aodn.reefscenarios.actions.job.ProcessRunner;
import au.org.aodn.reefscenarios.actions.job.ProcessRunnerException;
import au.org.aodn.reefscenarios.entities.Job;
import au.org.aodn.reefscenarios.entities.User;
import org.junit.Assert;
import org.junit.Test;
import javax.validation.constraints.AssertTrue;
/**
* Created by IntelliJ IDEA.
* User: pmak
* Date: Aug 27, 2010
* Time: 12:22:59 PM
* To change this template use File | Settings | File Templates.
*/
public class ProcessRunnerTester
{
@Test
public void TestExecutePretendScript()
{
System.out.println("Running TestExecutePretendScript()");
try
{
ProcessRunner runner = new ProcessRunner();
Job j = new Job();
j.setJobName("blah");
j.setJobPath(System.getProperty("user.dir") + "/src/test");
System.out.println("job path: " + j.createRunPath());
User user = new User();
user.setEmailAddress("pauline.mak@utas.edu.au");
j.setUserId(user.getUserId());
runner.submitJob(j);
System.out.println("new PBS job name: " + j.getPBSJobName());
Assert.assertEquals(j.getPBSJobName(), "62586");
}
catch(Exception e)
{
System.out.println("This should NEVER HAPPEN!");
e.printStackTrace();
Assert.assertTrue(false);
}
}
@Test(expected = ProcessRunnerException.class)
public void TestNonExistantScript() throws Exception
{
System.out.println("Running TestNonExistantScript()");
ProcessRunner runner = new ProcessRunner();
Job j = new Job();
j.setJobName("blah");
//There should be NO submit.sh script at this directory ($PROJECT/trunk)
j.setJobPath("/SomeStupidDirectory");
User user = new User();
user.setEmailAddress("pauline.mak@utas.edu.au");
j.setUserId(user.getUserId());
runner.submitJob(j);
}
}