1 package fr.in2p3.jsaga.impl.file;
2
3 import fr.in2p3.jsaga.adaptor.WaitForEverAdaptorAbstract;
4 import org.ogf.saga.AbstractTest;
5 import org.ogf.saga.buffer.BufferFactory;
6 import org.ogf.saga.error.TimeoutException;
7 import org.ogf.saga.file.File;
8 import org.ogf.saga.file.FileFactory;
9 import org.ogf.saga.namespace.Flags;
10 import org.ogf.saga.session.Session;
11 import org.ogf.saga.session.SessionFactory;
12 import org.ogf.saga.url.URL;
13 import org.ogf.saga.url.URLFactory;
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class TimeoutableFileImplTest extends AbstractTest {
28 private static final String m_url = "waitforever://host/directory/file";
29 private File m_readfile, m_writefile;
30
31 public TimeoutableFileImplTest() throws Exception {
32 super();
33 }
34
35 public void setUp() throws Exception {
36 Session emptySession = SessionFactory.createSession(false);
37 URL url = URLFactory.createURL(m_url);
38 m_readfile = FileFactory.createFile(emptySession, url, Flags.READ.getValue());
39 m_writefile = FileFactory.createFile(emptySession, url, Flags.WRITE.getValue());
40 }
41
42 public void tearDown() throws Exception {
43 m_readfile.close();
44 }
45
46 public void test_getSize() throws Exception {
47 try {
48 m_readfile.getSize();
49 fail("Expected exception: "+ TimeoutException.class);
50 } catch (TimeoutException e) {
51 assertTrue("Should be hanged", WaitForEverAdaptorAbstract.isHanging());
52 }
53 }
54
55 public void test_read() throws Exception {
56 try {
57 m_readfile.read(BufferFactory.createBuffer(1024));
58 fail("Expected exception: "+ TimeoutException.class);
59 } catch (TimeoutException e) {
60 assertTrue("Should be hanged", WaitForEverAdaptorAbstract.isHanging());
61 }
62 }
63
64 public void test_write() throws Exception {
65 try {
66 m_writefile.write(BufferFactory.createBuffer(1024));
67 fail("Expected exception: "+ TimeoutException.class);
68 } catch (TimeoutException e) {
69 assertTrue("Should be hanged", WaitForEverAdaptorAbstract.isHanging());
70 }
71 }
72 }