View Javadoc

1   package org.ogf.saga.resource;
2   
3   import org.junit.Test;
4   import org.ogf.saga.error.AuthenticationFailedException;
5   import org.ogf.saga.error.AuthorizationFailedException;
6   import org.ogf.saga.error.BadParameterException;
7   import org.ogf.saga.error.NoSuccessException;
8   import org.ogf.saga.error.NotImplementedException;
9   import org.ogf.saga.error.TimeoutException;
10  import org.ogf.saga.namespace.Flags;
11  import org.ogf.saga.namespace.NSDirectory;
12  import org.ogf.saga.namespace.NSFactory;
13  import org.ogf.saga.resource.description.ResourceDescription;
14  import org.ogf.saga.resource.description.StorageDescription;
15  import org.ogf.saga.resource.instance.Resource;
16  import org.ogf.saga.resource.instance.Storage;
17  import org.ogf.saga.url.URL;
18  import org.ogf.saga.url.URLFactory;
19  
20  public abstract class StorageTest extends ResourceBaseTest {
21  
22      public StorageTest(String resourceprotocol) throws Exception {
23          super(resourceprotocol, Type.STORAGE);
24      }
25      
26      @Override
27      protected Resource acquire(ResourceDescription rd) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, BadParameterException, TimeoutException, NoSuccessException {
28          return m_rm.acquireStorage((StorageDescription) rd);
29      }
30  
31      //////////////////
32      // acquire storage
33      //////////////////
34      @Test 
35      public void createWithSize() throws Exception {
36          StorageDescription nd = (StorageDescription) ResourceFactory.createResourceDescription(m_type);
37          nd.setAttribute(StorageDescription.SIZE, Integer.toString(1024*1024));
38          m_currentResource = (Storage) this.acquireResourceFromDescReadyForUse(nd);
39          assertEquals(Integer.toString(1024*1024), 
40                  ((StorageDescription)m_currentResource.getDescription()).getAttribute(StorageDescription.SIZE));
41      }
42      
43      @Test
44      public void createAndMkdirAndDeleteStorageArea() throws Exception {
45          m_currentResource = (Storage) this.acquireResourceReadyForUse();
46          URL baseUrl = URLFactory.createURL(m_currentResource.getAccess()[0]);
47          URL m_dirUrl = createURL(baseUrl, "dir/");
48          NSDirectory m_dir = NSFactory.createNSDirectory(m_session, m_dirUrl, Flags.CREATE.or(Flags.EXCL));
49          m_dir.close();
50      }
51  }