summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2009-08-27 06:40:37 +0000
committerMaria Odea B. Ching <oching@apache.org>2009-08-27 06:40:37 +0000
commit573472d62a8f713a9afecab788255e865a0784ef (patch)
treeeed65e469e2d2c2df14b8251ab1f718e747f6289
parent9c3facccc759ae93bb80d35762e5ad056f384438 (diff)
downloadarchiva-573472d62a8f713a9afecab788255e865a0784ef.tar.gz
archiva-573472d62a8f713a9afecab788255e865a0784ef.zip
[MRM-1239] Unable to get artifact-level maven-metadata.xml of artifacts that are only three directory levels deep
o added tests o allow three levels for metadata and metadata checksums when checking if repository layout is default git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@808295 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java34
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java3
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java5
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java235
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/resources/maven-metadata.xml2
5 files changed, 248 insertions, 31 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
index 00c7ca112..4f4a85a20 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
@@ -154,8 +154,38 @@ public class RepositoryRequest
return false;
}
- String pathParts[] = StringUtils.splitPreserveAllTokens( requestedPath, '/' );
- return pathParts.length > 3;
+ String pathParts[] = StringUtils.splitPreserveAllTokens( requestedPath, '/' );
+ if( pathParts.length > 3 )
+ {
+ return true;
+ }
+ else if ( pathParts.length == 3 )
+ {
+ // check if artifact-level metadata (ex. eclipse/jdtcore/maven-metadata.xml)
+ if( isMetadata( requestedPath ) )
+ {
+ return true;
+ }
+ else
+ {
+ // check if checksum of artifact-level metadata (ex. eclipse/jdtcore/maven-metadata.xml.sha1)
+ int idx = requestedPath.lastIndexOf( '.' );
+ if ( idx > 0 )
+ {
+ String base = requestedPath.substring( 0, idx );
+ if( isMetadata( base ) && isSupportFile( requestedPath ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
}
/**
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
index ff15aa507..892adaf9d 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
@@ -249,6 +249,9 @@ public class RepositoryRequestTest
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) );
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) );
assertTrue( repoRequest.isDefault( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) );
+ assertTrue( repoRequest.isDefault( "eclipse/jdtcore/maven-metadata.xml" ) );
+ assertTrue( repoRequest.isDefault( "eclipse/jdtcore/maven-metadata.xml.sha1" ) );
+ assertTrue( repoRequest.isDefault( "eclipse/jdtcore/maven-metadata.xml.md5" ) );
assertFalse( repoRequest.isDefault( null ) );
assertFalse( repoRequest.isDefault( "" ) );
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
index 7d912ab35..7ca4de562 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
@@ -1057,4 +1057,9 @@ public class ArchivaDavResourceFactory
{
this.repositoryRequest = repositoryRequest;
}
+
+ public void setConnectors( RepositoryProxyConnectors connectors )
+ {
+ this.connectors = connectors;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
index d96ce80e2..0154d29b4 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactoryTest.java
@@ -20,9 +20,11 @@ package org.apache.maven.archiva.webdav;
*/
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavResourceLocator;
import org.apache.jackrabbit.webdav.DavServletRequest;
@@ -31,6 +33,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.maven.archiva.proxy.DefaultRepositoryProxyConnectors;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.RepositoryContentFactory;
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
@@ -51,6 +54,8 @@ public class ArchivaDavResourceFactoryTest
private static final String LOCAL_MIRROR_REPO = "local-mirror";
+ private static final String LEGACY_REPO = "legacy-repo";
+
private static final String LOCAL_REPO_GROUP = "local";
private OverridingArchivaDavResourceFactory resourceFactory;
@@ -63,6 +68,8 @@ public class ArchivaDavResourceFactoryTest
private RepositoryRequest repoRequest;
+ private MockControl responseControl;
+
private DavServletResponse response;
private MockControl archivaConfigurationControl;
@@ -81,20 +88,24 @@ public class ArchivaDavResourceFactoryTest
super.setUp();
requestControl = MockControl.createControl( DavServletRequest.class );
-
request = (DavServletRequest) requestControl.getMock();
- archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+ responseControl = MockControl.createControl( DavServletResponse.class );
+ response = (DavServletResponse) responseControl.getMock();
+ responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+ archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
config = new Configuration();
- config.addManagedRepository( createManagedRepository(
- RELEASES_REPO,
- new File( getBasedir(), "target/test-classes/releases" ).getPath() ) );
- config.addManagedRepository( createManagedRepository(
- INTERNAL_REPO,
- new File( getBasedir(), "target/test-classes/internal" ).getPath() ) );
+ config.addManagedRepository( createManagedRepository( RELEASES_REPO, new File( getBasedir(),
+ "target/test-classes/" +
+ RELEASES_REPO ).getPath(),
+ "default" ) );
+ config.addManagedRepository( createManagedRepository( INTERNAL_REPO, new File( getBasedir(),
+ "target/test-classes/" +
+ INTERNAL_REPO ).getPath(),
+ "default" ) );
RepositoryGroupConfiguration repoGroupConfig = new RepositoryGroupConfiguration();
repoGroupConfig.setId( LOCAL_REPO_GROUP );
@@ -113,14 +124,16 @@ public class ArchivaDavResourceFactoryTest
resourceFactory.setArchivaConfiguration( archivaConfiguration );
resourceFactory.setRepositoryFactory( repoFactory );
resourceFactory.setRepositoryRequest( repoRequest );
+ resourceFactory.setConnectors( new OverridingRepositoryProxyConnectors() );
}
- private ManagedRepositoryConfiguration createManagedRepository( String id, String location )
+ private ManagedRepositoryConfiguration createManagedRepository( String id, String location, String layout )
{
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId( id );
repoConfig.setName( id );
repoConfig.setLocation( location );
+ repoConfig.setLayout( layout );
return repoConfig;
}
@@ -144,8 +157,9 @@ public class ArchivaDavResourceFactoryTest
throws Exception
{
DavResourceLocator locator =
- new ArchivaDavResourceLocator( "", "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
- LOCAL_REPO_GROUP, new ArchivaDavLocatorFactory() );
+ new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP +
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
+ new ArchivaDavLocatorFactory() );
ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
@@ -158,17 +172,17 @@ public class ArchivaDavResourceFactoryTest
requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
repoRequestControl.expectAndReturn(
- repoRequest.isSupportFile( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false );
repoRequestControl.expectAndReturn(
- repoRequest.isDefault( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false );
repoRequestControl.expectAndReturn(
- repoRequest.toArtifactReference( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
null );
repoRequestControl.expectAndReturn(
repoRequest.toNativePath(
- "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
+ "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ),
new File(
config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
@@ -200,8 +214,9 @@ public class ArchivaDavResourceFactoryTest
throws Exception
{
DavResourceLocator locator =
- new ArchivaDavResourceLocator( "", "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
- LOCAL_REPO_GROUP, new ArchivaDavLocatorFactory() );
+ new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP +
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
+ new ArchivaDavLocatorFactory() );
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
@@ -226,17 +241,17 @@ public class ArchivaDavResourceFactoryTest
requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
repoRequestControl.expectAndReturn(
- repoRequest.isSupportFile( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false );
repoRequestControl.expectAndReturn(
- repoRequest.isDefault( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false );
repoRequestControl.expectAndReturn(
- repoRequest.toArtifactReference( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
null );
repoRequestControl.expectAndReturn(
repoRequest.toNativePath(
- "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
+ "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ),
new File(
config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
@@ -266,12 +281,14 @@ public class ArchivaDavResourceFactoryTest
throws Exception
{
DavResourceLocator locator =
- new ArchivaDavResourceLocator( "", "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
- LOCAL_REPO_GROUP, new ArchivaDavLocatorFactory() );
+ new ArchivaDavResourceLocator( "", "/repository/" + LOCAL_REPO_GROUP +
+ "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP,
+ new ArchivaDavLocatorFactory() );
config.addManagedRepository( createManagedRepository( LOCAL_MIRROR_REPO,
new File( getBasedir(),
- "target/test-classes/local-mirror" ).getPath() ) );
+ "target/test-classes/local-mirror" ).getPath(),
+ "default" ) );
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
@@ -297,17 +314,17 @@ public class ArchivaDavResourceFactoryTest
requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
repoRequestControl.expectAndReturn(
- repoRequest.isSupportFile( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false, 2 );
repoRequestControl.expectAndReturn(
- repoRequest.isDefault( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
false, 2 );
repoRequestControl.expectAndReturn(
- repoRequest.toArtifactReference( "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+ repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
null, 2 );
repoRequestControl.expectAndReturn(
repoRequest.toNativePath(
- "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
+ "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
internalRepo ),
new File(
config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(),
@@ -315,7 +332,7 @@ public class ArchivaDavResourceFactoryTest
repoRequestControl.expectAndReturn(
repoRequest.toNativePath(
- "archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
+ "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
localMirrorRepo ),
new File(
config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(),
@@ -341,6 +358,147 @@ public class ArchivaDavResourceFactoryTest
}
}
+ // MRM-1239
+ public void testRequestArtifactMetadataThreePartsRepoHasDefaultLayout()
+ throws Exception
+ {
+ // should fetch metadata
+ DavResourceLocator locator =
+ new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml", INTERNAL_REPO,
+ new ArchivaDavLocatorFactory() );
+
+ //DavResourceLocator locator =
+ // new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/extra/maven-metadata.xml",
+ // INTERNAL_REPO, new ArchivaDavLocatorFactory() );
+ ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+
+ // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
+ RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
+ resourceFactory.setRepositoryRequest( repoRequest );
+
+ try
+ {
+ archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+ repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
+ internalRepo );
+ requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
+ requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
+ requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+ requestControl.expectAndReturn( request.getRequestURI(), "http://localhost:8080/archiva/repository/" +
+ INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" );
+ response.addHeader( "Pragma", "no-cache" );
+ responseControl.setVoidCallable();
+
+ response.addHeader( "Cache-Control", "no-cache" );
+ responseControl.setVoidCallable();
+
+ long date = 2039842134;
+ response.addDateHeader( "last-modified", date );
+ responseControl.setVoidCallable();
+
+ archivaConfigurationControl.replay();
+ repoContentFactoryControl.replay();
+ requestControl.replay();
+ responseControl.replay();
+
+ resourceFactory.createResource( locator, request, response );
+
+ archivaConfigurationControl.verify();
+ repoContentFactoryControl.verify();
+ requestControl.verify();
+ responseControl.verify();
+ }
+ catch ( DavException e )
+ {
+ fail( "A DavException should not have been thrown!" );
+ }
+ }
+
+ public void testRequestArtifactMetadataTwoPartsRepoHasDefaultLayout()
+ throws Exception
+ {
+ // should not fetch metadata
+ DavResourceLocator locator =
+ new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml", INTERNAL_REPO,
+ new ArchivaDavLocatorFactory() );
+
+ ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO );
+
+ // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
+ RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
+ resourceFactory.setRepositoryRequest( repoRequest );
+
+ try
+ {
+ archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+ repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
+ internalRepo );
+ requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+ requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+ requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
+ archivaConfigurationControl.replay();
+ repoContentFactoryControl.replay();
+ requestControl.replay();
+
+ resourceFactory.createResource( locator, request, response );
+
+ archivaConfigurationControl.verify();
+ repoContentFactoryControl.verify();
+ requestControl.verify();
+
+ fail( "A 404 error should have been thrown!" );
+ }
+ catch ( DavException e )
+ {
+ assertEquals( 404, e.getErrorCode() );
+ }
+ }
+
+ public void testRequestMetadataRepoIsLegacy()
+ throws Exception
+ {
+ config.addManagedRepository( createManagedRepository( LEGACY_REPO, new File( getBasedir(),
+ "target/test-classes/" +
+ LEGACY_REPO ).getPath(),
+ "legacy" ) );
+ DavResourceLocator locator =
+ new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml", LEGACY_REPO,
+ new ArchivaDavLocatorFactory() );
+
+ ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO );
+
+ // use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
+ RepositoryRequest repoRequest = (RepositoryRequest) lookup( RepositoryRequest.class );
+ resourceFactory.setRepositoryRequest( repoRequest );
+
+ try
+ {
+ archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
+ repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
+ legacyRepo );
+ requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
+ requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
+ requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+
+ archivaConfigurationControl.replay();
+ repoContentFactoryControl.replay();
+ requestControl.replay();
+
+ resourceFactory.createResource( locator, request, response );
+
+ archivaConfigurationControl.verify();
+ repoContentFactoryControl.verify();
+ requestControl.verify();
+
+ fail( "A 404 error should have been thrown!" );
+ }
+ catch ( DavException e )
+ {
+ assertEquals( 404, e.getErrorCode() );
+ }
+ }
+
class OverridingArchivaDavResourceFactory
extends ArchivaDavResourceFactory
{
@@ -363,4 +521,23 @@ public class ArchivaDavResourceFactoryTest
return "guest";
}
}
+
+ class OverridingRepositoryProxyConnectors
+ extends DefaultRepositoryProxyConnectors
+ {
+ public File fetchMetatadaFromProxies( ManagedRepositoryContent repository, String logicalPath )
+ {
+ File target = new File( repository.getRepoRoot(), logicalPath );
+ try
+ {
+ FileUtils.copyFile( new File( getBasedir(), "target/test-classes/maven-metadata.xml" ), target );
+ }
+ catch ( IOException e )
+ {
+
+ }
+
+ return target;
+ }
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/maven-metadata.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/maven-metadata.xml
new file mode 100644
index 000000000..748dbd8c2
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/maven-metadata.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata/> \ No newline at end of file