1 package org.apache.maven.archetype.repositorycrawler; 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.ArchetypeCatalog; 23 import org.apache.maven.plugin.testing.AbstractMojoTestCase; 24 25 import java.io.File; 26 27 /** 28 * @author rafale 29 */ 30 public class DefaultRepositoryCrawlerTest 31 extends AbstractMojoTestCase 32 { 33 /** 34 * Test of crawl method, of class DefaultRepositoryCrawler. 35 */ 36 public void testCrawl() 37 throws Exception 38 { 39 System.out.println( "crawl" ); 40 41 File repository = getTestFile( "target/test-classes/repositories/central" ); 42 RepositoryCrawler instance = (RepositoryCrawler) lookup( RepositoryCrawler.class.getName() ); 43 44 ArchetypeCatalog result = instance.crawl( repository ); 45 System.err.println( "result = " + result ); 46 assertTrue( ( 5 <= result.getArchetypes().size() ) && ( result.getArchetypes().size() <= 8 ) ); 47 48 // TODO: should write to another directory 49 // instance.writeCatalog(result, new File(repository, "archetype-catalog.xml")); 50 } 51 52 // public void testCrawl2 () 53 // throws Exception 54 // { 55 // System.out.println ( "\n\n\n\n\n\ncrawl2" ); 56 // 57 // File repository = new File("/home/rafale/.m2/repository"); 58 // //getTestFile ( "target/test-classes/repositories/central" ); 59 // RepositoryCrawler instance = 60 // (RepositoryCrawler) lookup ( RepositoryCrawler.class.getName () ); 61 // 62 // ArchetypeCatalog expResult = null; 63 // ArchetypeCatalog result = instance.crawl ( repository ); 64 // System.err.println("result = "+result); 65 // assertEquals ( expResult, result ); 66 // // TODO review the generated test code and remove the default call to fail. 67 //// fail ( "The test case is a prototype." ); 68 // } 69 70 protected void tearDown() 71 throws Exception 72 { 73 super.tearDown(); 74 } 75 76 protected void setUp() 77 throws Exception 78 { 79 super.setUp(); 80 } 81 }