From: Olivier Lamy Date: Mon, 29 Oct 2012 21:02:19 +0000 (+0000) Subject: [MRM-1704] Refactor to remove maven specific part from various repository/metadata... X-Git-Tag: archiva-1.4-M4~685 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=00ee48b77b646f1e91ae67aadde6e7c014333a59;p=archiva.git [MRM-1704] Refactor to remove maven specific part from various repository/metadata apis fix some unit tests due to some move spring conf for test need to be adapted. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1403511 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/spring-context.xml deleted file mode 100644 index 03ae490a6..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/spring-context.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 791c8806c..cb2171c70 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -72,6 +72,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; @@ -136,8 +137,7 @@ public class Maven2RepositoryStorage private WagonFactory wagonFactory; @Inject - @Named ( value = "repositoryProxyConnectors#default" ) - private RepositoryProxyConnectors connectors; + private ApplicationContext applicationContext; private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class ); @@ -644,6 +644,9 @@ public class Maven2RepositoryStorage pomReference.setVersion( artifact.getVersion() ); pomReference.setType( "pom" ); + RepositoryProxyConnectors connectors = + applicationContext.getBean( "repositoryProxyConnectors#default", RepositoryProxyConnectors.class ); + // Get the artifact POM from proxied repositories if needed connectors.fetchFromProxies( managedRepository, pomReference ); diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java index d5839d210..a58393169 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java @@ -47,17 +47,17 @@ public class TestConfiguration public void addListener( ConfigurationListener listener ) { - throw new UnsupportedOperationException(); + // no op } public void removeListener( ConfigurationListener listener ) { - throw new UnsupportedOperationException(); + // no op } public void addChangeListener( RegistryListener listener ) { - throw new UnsupportedOperationException(); + // no op } public void reload() diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java index 319df0f23..211cfa305 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java @@ -35,7 +35,7 @@ public class TestMetadataResolver String projectId, String projectVersion ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveProjectReferences( RepositorySession session, String repoId, @@ -43,38 +43,38 @@ public class TestMetadataResolver String projectVersion ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveRootNamespaces( RepositorySession session, String repoId ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveNamespaces( RepositorySession session, String repoId, String namespace ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveProjects( RepositorySession session, String repoId, String namespace ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveProjectVersions( RepositorySession session, String repoId, String namespace, String projectId ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public Collection resolveArtifacts( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion ) throws MetadataResolutionException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java index c63c8d7bf..cf998b63e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractDefaultRepositoryContentTestCase.java @@ -20,6 +20,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; */ import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.lang.StringUtils; @@ -33,7 +34,7 @@ import static org.junit.Assert.*; * AbstractDefaultRepositoryContentTestCase */ @RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public abstract class AbstractDefaultRepositoryContentTestCase extends AbstractRepositoryLayerTestCase { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractLegacyRepositoryContentTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractLegacyRepositoryContentTestCase.java index 5a53f84d1..f00aef424 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractLegacyRepositoryContentTestCase.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractLegacyRepositoryContentTestCase.java @@ -20,6 +20,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; */ import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.Test; @@ -32,10 +33,11 @@ import static org.junit.Assert.*; * AbstractLegacyRepositoryContentTestCase */ @RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public abstract class AbstractLegacyRepositoryContentTestCase extends AbstractRepositoryLayerTestCase { + @Test public void testBadPathArtifactIdMissingA() { @@ -48,6 +50,7 @@ public abstract class AbstractLegacyRepositoryContentTestCase assertBadPath( "groupId/jars/1.0.jar", "artifactId is missing" ); } + @Test public void testBadPathMissingType() { @@ -61,6 +64,7 @@ public abstract class AbstractLegacyRepositoryContentTestCase assertBadPath( "invalid/invalid-1.0.jar", "path is too short" ); } + @Test public void testBadPathWrongPackageExtension() { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractRepositoryLayerTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractRepositoryLayerTestCase.java deleted file mode 100644 index ea1ea8450..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/AbstractRepositoryLayerTestCase.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.apache.archiva.metadata.repository.storage.maven2; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.admin.model.beans.RemoteRepository; -import org.apache.archiva.repository.ManagedRepositoryContent; -import org.apache.archiva.repository.RemoteRepositoryContent; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; - -import javax.inject.Inject; -import java.io.File; - -/** - * AbstractRepositoryLayerTestCase - * - * - */ -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) -public abstract class AbstractRepositoryLayerTestCase -{ - @Rule - public TestName name = new TestName(); - - @Inject - protected ApplicationContext applicationContext; - - protected ManagedRepository createRepository( String id, String name, File location ) - { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.getAbsolutePath() ); - return repo; - } - - protected RemoteRepository createRemoteRepository( String id, String name, String url ) - { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); - return repo; - } - - protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, File location, - String layout ) - throws Exception - { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.getAbsolutePath() ); - repo.setLayout( layout ); - - ManagedRepositoryContent repoContent = - applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class ); - repoContent.setRepository( repo ); - - return repoContent; - } - - protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout ) - throws Exception - { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); - repo.setLayout( layout ); - - RemoteRepositoryContent repoContent = - applicationContext.getBean( "remoteRepositoryContent#" + layout, RemoteRepositoryContent.class ); - repoContent.setRepository( repo ); - - return repoContent; - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java index 4fc0e7429..0c583a059 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java @@ -50,8 +50,6 @@ import static org.junit.Assert.fail; /** * ManagedDefaultRepositoryContentTest */ -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class ManagedDefaultRepositoryContentTest extends AbstractDefaultRepositoryContentTestCase { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedLegacyRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedLegacyRepositoryContentTest.java index 61640e563..e0bbde49e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedLegacyRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedLegacyRepositoryContentTest.java @@ -47,8 +47,6 @@ import static org.junit.Assert.*; * * */ -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class ManagedLegacyRepositoryContentTest extends AbstractDefaultRepositoryContentTestCase { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java index 9a3a78cf6..e24a00a49 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java @@ -56,8 +56,10 @@ import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith (ArchivaSpringJUnit4ClassRunner.class) -@ContextConfiguration (locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" }) + +@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) +@ContextConfiguration ( + locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest extends TestCase { @@ -92,6 +94,7 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; @Inject + @Named (value = "archivaConfiguration#default") private ArchivaConfiguration configuration; private WagonFactory wagonFactory; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411Test.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411Test.java index a03e70291..6d940fa2b 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411Test.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411Test.java @@ -58,14 +58,15 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@ContextConfiguration ( + locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public class Maven2RepositoryMetadataResolverMRM1411Test extends TestCase { private static final Filter ALL = new AllFilter(); @Inject - @Named ( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -89,6 +90,7 @@ public class Maven2RepositoryMetadataResolverMRM1411Test private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; @Inject + @Named (value = "archivaConfiguration#default") private ArchivaConfiguration configuration; private WagonFactory wagonFactory; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java index 495c15c55..c0ebe5ef4 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java @@ -19,32 +19,26 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException; import org.apache.archiva.proxy.common.WagonFactory; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; import javax.inject.Named; -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class Maven2RepositoryMetadataResolverManagedReleaseTest extends Maven2RepositoryMetadataResolverTest { private static final Filter ALL = new AllFilter(); @Inject - @Named ( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -67,9 +61,6 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; - @Inject - private ArchivaConfiguration configuration; - private WagonFactory wagonFactory; @Before @@ -103,7 +94,7 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() throws Exception @@ -114,7 +105,7 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest storage.readProjectVersionMetadata( readMetadataRequest ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata() throws Exception @@ -125,7 +116,7 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest storage.readProjectVersionMetadata( readMetadataRequest ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception @@ -134,7 +125,7 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata() throws Exception diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java index f24ba9cbf..5011f9f04 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java @@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; @@ -34,16 +33,16 @@ import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; import javax.inject.Named; - @RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@ContextConfiguration ( + locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public class Maven2RepositoryMetadataResolverManagedSnapshotTest extends Maven2RepositoryMetadataResolverTest { private static final Filter ALL = new AllFilter(); @Inject - @Named ( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -64,10 +63,8 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e"; - private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; - @Inject - private ArchivaConfiguration configuration; + private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; @Before @@ -86,7 +83,7 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest assertFalse( c.getManagedRepositories().get( 0 ).isReleases() ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testModelWithJdkProfileActivation() throws Exception @@ -100,7 +97,7 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForMislocatedPom() throws Exception @@ -120,7 +117,7 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest // super test is on release } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForInvalidPom() throws Exception @@ -131,7 +128,7 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest storage.readProjectVersionMetadata( readMetadataRequest ); } - @Test ( expected = RepositoryStorageRuntimeException.class ) + @Test (expected = RepositoryStorageRuntimeException.class) @Override public void testGetProjectVersionMetadataForMissingPom() throws Exception diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index 3c8e3212d..607d91a1b 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -62,15 +62,16 @@ import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith (ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration ( + locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" }) public class Maven2RepositoryMetadataResolverTest extends TestCase { private static final Filter ALL = new AllFilter(); @Inject - @Named ( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -94,7 +95,8 @@ public class Maven2RepositoryMetadataResolverTest private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; @Inject - private ArchivaConfiguration configuration; + @Named ( value = "archivaConfiguration#default" ) + protected ArchivaConfiguration configuration; private WagonFactory wagonFactory; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java index fc2e4cf2d..be5f77b1c 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java @@ -34,8 +34,6 @@ import javax.inject.Named; /** * RemoteDefaultRepositoryContentTest */ -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class RemoteDefaultRepositoryContentTest extends AbstractDefaultRepositoryContentTestCase { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java index 4f4e3bee9..1e587c92f 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java @@ -41,7 +41,7 @@ import static org.junit.Assert.*; * */ @RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) public class LegacyPathParserTest { private LegacyPathParser parser; diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/default-repository/org/apache/cocoon/cocoon/1/cocoon-1.pom b/archiva-modules/plugins/maven2-repository/src/test/repositories/default-repository/org/apache/cocoon/cocoon/1/cocoon-1.pom index 31405768a..81201451e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/repositories/default-repository/org/apache/cocoon/cocoon/1/cocoon-1.pom +++ b/archiva-modules/plugins/maven2-repository/src/test/repositories/default-repository/org/apache/cocoon/cocoon/1/cocoon-1.pom @@ -16,7 +16,7 @@ --> diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-metadata-tools-test.xml b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-metadata-tools-test.xml index 663f4fad0..90b8da13e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-metadata-tools-test.xml +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-metadata-tools-test.xml @@ -27,7 +27,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-lazy-init="true"> - + + diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml new file mode 100644 index 000000000..98df63617 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml @@ -0,0 +1,30 @@ + + + + + + + \ No newline at end of file