1 package org.apache.maven.archetype.source;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
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 }