### Question:
ContinuumBuildAgentDavResourceFactory implements DavResourceFactory { public DavResource createResource( final DavResourceLocator locator, final DavSession davSession ) throws DavException { ContinuumBuildAgentDavResourceLocator continuumLocator = checkLocatorIsInstanceOfContinuumBuildAgentLocator( locator ); String logicalResource = WorkingCopyPathUtil.getLogicalResource( locator.getResourcePath() ); if ( logicalResource.startsWith( "/" ) ) { logicalResource = logicalResource.substring( 1 ); } File resourceFile = getResourceFile( continuumLocator.getProjectId(), logicalResource ); if ( !resourceFile.exists() || ( continuumLocator.getHref( false ).endsWith( "/" ) && !resourceFile.isDirectory() ) ) { log.error( "Resource file '" + resourceFile.getAbsolutePath() + "' does not exist" ); throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" ); } else { return createResource( resourceFile, logicalResource, davSession, continuumLocator ); } }  DavResource createResource( final DavResourceLocator locator, final DavSession davSession ); DavResource createResource( DavResourceLocator locator, DavServletRequest request,
                                       DavServletResponse response ); BuildAgentConfigurationService getBuildAgentConfigurationService(); MimetypesFileTypeMap getMimeTypes(); void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService );  }### Answer:
@Test public void testRequestArtifact() throws Exception { DavResourceLocator locator = new ContinuumBuildAgentDavResourceLocator( "http: "/workingcopy/1/target/continuum-artifact-1.0.jar", new ContinuumBuildAgentDavLocatorFactory(), 1 ); try { when( request.getMethod() ).thenReturn( "GET" ); when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( getWorkingDirectory( 1 ) ); when( request.getDavSession() ).thenReturn( new ContinuumBuildAgentDavSession() ); DavResource resource = resourceFactory.createResource( locator, request, response ); assertNotNull( resource ); assertEquals( locator.getRepositoryPath(), locator.getRepositoryPath() ); } catch ( DavException e ) { fail( "A DavException should not have been thrown!" ); } }
@Test public void testRequestArtifactDoesNotExist() throws Exception { DavResourceLocator locator = new ContinuumBuildAgentDavResourceLocator( "http: "/workingcopy/1/pom.xml", new ContinuumBuildAgentDavLocatorFactory(), 1 ); try { when( request.getMethod() ).thenReturn( "GET" ); when( buildAgentConfigurationService.getWorkingDirectory( 1 ) ).thenReturn( getWorkingDirectory( 1 ) ); resourceFactory.createResource( locator, request, response ); fail( "A DavException with 404 error code should have been thrown." ); } catch ( DavException e ) { assertEquals( 404, e.getErrorCode() ); } }