mirror of https://github.com/apache/archiva.git
Adding tests for new repo content interface
This commit is contained in:
parent
65e4acd8bd
commit
8befca5a49
|
@ -19,10 +19,15 @@ package org.apache.archiva.repository.maven.content;
|
|||
*/
|
||||
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.content.base.ArchivaItemSelector;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Specific tests for ManagedRepositoryContent
|
||||
*
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public abstract class AbstractManagedRepositoryContentTest extends AbstractRepositoryContentTest
|
||||
|
@ -36,11 +41,22 @@ public abstract class AbstractManagedRepositoryContentTest extends AbstractRepos
|
|||
{
|
||||
getManaged().toItem( path );
|
||||
fail(
|
||||
"Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
|
||||
"toItem(path) should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
/* expected path */
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetArtifactOnEmptyPath() {
|
||||
ItemSelector selector = ArchivaItemSelector.builder( ).build( );
|
||||
try {
|
||||
getManaged( ).getArtifact( selector );
|
||||
fail( "getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException" );
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Good
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven.content;
|
|||
*/
|
||||
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.repository.RepositoryContent;
|
||||
import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
|
@ -69,18 +70,21 @@ public abstract class AbstractRepositoryContentTest
|
|||
public void testBadPathTooShort()
|
||||
{
|
||||
assertBadPath( "invalid/invalid-1.0.jar", "path is too short" );
|
||||
assertBadPathCi( "invalid/invalid-1.0.jar", "path is too short" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadPathVersionMismatchA()
|
||||
{
|
||||
assertBadPath( "invalid/invalid/1.0/invalid-2.0.jar", "version mismatch between path and artifact" );
|
||||
assertBadPathCi( "invalid/invalid/1.0/invalid-2.0.jar", "version mismatch between path and artifact" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadPathVersionMismatchB()
|
||||
{
|
||||
assertBadPath( "invalid/invalid/1.0/invalid-1.0b.jar", "version mismatch between path and artifact" );
|
||||
assertBadPathCi( "invalid/invalid/1.0/invalid-1.0b.jar", "version mismatch between path and artifact" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,6 +92,8 @@ public abstract class AbstractRepositoryContentTest
|
|||
{
|
||||
assertBadPath( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar",
|
||||
"wrong artifact id" );
|
||||
assertBadPathCi( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar",
|
||||
"wrong artifact id" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,6 +378,21 @@ public abstract class AbstractRepositoryContentTest
|
|||
assertLayoutCi( path, groupId, artifactId, version, classifier, type );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testToItemSelectorOnEmptyPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
getContent( ).toItemSelector( "" );
|
||||
fail( "toItemSelector() should have failed due to empty path." );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
/* expected path */
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToArtifactOnEmptyPath()
|
||||
{
|
||||
|
@ -401,26 +422,12 @@ public abstract class AbstractRepositoryContentTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testToArtifactReferenceOnEmptyPath()
|
||||
public void testToItemSelectorOnNullPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
toArtifactReference( "" );
|
||||
fail( "Should have failed due to empty path." );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
/* expected path */
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToArtifactReferenceOnNullPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
toArtifactReference( null );
|
||||
fail( "Should have failed due to null path." );
|
||||
getContent().toItemSelector( null );
|
||||
fail( "toItemSelector() should have failed due to null path." );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
|
@ -636,4 +643,6 @@ public abstract class AbstractRepositoryContentTest
|
|||
protected abstract ItemSelector toItemSelector(String path) throws LayoutException;
|
||||
|
||||
protected abstract ManagedRepositoryContent getManaged();
|
||||
|
||||
protected abstract RepositoryContent getContent( );
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.archiva.model.VersionedReference;
|
|||
import org.apache.archiva.repository.EditableManagedRepository;
|
||||
import org.apache.archiva.repository.LayoutException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContent;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.maven.MavenManagedRepository;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
|
@ -282,6 +283,12 @@ public class ManagedDefaultRepositoryContentTest
|
|||
return repoContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RepositoryContent getContent( )
|
||||
{
|
||||
return repoContent;
|
||||
}
|
||||
|
||||
private Path setupRepoCopy( String source, String target) throws IOException
|
||||
{
|
||||
Path defaultRepo = getRepositoryPath( source );
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.archiva.repository.LayoutException;
|
|||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RemoteRepository;
|
||||
import org.apache.archiva.repository.RemoteRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryContent;
|
||||
import org.apache.archiva.repository.content.ItemSelector;
|
||||
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
|
||||
import org.junit.Before;
|
||||
|
@ -73,6 +74,12 @@ public class RemoteDefaultRepositoryContentTest
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RepositoryContent getContent( )
|
||||
{
|
||||
return repoContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toPath( ArtifactReference reference )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue