1 package fr.in2p3.jsaga.impl.job;
2
3 import fr.in2p3.jsaga.adaptor.WaitForEverAdaptorAbstract;
4 import org.ogf.saga.AbstractTest;
5 import org.ogf.saga.error.TimeoutException;
6 import org.ogf.saga.job.*;
7 import org.ogf.saga.session.Session;
8 import org.ogf.saga.session.SessionFactory;
9 import org.ogf.saga.url.URL;
10 import org.ogf.saga.url.URLFactory;
11
12
13
14
15
16
17
18
19
20
21
22
23
24 public class TimeoutableJobFactoryImplTest extends AbstractTest {
25 private static final String m_url = "waitforever://host";
26
27 public TimeoutableJobFactoryImplTest() throws Exception {
28 super();
29 }
30
31 public void test_createJobService() throws Exception {
32 Session emptySession = SessionFactory.createSession(false);
33 URL url = URLFactory.createURL(m_url+"?hangatconnect");
34 try {
35 JobFactoryImpl.createJobService(emptySession, url);
36 fail("Expected exception: "+ TimeoutException.class);
37 } catch (TimeoutException e) {
38 assertTrue("Should be hanged", WaitForEverAdaptorAbstract.isHanging());
39 }
40 }
41
42 public void test_run() throws Exception {
43 Session emptySession = SessionFactory.createSession(false);
44 URL url = URLFactory.createURL(m_url);
45 JobService service = JobFactory.createJobService(emptySession, url);
46 JobDescription description = JobFactory.createJobDescription();
47 description.setAttribute(JobDescription.EXECUTABLE, "hangatconnect");
48 Job job = service.createJob(description);
49 try {
50 job.run();
51 fail("Expected exception: "+ TimeoutException.class);
52 } catch (TimeoutException e) {
53 assertTrue("Should be hanged", WaitForEverAdaptorAbstract.isHanging());
54 }
55 }
56 }