View Javadoc

1   package org.apache.maven.archetype.source;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.apache.maven.archetype.catalog.Archetype;
23  import org.apache.maven.archetype.catalog.ArchetypeCatalog;
24  import org.codehaus.plexus.PlexusTestCase;
25  
26  import java.io.File;
27  import java.util.Properties;
28  
29  /** @author Jason van Zyl */
30  public class WikiArchetypeDataSourceTest
31      extends PlexusTestCase
32  {
33      private static final String[][] REFERENCE =
34          {
35              { "appfuse-basic-jsf", "org.appfuse.archetypes", "2.0", "http://static.appfuse.org/releases",
36                  "AppFuse archetype for creating a web application with Hibernate, Spring and JSF" },
37              { "maven-archetype-profiles", "org.apache.maven.archetypes", "RELEASE", "http://repo1.maven.org/maven2", "" },
38              { "struts2-archetype-starter", "org.apache.struts", "2.0.9-SNAPSHOT",
39                  "http://people.apache.org/repo/m2-snapshot-repository",
40                  "A starter Struts 2 application with Sitemesh, DWR, and Spring" },
41              { "maven-archetype-har", "net.sf.maven-har", "0.9", "", "Hibernate Archive" },
42              { "maven-archetype-archetype", "org.apache.maven.archetypes", "RELEASE", "", "" }
43          };
44  
45      public void testWikiArchetypeDataSource()
46          throws Exception
47      {
48          File wikiSource = new File( getBasedir(), "src/test/resources/wiki/wiki-source.txt" );
49  
50          assertTrue( wikiSource.exists() );
51  
52          Properties p = new Properties();
53          p.put( "url", wikiSource.toURL().toExternalForm() );
54  
55          ArchetypeDataSource ads = new WikiArchetypeDataSource();
56  
57          ArchetypeCatalog catalog = ads.getArchetypeCatalog( p );
58  
59          int catalogSize = catalog.getArchetypes().size();
60  
61          assertEquals( REFERENCE.length, catalogSize );
62  
63          for ( int i = 0; i < catalogSize; i++ )
64          {
65              String[] reference = REFERENCE[i];
66  
67              Archetype ar = (Archetype) catalog.getArchetypes().get( i );
68  
69              assertEquals( "#" + i + " artifactId", reference[0], ar.getArtifactId() );
70              assertEquals( "#" + i + " groupId", reference[1], ar.getGroupId() );
71              assertEquals( "#" + i + " version", reference[2], ar.getVersion() );
72              assertEquals( "#" + i + " repository", reference[3], ar.getRepository() );
73              assertEquals( "#" + i + " description", reference[4], ar.getDescription() );
74          }
75      }
76  }