import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.Scm;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} )
public abstract class AbstractMetadataRepositoryTest
extends TestCase
{
return factories;
}
+ @Test
public void testRootNamespaceWithNoMetadataRepository()
throws Exception
{
assertEquals( Collections.<String>emptyList(), namespaces );
}
+ @Test
public void testGetNamespaceOnly()
throws Exception
{
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
+ @Test
public void testGetProjectOnly()
throws Exception
{
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
+ @Test
public void testGetProjectVersionOnly()
throws Exception
{
assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace() );
}
+ @Test
public void testGetArtifactOnly()
throws Exception
{
assertEquals( TEST_PROJECT_VERSION, projectVersionMetadata.getId() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithNoOtherArchives()
throws Exception
{
assertEquals( Collections.<String>emptyList(), mailingList.getOtherArchives() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithAllElements()
throws Exception
{
assertTrue( d.isOptional() );
}
+ @Test
public void testGetRepositories()
throws Exception
{
repository.getRepositories() ) );
}
+ @Test
public void testUpdateProjectVersionMetadataIncomplete()
throws Exception
{
assertTrue( metadata.getDependencies().isEmpty() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithExistingFacets()
throws Exception
{
assertEquals( "baz", testFacet.getValue() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithNoExistingFacets()
throws Exception
{
assertEquals( Collections.<String>emptyList(), new ArrayList<String>( metadata.getFacetIds() ) );
}
+ @Test
public void testUpdateProjectVersionMetadataWithExistingFacetsFacetPropertyWasRemoved()
throws Exception
{
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
}
+ @Test
public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets()
throws Exception
{
assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
}
+ @Test
public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved()
throws Exception
{
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
}
+ @Test
public void testUpdateArtifactMetadataWithExistingFacets()
throws Exception
{
assertEquals( "baz", testFacet.getValue() );
}
+ @Test
public void testUpdateArtifactMetadataWithNoExistingFacets()
throws Exception
{
assertEquals( Collections.<String>emptyList(), new ArrayList<String>( metadata.getFacetIds() ) );
}
+ @Test
public void testGetMetadataFacet()
throws Exception
{
TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacetWhenEmpty()
throws Exception
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacetWhenUnknownName()
throws Exception
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, UNKNOWN ) );
}
+ @Test
public void testGetMetadataFacetWhenDefaultValue()
throws Exception
{
TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacetWhenUnknownFacetId()
throws Exception
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacets()
throws Exception
{
TEST_FACET_ID ) );
}
+ @Test
public void testGetMetadataFacetsWhenEmpty()
throws Exception
-
{
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacets()
throws Exception
-
{
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetsWhenEmpty()
throws Exception
{
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetsWhenUnknown()
throws Exception
{
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
}
+ @Test
public void testRemoveFacetWhenUnknown()
throws Exception
{
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
}
+ @Test
public void testRemoveFacet()
throws Exception
{
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetWhenEmpty()
throws Exception
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
+ @Test
public void testGetArtifacts()
throws Exception
{
assertEquals( Arrays.asList( artifact1, artifact2 ), actual );
}
+ @Test
public void testGetArtifactVersions()
throws Exception
{
assertEquals( Arrays.asList( version1, version2 ), versions );
}
+ @Test
public void testGetArtifactVersionsMultipleArtifactsSingleVersion()
throws Exception
{
TEST_PROJECT_VERSION ) );
}
+ @Test
public void testGetArtifactsByDateRangeOpen()
throws Exception
{
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeSparseNamespace()
throws Exception
{
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeLowerBound()
throws Exception
{
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeLowerBoundOutOfRange()
throws Exception
{
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ).isEmpty() );
}
+ @Test
public void testGetArtifactsByDateRangeLowerAndUpperBound()
throws Exception
{
upper ) );
}
+ @Test
public void testGetArtifactsByDateRangeUpperBound()
throws Exception
{
upper ) );
}
+ @Test
public void testGetArtifactsByDateRangeUpperBoundOutOfRange()
throws Exception
{
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ).isEmpty() );
}
+ @Test
public void testGetArtifactsByRepoId()
throws Exception
{
assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) );
}
+ @Test
public void testGetArtifactsByRepoIdMultipleCopies()
throws Exception
{
assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifacts( OTHER_REPO_ID ) );
}
+ @Test
public void testGetArtifactsByDateRangeMultipleCopies()
throws Exception
{
null, null ) );
}
+ @Test
public void testGetArtifactsByChecksumMultipleCopies()
throws Exception
{
TEST_MD5 ) );
}
+ @Test
public void testGetNamespacesWithSparseDepth()
throws Exception
{
assertEquals( Arrays.asList( "shared" ), repository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ) );
}
+ @Test
public void testGetNamespacesWithProjectsPresent()
throws Exception
{
assertEquals( Collections.<String>emptyList(), repository.getNamespaces( TEST_REPO_ID, namespace ) );
}
+ @Test
public void testGetProjectsWithOtherNamespacesPresent()
throws Exception
{
"org.apache.maven" ) );
}
+ @Test
public void testGetProjectVersionsWithOtherNamespacesPresent()
throws Exception
{
TEST_PROJECT ) );
}
+ @Test
public void testGetArtifactsByChecksumSingleResultMd5()
throws Exception
{
TEST_MD5 ) );
}
+ @Test
public void testGetArtifactsByChecksumSingleResultSha1()
throws Exception
{
TEST_SHA1 ) );
}
+ @Test
public void testGetArtifactsByChecksumDeepNamespace()
throws Exception
{
TEST_MD5 ) );
}
+ @Test
public void testGetArtifactsByChecksumMultipleResult()
throws Exception
{
assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts );
}
+ @Test
public void testGetArtifactsByChecksumNoResult()
throws Exception
{
assertEquals( Collections.<ArtifactMetadata>emptyList(), artifactsByChecksum );
}
+ @Test
public void testDeleteArtifact()
throws Exception
{
TEST_PROJECT_VERSION ).isEmpty() );
}
+ @Test
public void testDeleteRepository()
throws Exception
{