diff --git a/archiva-modules/archiva-web/archiva-rss/pom.xml b/archiva-modules/archiva-web/archiva-rss/pom.xml index a5827b2fc..cd38a6e93 100644 --- a/archiva-modules/archiva-web/archiva-rss/pom.xml +++ b/archiva-modules/archiva-web/archiva-rss/pom.xml @@ -60,5 +60,10 @@ jcl-over-slf4j test + + org.springframework + spring-test + test + diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java index 6281df9ed..af2433968 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java +++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/RssFeedGenerator.java @@ -31,15 +31,19 @@ import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndEntryImpl; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndFeedImpl; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; /** * Generates RSS feeds. * - * @plexus.component role="org.apache.archiva.rss.RssFeedGenerator" + * plexus.component role="org.apache.archiva.rss.RssFeedGenerator" * instantiation-strategy="per-lookup" * * @version */ +@Service("rssFeedGenerator#default") +@Scope("prototype") public class RssFeedGenerator { private Logger log = LoggerFactory.getLogger( RssFeedGenerator.class ); @@ -65,7 +69,7 @@ public class RssFeedGenerator feed.setFeedType( DEFAULT_FEEDTYPE ); feed.setEntries( getEntries( dataEntries ) ); - log.debug( "Finished generating the feed \'" + title + "\'." ); + log.debug( "Finished generating the feed \'{}\'.", title ); return feed; } diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java index bac85d9c1..0f2b7d593 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java +++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java @@ -28,7 +28,9 @@ import org.apache.archiva.rss.RssFeedEntry; import org.apache.archiva.rss.RssFeedGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import javax.inject.Inject; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -41,8 +43,9 @@ import java.util.TimeZone; * The artifacts will be grouped by the date when the artifacts were gathered. * Each group will appear as one entry in the feed. * - * @plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-artifacts" + * plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-artifacts" */ +@Service("rssFeedProcessor#new-artifacts") public class NewArtifactsRssFeedProcessor extends AbstractArtifactsRssFeedProcessor { @@ -53,8 +56,9 @@ public class NewArtifactsRssFeedProcessor private static final String desc = "These are the new artifacts found in the repository "; /** - * @plexus.requirement + * plexus.requirement */ + @Inject private RssFeedGenerator generator; private Logger log = LoggerFactory.getLogger( NewArtifactsRssFeedProcessor.class ); diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java index b731b4f43..4757c2855 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java +++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java @@ -29,7 +29,9 @@ import org.apache.archiva.rss.RssFeedEntry; import org.apache.archiva.rss.RssFeedGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import javax.inject.Inject; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -41,8 +43,9 @@ import java.util.Map; * generate a rss feed. The versions will be grouped by the date when the artifact * was gathered. Each group will appear as one entry in the feed. * - * @plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-versions" + * plexus.component role="org.apache.archiva.rss.processor.RssFeedProcessor" role-hint="new-versions" */ +@Service("rssFeedProcessor#new-versions") public class NewVersionsOfArtifactRssFeedProcessor extends AbstractArtifactsRssFeedProcessor { @@ -53,8 +56,9 @@ public class NewVersionsOfArtifactRssFeedProcessor private static final String desc = "These are the new versions of artifact "; /** - * @plexus.requirement + * plexus.requirement */ + @Inject private RssFeedGenerator generator; /** diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rss/src/main/resources/META-INF/spring-context.xml new file mode 100755 index 000000000..038b04481 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rss/src/main/resources/META-INF/spring-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java index 660a592f7..0eb01b01a 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/RssFeedGeneratorTest.java @@ -19,32 +19,41 @@ package org.apache.archiva.rss; * under the License. */ +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import javax.inject.Inject; import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndFeed; - /** * @version */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml"} ) public class RssFeedGeneratorTest - extends PlexusInSpringTestCase + extends TestCase { + @Inject private RssFeedGenerator generator; + @Before public void setUp() throws Exception { super.setUp(); - generator = (RssFeedGenerator) lookup( RssFeedGenerator.class ); } @SuppressWarnings("unchecked") + @Test public void testNewFeed() throws Exception { @@ -81,7 +90,8 @@ public class RssFeedGeneratorTest assertEquals( "Item 2", syndEntries.get( 1 ).getTitle() ); assertEquals( "Item 3", syndEntries.get( 2 ).getTitle() ); } - + + @Test public void testNoDataEntries() throws Exception { diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java index dc6f11568..1636f27c7 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java @@ -21,6 +21,7 @@ package org.apache.archiva.rss.processor; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; +import junit.framework.TestCase; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.ProjectMetadata; @@ -29,7 +30,10 @@ import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataResolutionException; import org.apache.archiva.rss.RssFeedGenerator; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.util.ArrayList; import java.util.Calendar; @@ -40,8 +44,9 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; +@RunWith( JUnit4.class ) public class NewArtifactsRssFeedProcessorTest - extends PlexusInSpringTestCase + extends TestCase { private static final String TEST_REPO = "test-repo"; @@ -49,7 +54,7 @@ public class NewArtifactsRssFeedProcessorTest private MetadataRepositoryMock metadataRepository; - @Override + @Before public void setUp() throws Exception { @@ -62,6 +67,7 @@ public class NewArtifactsRssFeedProcessorTest } @SuppressWarnings( "unchecked" ) + @Test public void testProcess() throws Exception { diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java index e36312b2b..846c2011b 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java @@ -21,11 +21,15 @@ package org.apache.archiva.rss.processor; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; +import junit.framework.TestCase; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.rss.RssFeedGenerator; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.util.Arrays; import java.util.Collections; @@ -34,8 +38,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +@RunWith( JUnit4.class ) public class NewVersionsOfArtifactRssFeedProcessorTest - extends PlexusInSpringTestCase + extends TestCase { private NewVersionsOfArtifactRssFeedProcessor newVersionsProcessor; @@ -49,7 +54,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest private MetadataRepository metadataRepository; - @Override + @Before public void setUp() throws Exception { @@ -63,6 +68,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest } @SuppressWarnings( "unchecked" ) + @Test public void testProcess() throws Exception {