add unit test for new method in MetadataRepository and fix compilation for some impls/mocks

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1397345 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-11 22:43:15 +00:00
parent 092a635e39
commit e7bc35db81
11 changed files with 94 additions and 2 deletions

View File

@ -201,4 +201,10 @@ public class TestMetadataRepository
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}

View File

@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataRepositoryException
{
}
};
}
};

View File

@ -206,4 +206,10 @@ public class TestMetadataRepository
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}

View File

@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataRepositoryException
{
}
};
}
};

View File

@ -260,6 +260,13 @@ public class MockRepositorySessionFactory
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataRepositoryException
{
}
};
}
};

View File

@ -337,5 +337,11 @@ public class NewArtifactsRssFeedProcessorTest
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}
}

View File

@ -241,4 +241,10 @@ public class TestMetadataRepository
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}

View File

@ -202,4 +202,10 @@ public class TestMetadataRepository
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}

View File

@ -1132,7 +1132,7 @@ public abstract class AbstractMetadataRepositoryTest
}
@Test
public void deleteVersion()
public void deleteArtifact()
throws Exception
{
ArtifactMetadata artifact = createArtifact();
@ -1151,6 +1151,24 @@ public abstract class AbstractMetadataRepositoryTest
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() );
}
@Test
public void deleteVersion()
throws Exception
{
ArtifactMetadata artifact = createArtifact();
artifact.addFacet( new TestMetadataFacet( "value" ) );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertEquals( 1, repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ).size() );
repository.removeProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( 0, repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ).size() );
}
@Test
public void deleteSnapshotVersion()
throws Exception

View File

@ -217,4 +217,10 @@ public class TestMetadataRepository
{
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
}
}

View File

@ -703,7 +703,6 @@ public class FileMetadataRepository
* @param namespace
* @param project
* @param projectVersion
* @param projectId
* @param metadataFacet will remove artifacts which have this {@link MetadataFacet} using equals
* @throws MetadataRepositoryException
*/
@ -1163,6 +1162,24 @@ public class FileMetadataRepository
return projectVersions;
}
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
File directory = new File( getDirectory( repoId ), namespace + "/" + projectId + "/" + projectVersion );
if ( directory.exists() )
{
try
{
FileUtils.deleteDirectory( directory );
}
catch ( IOException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
}
private void writeProperties( Properties properties, File directory, String propertiesKey )
throws IOException
{