continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r965682 - in /continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src: main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java
Date Mon, 19 Jul 2010 23:49:18 GMT
Author: ctan
Date: Mon Jul 19 23:49:18 2010
New Revision: 965682

URL: http://svn.apache.org/viewvc?rev=965682&view=rev
Log:
[CONTINUUM-2545] forgot to add unit test for ContinuumBuildAgentDavResource

Added:
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java
Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java?rev=965682&r1=965681&r2=965682&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/main/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResource.java
Mon Jul 19 23:49:18 2010
@@ -98,7 +98,7 @@ public class ContinuumBuildAgentDavResou
     {
     }
 
-    public void addMember( DavResource davResource, InputContext arg1 )
+    public void addMember( DavResource davResource, InputContext inputContext )
         throws DavException
     {
         throw new UnsupportedOperationException( "Not supported" );

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java?rev=965682&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java
(added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-webdav/src/test/java/org/apache/continuum/webdav/ContinuumBuildAgentDavResourceTest.java
Mon Jul 19 23:49:18 2010
@@ -0,0 +1,147 @@
+package org.apache.continuum.webdav;
+
+import java.io.File;
+
+import javax.activation.MimetypesFileTypeMap;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavResourceFactory;
+import org.apache.jackrabbit.webdav.DavResourceLocator;
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+public class ContinuumBuildAgentDavResourceTest
+    extends PlexusInSpringTestCase
+{
+    private DavSession session;
+
+    private DavResourceFactory resourceFactory;
+
+    private ContinuumBuildAgentDavResourceLocator resourceLocator;
+
+    private DavResource resource;
+
+    private MimetypesFileTypeMap mimeTypes;
+
+    private File baseDir;
+
+    private File resourceFile;
+
+    private final String RESOURCE_FILE = "resource.jar";
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        session = new ContinuumBuildAgentDavSession();
+
+        mimeTypes = new MimetypesFileTypeMap();
+        mimeTypes.addMimeTypes( "application/java-archive jar war ear" );
+        mimeTypes.addMimeTypes( "application/java-class class" );
+        mimeTypes.addMimeTypes( "image/png png" );
+
+        baseDir = getTestFile( "target/DavResourceTest" );
+        baseDir.mkdirs();
+        resourceFile = new File( baseDir, RESOURCE_FILE );
+        resourceFile.createNewFile();
+
+        resourceFactory = new RootContextDavResourceFactory();
+        resourceLocator = (ContinuumBuildAgentDavResourceLocator) new ContinuumBuildAgentDavLocatorFactory().
+                                createResourceLocator( "/", RESOURCE_FILE );
+        resource = getDavResource( resourceLocator.getHref( false ), resourceFile );
+    }
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        if ( baseDir.exists() )
+        {
+            FileUtils.deleteDirectory( baseDir );
+        }
+
+        super.tearDown();
+    }
+
+    public void testAddResource()
+        throws Exception
+    {
+        File newResource = new File( baseDir, "newResource.jar" );
+        assertFalse( newResource.exists() );
+        try
+        {
+            resource.getCollection().addMember( resource, null );
+            fail( "Should have thrown an UnsupportedOperationException" );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+            assertFalse( newResource.exists() );
+        }
+    }
+
+    public void testDeleteCollection()
+        throws Exception
+    {
+        File dir = new File( baseDir, "testdir" );
+        try
+        {
+            assertTrue( dir.mkdir() );
+            DavResource directoryResource = getDavResource( "/testdir", dir );
+            directoryResource.getCollection().removeMember( directoryResource );
+            fail( "Should have thrown an UnsupportedOperationException" );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+            assertTrue( dir.exists() );
+        }
+        finally
+        {
+            FileUtils.deleteDirectory( dir );
+        }
+    }
+
+    public void testDeleteResource()
+        throws Exception
+    {
+        assertTrue( resourceFile.exists() );
+        try
+        {
+            resource.getCollection().removeMember( resource );
+            fail( "Should have thrown an UnsupportedOperationException" );
+        }
+        catch ( UnsupportedOperationException e )
+        {
+            assertTrue( resourceFile.exists() );
+        }
+    }
+
+    private DavResource getDavResource( String logicalPath, File file )
+    {
+        return new ContinuumBuildAgentDavResource( file.getAbsolutePath(), logicalPath, session,
resourceLocator,
+                                                   resourceFactory, mimeTypes );
+    }
+
+    private class RootContextDavResourceFactory
+        implements DavResourceFactory
+    {
+        public DavResource createResource( DavResourceLocator locator, DavServletRequest
request,
+                                           DavServletResponse response )
+            throws DavException
+        {
+            throw new UnsupportedOperationException( "Not supported yet." );
+        }
+    
+        public DavResource createResource( DavResourceLocator locator, DavSession session
)
+            throws DavException
+        {
+            return new ContinuumBuildAgentDavResource( baseDir.getAbsolutePath(), "/", session,
resourceLocator,
+                                                       resourceFactory, mimeTypes );
+        }
+    }
+}



Mime
View raw message