unico       2004/06/29 09:10:55

  Modified:    src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
               src/blocks/webdav/test/org/apache/cocoon/components/source/impl
                        WebDAVSourceTestCase.java
  Log:
  fix bug in makeCollection and make getParent independent of child existence
  
  Revision  Changes    Path
  1.30      +8 -3      
cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
  
  Index: WebDAVSource.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- WebDAVSource.java 28 Jun 2004 10:10:04 -0000      1.29
  +++ WebDAVSource.java 29 Jun 2004 16:10:55 -0000      1.30
  @@ -602,8 +602,13 @@
        * @see org.apache.excalibur.source.TraversableSource#getParent()
        */
       public Source getParent() throws SourceException {
  -        initResource(WebdavResource.BASIC, DepthSupport.DEPTH_0);
  -        String path = this.resource.isCollection()?"..":".";
  +        String path;
  +        if (this.url.getEscapedPath().endsWith("/")) {
  +            path = "..";
  +        }
  +        else {
  +            path = ".";
  +        }
           try {
               HttpURL parentURL;
               if (url instanceof HttpsURL) {
  
  
  
  1.4       +34 -18    
cocoon-2.1/src/blocks/webdav/test/org/apache/cocoon/components/source/impl/WebDAVSourceTestCase.java
  
  Index: WebDAVSourceTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/webdav/test/org/apache/cocoon/components/source/impl/WebDAVSourceTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WebDAVSourceTestCase.java 27 Mar 2004 17:40:11 -0000      1.3
  +++ WebDAVSourceTestCase.java 29 Jun 2004 16:10:55 -0000      1.4
  @@ -21,6 +21,7 @@
   
   import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
   import org.apache.cocoon.components.source.impl.WebDAVSource;
  +import org.apache.commons.httpclient.HttpURL;
   import org.apache.excalibur.source.ModifiableTraversableSource;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.TraversableSource;
  @@ -36,10 +37,9 @@
       private String m_authority = "localhost:8888";
       private String m_path = "/webdav/";
       private String m_name = "files";
  -    private String m_qs = "?foo=bar";
  -    private String m_location = m_scheme + "://" + m_credentials + "@" + 
m_authority + m_path + m_name + m_qs;
  -    private String m_secure = m_scheme + "://" + m_authority + m_path + 
m_name + m_qs;
  -    private String m_options = "&cocoon:webdav-action=" + 
WebdavResource.NOACTION + "&cocoon:webdav-depth=0";
  +    private String m_location = m_scheme + "://" + m_credentials + "@" + 
m_authority + m_path + m_name;
  +    private String m_secure = m_scheme + "://" + m_authority + m_path + 
m_name;
  +    private String m_options = "?cocoon:webdav-action=" + 
WebdavResource.NOACTION + "&cocoon:webdav-depth=0";
       
       
       public WebDAVSourceTestCase(String name) {
  @@ -73,26 +73,22 @@
   //            assertTrue(parent.isCollection());
   //            resolver.release(child);
   //        }
  +//
  +//        TraversableSource child = (TraversableSource) 
source.getChild("childcollection");
  +//        assertEquals(child.getURI(), m_location + "/childcollection");
  +//
  +//        TraversableSource parent = (TraversableSource) child.getParent();
  +//        assertEquals(m_name, parent.getName());
  +//        
   //        resolver.release(source);
       }
   
       public void testModification() throws Exception {
   //        SourceResolver resolver = (SourceResolver) 
lookup(SourceResolver.ROLE);
   //        String uri = m_location + m_options;
  -//        ModifiableTraversableSource source = (ModifiableTraversableSource) 
resolver.resolveURI(uri);
  -//        ModifiableTraversableSource child = (ModifiableTraversableSource) 
source.getChild("newcol");
  -//        
  -//        assertTrue(!child.exists());
  -//        child.makeCollection();
  -//        assertTrue(child.exists());
  -//        child.delete();
  -//        assertTrue(!child.exists());
  -//        
  -//        resolver.release(child);
  -//        resolver.release(source);
   //        
  -//        source = (ModifiableTraversableSource) resolver.resolveURI(uri);
  -//        child = (ModifiableTraversableSource) 
source.getChild("newdoc.txt");
  +//        ModifiableTraversableSource source = (ModifiableTraversableSource) 
resolver.resolveURI(uri);
  +//        ModifiableTraversableSource child = (ModifiableTraversableSource) 
source.getChild("newdoc.txt");
   //        assertTrue(!child.exists());
   //        
   //        // create document
  @@ -116,5 +112,25 @@
   //        
   //        resolver.release(source);
   //        resolver.release(child);
  +    }
  +    
  +    public void testMakeCollection() throws Exception {
  +//        SourceResolver resolver = (SourceResolver) 
lookup(SourceResolver.ROLE);
  +//        String uri = m_location + m_options;
  +//        ModifiableTraversableSource source = (ModifiableTraversableSource) 
resolver.resolveURI(uri);
  +//        ModifiableTraversableSource child = (ModifiableTraversableSource) 
source.getChild("child");
  +//        ModifiableTraversableSource descendant = 
(ModifiableTraversableSource) source.getChild("child/decendant");
  +//        
  +//        assertTrue(!child.exists());
  +//        descendant.makeCollection();
  +//        assertTrue(child.exists());
  +//        assertTrue(descendant.exists());
  +//        child.delete();
  +//        assertTrue(!child.exists());
  +//        descendant.refresh();
  +//        assertTrue(!descendant.exists());
  +//        
  +//        resolver.release(child);
  +//        resolver.release(source);
       }
   }
  
  
  

Reply via email to