1 package org.apache.archiva.rss.processor;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.apache.archiva.rss.RssFeedGenerator;
27 import org.apache.maven.archiva.model.ArchivaArtifact;
28 import org.codehaus.plexus.PlexusTestCase;
31 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
34 public class NewArtifactsRssFeedProcessorTest
35 extends PlexusTestCase
37 private RssFeedProcessor newArtifactsProcessor;
39 private String rssDirectory;
46 newArtifactsProcessor = (RssFeedProcessor) lookup( RssFeedProcessor.class, "new-artifacts" );
47 rssDirectory = getBasedir() + "/target/test-classes/rss-feeds/";
49 RssFeedGenerator generator = ( ( NewArtifactsRssFeedProcessor ) newArtifactsProcessor ).getGenerator();
50 generator.setRssDirectory( rssDirectory );
51 ( (NewArtifactsRssFeedProcessor) newArtifactsProcessor ).setGenerator( generator );
54 public void testProcess()
57 List<ArchivaArtifact> newArtifacts = new ArrayList<ArchivaArtifact>();
59 ArchivaArtifact artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-one", "1.0", "", "jar" );
60 artifact.getModel().setRepositoryId( "test-repo" );
61 newArtifacts.add( artifact );
63 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-one", "1.1", "", "jar" );
64 artifact.getModel().setRepositoryId( "test-repo" );
65 newArtifacts.add( artifact );
67 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-one", "2.0", "", "jar" );
68 artifact.getModel().setRepositoryId( "test-repo" );
69 newArtifacts.add( artifact );
71 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-two", "1.0.1", "", "jar" );
72 artifact.getModel().setRepositoryId( "test-repo" );
73 newArtifacts.add( artifact );
75 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-two", "1.0.2", "", "jar" );
76 artifact.getModel().setRepositoryId( "test-repo" );
77 newArtifacts.add( artifact );
79 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-two", "1.0.3-SNAPSHOT", "", "jar" );
80 artifact.getModel().setRepositoryId( "test-repo" );
81 newArtifacts.add( artifact );
83 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-three", "2.0-SNAPSHOT", "", "jar" );
84 artifact.getModel().setRepositoryId( "test-repo" );
85 newArtifacts.add( artifact );
87 artifact = new ArchivaArtifact( "org.apache.archiva", "artifact-four", "1.1-beta-2", "", "jar" );
88 artifact.getModel().setRepositoryId( "test-repo" );
89 newArtifacts.add( artifact );
91 newArtifactsProcessor.process( newArtifacts );
93 File outputFile = new File( rssDirectory, "new_artifacts_test-repo.xml" );
94 assertTrue( outputFile.exists() );
96 outputFile = new File( rssDirectory, "new_versions_test-repo_org.apache.archiva:artifact-one.xml" );
97 assertTrue( outputFile.exists() );
99 outputFile = new File( rssDirectory, "new_versions_test-repo_org.apache.archiva:artifact-two.xml" );
100 assertTrue( outputFile.exists() );
102 outputFile = new File( rssDirectory, "new_versions_test-repo_org.apache.archiva:artifact-three.xml" );
103 assertTrue( outputFile.exists() );
105 outputFile = new File( rssDirectory, "new_versions_test-repo_org.apache.archiva:artifact-four.xml" );
106 assertTrue( outputFile.exists() );