View Javadoc

1   package org.ogf.saga.namespace.base;
2   
3   import java.util.List;
4   
5   import org.junit.After;
6   import org.junit.Before;
7   import org.junit.Test;
8   import org.ogf.saga.namespace.Flags;
9   import org.ogf.saga.namespace.NSDirectory;
10  import org.ogf.saga.namespace.abstracts.AbstractDirectory;
11  import org.ogf.saga.url.URLFactory;
12  
13  /* ***************************************************
14  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
15  * ***             http://cc.in2p3.fr/             ***
16  * ***************************************************
17  * File:   AbstractNSDirectoryTest
18  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
19  * Date:   2 juil. 2007
20  * ***************************************************
21  * Description:                                      */
22  /**
23   *
24   */
25  public abstract class DirectoryBaseTest extends AbstractDirectory {
26  
27      public DirectoryBaseTest(String protocol) throws Exception {
28          super(protocol);
29      }
30  
31      @Test
32      public void test_changeDir() throws Exception {
33          m_subDir.changeDir(URLFactory.createURL(".."));
34          assertEquals(
35                  DEFAULT_DIRNAME,
36                  m_subDir.getName().getPath()+"/");
37      }
38  
39      @Test
40      public void test_list() throws Exception {
41          List list = m_subDir.list(DEFAULT_FILEPATTERN, Flags.NONE.getValue());
42          assertEquals(
43                  1,
44                  list.size());
45          assertEquals(
46                  DEFAULT_FILENAME,
47                  list.get(0).toString());
48      }
49  
50      @Test
51      public void test_list_empty() throws Exception {
52          m_subDir.remove(DEFAULT_FILENAME);
53          List list = m_subDir.list();
54          assertEquals(
55                  0,
56                  list.size());
57      }
58      
59      @Test
60      public void test_list_file() throws Exception {
61          List list = m_subDir.list(DEFAULT_FILENAME, Flags.NONE.getValue());
62          assertEquals(
63                  1,
64                  list.size());
65          assertEquals(
66                  DEFAULT_FILENAME,
67                  list.get(0).toString());
68      }
69  
70      @Test
71      public void test_list_directories() throws Exception {
72          List list = m_dir.list("*/", Flags.NONE.getValue());
73          assertEquals(
74                  1,
75                  list.size());
76          assertEquals(DEFAULT_SUBDIRNAME,
77                  list.get(0).toString());
78          list = m_subDir.list("*/", Flags.NONE.getValue());
79          assertEquals(
80                  0,
81                  list.size());
82      }
83  
84      @Test
85      public void test_find() throws Exception {
86          List list = m_subDir.find(DEFAULT_FILEPATTERN, Flags.NONE.getValue());
87          assertEquals(
88                  1,
89                  list.size());
90          assertEquals(
91                  DEFAULT_FILENAME,
92                  list.get(0).toString());
93          list = m_dir.find(DEFAULT_FILEPATTERN, Flags.NONE.getValue());
94          assertEquals(
95                  0,
96                  list.size());
97      }
98  
99      @Test
100     public void test_find_recurse() throws Exception {
101         List list = m_dir.find(DEFAULT_FILEPATTERN, Flags.RECURSIVE.getValue());
102         assertEquals(
103                 1,
104                 list.size());
105         assertEquals(
106                 DEFAULT_SUBDIRNAME +DEFAULT_FILENAME,
107                 list.get(0).toString());
108     }
109 
110     @Test
111     public void test_getNumEntries() throws Exception {
112     	assertEquals(
113                 1,
114                 m_subDir.getNumEntries());
115     }
116 
117     @Test
118     public void test_getEntry() throws Exception {
119     	assertEquals(
120                 DEFAULT_FILENAME,
121                 m_subDir.getEntry(0).toString());
122     }
123 
124     /////////////////////////////////// overloaded methods ///////////////////////////////////
125 
126     @Test
127     public void test_isDir() throws Exception {
128     	assertTrue(m_subDir.isDir());
129     }
130 
131     @Test
132     public void test_isEntry() throws Exception {
133     	assertFalse(m_subDir.isEntry());
134     }
135 }