소스 검색

Adding tests for new repo content interface

pull/60/head
Martin Stockhammer 4 년 전
부모
커밋
8befca5a49

+ 17
- 1
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractManagedRepositoryContentTest.java 파일 보기

@@ -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
}
}
}

+ 21
- 12
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractRepositoryContentTest.java 파일 보기

@@ -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,13 +378,14 @@ public abstract class AbstractRepositoryContentTest
assertLayoutCi( path, groupId, artifactId, version, classifier, type );
}


@Test
public void testToArtifactOnEmptyPath()
public void testToItemSelectorOnEmptyPath()
{
try
{
toArtifactReference( "" );
fail( "Should have failed due to empty path." );
getContent( ).toItemSelector( "" );
fail( "toItemSelector() should have failed due to empty path." );
}
catch ( LayoutException e )
{
@@ -387,12 +394,12 @@ public abstract class AbstractRepositoryContentTest
}

@Test
public void testToArtifactOnNullPath()
public void testToArtifactOnEmptyPath()
{
try
{
toArtifactReference( null );
fail( "Should have failed due to null path." );
toArtifactReference( "" );
fail( "Should have failed due to empty path." );
}
catch ( LayoutException e )
{
@@ -401,12 +408,12 @@ public abstract class AbstractRepositoryContentTest
}

@Test
public void testToArtifactReferenceOnEmptyPath()
public void testToArtifactOnNullPath()
{
try
{
toArtifactReference( "" );
fail( "Should have failed due to empty path." );
toArtifactReference( null );
fail( "Should have failed due to null path." );
}
catch ( LayoutException e )
{
@@ -415,12 +422,12 @@ public abstract class AbstractRepositoryContentTest
}

@Test
public void testToArtifactReferenceOnNullPath()
public void testToItemSelectorOnNullPath()
{
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( );
}

+ 7
- 0
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java 파일 보기

@@ -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 );

+ 7
- 0
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/RemoteDefaultRepositoryContentTest.java 파일 보기

@@ -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…
취소
저장