View Javadoc

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  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
12  * ***             http://cc.in2p3.fr/             ***
13  * ***************************************************
14  * File:   NSLinkTest
15  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
16  * Date:   2 juil. 2007
17  * ***************************************************
18  * Description:                                      */
19  /**
20   *
21   */
22  public abstract class LinkTest extends AbstractData {
23      // test data
24      private static final String DEFAULT_LINKNAME = "link.txt";
25      private static final String DEFAULT_LINKNAME_2 = "link2.txt";
26  
27      // configuration
28      private URL m_linkUrl;
29      private URL m_linkUrl2;
30  
31      // setup
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      /////////////////////////////////// file link tests ///////////////////////////////////
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  }