1 package org.ogf.saga.namespace;
2
3 import org.junit.After;
4 import org.junit.Assert;
5 import org.junit.Before;
6 import org.junit.Test;
7 import org.ogf.saga.namespace.abstracts.AbstractData;
8 import org.ogf.saga.url.URL;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public abstract class LinkTest extends AbstractData {
23
24 private static final String DEFAULT_LINKNAME = "link.txt";
25 private static final String DEFAULT_LINKNAME_2 = "link2.txt";
26
27
28 private URL m_linkUrl;
29 private URL m_linkUrl2;
30
31
32 private NSEntry m_link;
33
34 protected LinkTest(String protocol) throws Exception {
35 super(protocol);
36 m_linkUrl = createURL(m_dirUrl, DEFAULT_LINKNAME);
37 m_linkUrl2 = createURL(m_dirUrl, DEFAULT_LINKNAME_2);
38 }
39
40 @Before
41 public void setUp() throws Exception {
42 super.setUp();
43 m_file.link(m_linkUrl, Flags.NONE.getValue());
44 m_link = NSFactory.createNSEntry(m_session, m_linkUrl, Flags.NONE.getValue());
45 }
46
47 @After
48 public void tearDown() throws Exception {
49 m_link.close();
50 super.tearDown();
51 }
52
53
54 @Test
55 public void test_isLink() throws Exception {
56 Assert.assertFalse(m_file.isLink());
57 Assert.assertTrue(m_link.isLink());
58 }
59
60 @Test
61 public void test_readLink() throws Exception {
62 Assert.assertEquals(
63 m_fileUrl.toString(),
64 m_link.readLink().toString());
65 }
66
67 @Test
68 public void test_link() throws Exception {
69 m_link.link(m_linkUrl2, Flags.NONE.getValue());
70 NSEntry link2 = NSFactory.createNSEntry(m_session, m_linkUrl2, Flags.NONE.getValue());
71 Assert.assertEquals(
72 m_linkUrl.toString(),
73 link2.readLink().toString());
74 link2.remove();
75 link2.close();
76 }
77
78 @Test
79 public void test_link_dereferenced() throws Exception {
80 m_link.link(m_linkUrl2, Flags.DEREFERENCE.getValue());
81 NSEntry link2 = NSFactory.createNSEntry(m_session, m_linkUrl2, Flags.NONE.getValue());
82 Assert.assertEquals(
83 m_fileUrl.toString(),
84 link2.readLink().toString());
85 link2.remove();
86 link2.close();
87 }
88 }