summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-06-01 14:37:32 +0000
committerOlivier Lamy <olamy@apache.org>2011-06-01 14:37:32 +0000
commitf378a857ebf36348caedbd78890c71cd96e02a9d (patch)
treeece67be82642972fd6d0182da0819d152b678c39 /archiva-modules
parent76386bfcb1f4476f25eca5ac215263c1451a1cfd (diff)
downloadarchiva-f378a857ebf36348caedbd78890c71cd96e02a9d.tar.gz
archiva-f378a857ebf36348caedbd78890c71cd96e02a9d.zip
[MRM-1473] remove use of plexus-spring
fix module metadata-store-jcr git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1130164 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/pom.xml5
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java62
-rw-r--r--archiva-modules/plugins/metadata-store-file/pom.xml5
-rw-r--r--archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java2
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/pom.xml5
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java21
6 files changed, 94 insertions, 6 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/pom.xml b/archiva-modules/metadata/metadata-repository-api/pom.xml
index 30e4ef8b8..c5ef90a84 100644
--- a/archiva-modules/metadata/metadata-repository-api/pom.xml
+++ b/archiva-modules/metadata/metadata-repository-api/pom.xml
@@ -39,6 +39,11 @@
<artifactId>metadata-model</artifactId>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 9d45c8ded..9c663e516 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -32,6 +32,10 @@ import org.apache.archiva.metadata.model.Organization;
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;
@@ -43,6 +47,8 @@ import java.util.HashMap;
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
{
@@ -104,6 +110,7 @@ public abstract class AbstractMetadataRepositoryTest
return factories;
}
+ @Test
public void testRootNamespaceWithNoMetadataRepository()
throws Exception
{
@@ -111,6 +118,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), namespaces );
}
+ @Test
public void testGetNamespaceOnly()
throws Exception
{
@@ -121,6 +129,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
+ @Test
public void testGetProjectOnly()
throws Exception
{
@@ -141,6 +150,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( TEST_NAMESPACE ), repository.getRootNamespaces( TEST_REPO_ID ) );
}
+ @Test
public void testGetProjectVersionOnly()
throws Exception
{
@@ -163,6 +173,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( TEST_NAMESPACE, projectMetadata.getNamespace() );
}
+ @Test
public void testGetArtifactOnly()
throws Exception
{
@@ -193,6 +204,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( TEST_PROJECT_VERSION, projectVersionMetadata.getId() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithNoOtherArchives()
throws Exception
{
@@ -212,6 +224,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), mailingList.getOtherArchives() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithAllElements()
throws Exception
{
@@ -306,6 +319,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( d.isOptional() );
}
+ @Test
public void testGetRepositories()
throws Exception
{
@@ -318,6 +332,7 @@ public abstract class AbstractMetadataRepositoryTest
repository.getRepositories() ) );
}
+ @Test
public void testUpdateProjectVersionMetadataIncomplete()
throws Exception
{
@@ -341,6 +356,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( metadata.getDependencies().isEmpty() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithExistingFacets()
throws Exception
{
@@ -363,6 +379,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( "baz", testFacet.getValue() );
}
+ @Test
public void testUpdateProjectVersionMetadataWithNoExistingFacets()
throws Exception
{
@@ -381,6 +398,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), new ArrayList<String>( metadata.getFacetIds() ) );
}
+ @Test
public void testUpdateProjectVersionMetadataWithExistingFacetsFacetPropertyWasRemoved()
throws Exception
{
@@ -415,6 +433,7 @@ public abstract class AbstractMetadataRepositoryTest
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
}
+ @Test
public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets()
throws Exception
{
@@ -446,6 +465,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
}
+ @Test
public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved()
throws Exception
{
@@ -484,6 +504,7 @@ public abstract class AbstractMetadataRepositoryTest
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
}
+ @Test
public void testUpdateArtifactMetadataWithExistingFacets()
throws Exception
{
@@ -506,6 +527,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( "baz", testFacet.getValue() );
}
+ @Test
public void testUpdateArtifactMetadataWithNoExistingFacets()
throws Exception
{
@@ -524,6 +546,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), new ArrayList<String>( metadata.getFacetIds() ) );
}
+ @Test
public void testGetMetadataFacet()
throws Exception
{
@@ -533,12 +556,14 @@ public abstract class AbstractMetadataRepositoryTest
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
{
@@ -547,6 +572,7 @@ public abstract class AbstractMetadataRepositoryTest
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, UNKNOWN ) );
}
+ @Test
public void testGetMetadataFacetWhenDefaultValue()
throws Exception
{
@@ -557,12 +583,14 @@ public abstract class AbstractMetadataRepositoryTest
TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacetWhenUnknownFacetId()
throws Exception
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
}
+ @Test
public void testGetMetadataFacets()
throws Exception
{
@@ -572,17 +600,17 @@ public abstract class AbstractMetadataRepositoryTest
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 ) );
@@ -595,6 +623,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetsWhenEmpty()
throws Exception
{
@@ -607,6 +636,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetsWhenUnknown()
throws Exception
{
@@ -614,6 +644,7 @@ public abstract class AbstractMetadataRepositoryTest
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
}
+ @Test
public void testRemoveFacetWhenUnknown()
throws Exception
{
@@ -621,6 +652,7 @@ public abstract class AbstractMetadataRepositoryTest
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
}
+ @Test
public void testRemoveFacet()
throws Exception
{
@@ -638,6 +670,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( facets.isEmpty() );
}
+ @Test
public void testRemoveFacetWhenEmpty()
throws Exception
{
@@ -652,6 +685,7 @@ public abstract class AbstractMetadataRepositoryTest
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
+ @Test
public void testGetArtifacts()
throws Exception
{
@@ -673,6 +707,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Arrays.asList( artifact1, artifact2 ), actual );
}
+ @Test
public void testGetArtifactVersions()
throws Exception
{
@@ -694,6 +729,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Arrays.asList( version1, version2 ), versions );
}
+ @Test
public void testGetArtifactVersionsMultipleArtifactsSingleVersion()
throws Exception
{
@@ -710,6 +746,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_PROJECT_VERSION ) );
}
+ @Test
public void testGetArtifactsByDateRangeOpen()
throws Exception
{
@@ -721,6 +758,7 @@ public abstract class AbstractMetadataRepositoryTest
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeSparseNamespace()
throws Exception
{
@@ -734,6 +772,7 @@ public abstract class AbstractMetadataRepositoryTest
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeLowerBound()
throws Exception
{
@@ -746,6 +785,7 @@ public abstract class AbstractMetadataRepositoryTest
null ) );
}
+ @Test
public void testGetArtifactsByDateRangeLowerBoundOutOfRange()
throws Exception
{
@@ -756,6 +796,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, date, null ).isEmpty() );
}
+ @Test
public void testGetArtifactsByDateRangeLowerAndUpperBound()
throws Exception
{
@@ -769,6 +810,7 @@ public abstract class AbstractMetadataRepositoryTest
upper ) );
}
+ @Test
public void testGetArtifactsByDateRangeUpperBound()
throws Exception
{
@@ -781,6 +823,7 @@ public abstract class AbstractMetadataRepositoryTest
upper ) );
}
+ @Test
public void testGetArtifactsByDateRangeUpperBoundOutOfRange()
throws Exception
{
@@ -792,6 +835,7 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ).isEmpty() );
}
+ @Test
public void testGetArtifactsByRepoId()
throws Exception
{
@@ -802,6 +846,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( artifact ), repository.getArtifacts( TEST_REPO_ID ) );
}
+ @Test
public void testGetArtifactsByRepoIdMultipleCopies()
throws Exception
{
@@ -818,6 +863,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( secondArtifact ), repository.getArtifacts( OTHER_REPO_ID ) );
}
+ @Test
public void testGetArtifactsByDateRangeMultipleCopies()
throws Exception
{
@@ -836,6 +882,7 @@ public abstract class AbstractMetadataRepositoryTest
null, null ) );
}
+ @Test
public void testGetArtifactsByChecksumMultipleCopies()
throws Exception
{
@@ -858,6 +905,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_MD5 ) );
}
+ @Test
public void testGetNamespacesWithSparseDepth()
throws Exception
{
@@ -869,6 +917,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Arrays.asList( "shared" ), repository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ) );
}
+ @Test
public void testGetNamespacesWithProjectsPresent()
throws Exception
{
@@ -882,6 +931,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<String>emptyList(), repository.getNamespaces( TEST_REPO_ID, namespace ) );
}
+ @Test
public void testGetProjectsWithOtherNamespacesPresent()
throws Exception
{
@@ -896,6 +946,7 @@ public abstract class AbstractMetadataRepositoryTest
"org.apache.maven" ) );
}
+ @Test
public void testGetProjectVersionsWithOtherNamespacesPresent()
throws Exception
{
@@ -915,6 +966,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_PROJECT ) );
}
+ @Test
public void testGetArtifactsByChecksumSingleResultMd5()
throws Exception
{
@@ -926,6 +978,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_MD5 ) );
}
+ @Test
public void testGetArtifactsByChecksumSingleResultSha1()
throws Exception
{
@@ -937,6 +990,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_SHA1 ) );
}
+ @Test
public void testGetArtifactsByChecksumDeepNamespace()
throws Exception
{
@@ -952,6 +1006,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_MD5 ) );
}
+ @Test
public void testGetArtifactsByChecksumMultipleResult()
throws Exception
{
@@ -974,6 +1029,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts );
}
+ @Test
public void testGetArtifactsByChecksumNoResult()
throws Exception
{
@@ -984,6 +1040,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.<ArtifactMetadata>emptyList(), artifactsByChecksum );
}
+ @Test
public void testDeleteArtifact()
throws Exception
{
@@ -1001,6 +1058,7 @@ public abstract class AbstractMetadataRepositoryTest
TEST_PROJECT_VERSION ).isEmpty() );
}
+ @Test
public void testDeleteRepository()
throws Exception
{
diff --git a/archiva-modules/plugins/metadata-store-file/pom.xml b/archiva-modules/plugins/metadata-store-file/pom.xml
index 00556ffbc..0dd237306 100644
--- a/archiva-modules/plugins/metadata-store-file/pom.xml
+++ b/archiva-modules/plugins/metadata-store-file/pom.xml
@@ -65,5 +65,10 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
index 05693af32..77229cf3b 100644
--- a/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
+++ b/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java
@@ -25,6 +25,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.junit.Before;
import java.io.File;
import java.util.Map;
@@ -36,6 +37,7 @@ public class FileMetadataRepositoryTest
extends AbstractMetadataRepositoryTest
{
+ @Before
public void setUp()
throws Exception
{
diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml
index f501ca131..b5de67f2a 100644
--- a/archiva-modules/plugins/metadata-store-jcr/pom.xml
+++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml
@@ -69,6 +69,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<testResources>
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
index fbe1d5032..365135943 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
@@ -22,8 +22,13 @@ package org.apache.archiva.metadata.repository.jcr;
import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.springframework.context.ApplicationContext;
+import java.io.File;
import java.util.Map;
+import javax.inject.Inject;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -33,17 +38,25 @@ public class JcrMetadataRepositoryTest
{
private JcrMetadataRepository jcrMetadataRepository;
+ @Inject
+ private ApplicationContext applicationContext;
+
+ @Before
public void setUp()
throws Exception
{
super.setUp();
- FileUtils.deleteDirectory( getTestFile( "target/test-repositories" ) );
+ File directory = new File( "target/test-repositories" );
+ if (directory.exists())
+ {
+ FileUtils.deleteDirectory( directory );
+ }
Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
// TODO: probably don't need to use Spring for this
- Repository repository = (Repository) lookup( Repository.class );
+ Repository repository = applicationContext.getBean( Repository.class );
jcrMetadataRepository = new JcrMetadataRepository( factories, repository );
try
@@ -64,8 +77,8 @@ public class JcrMetadataRepositoryTest
this.repository = jcrMetadataRepository;
}
- @Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
jcrMetadataRepository.close();