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 assertTrue( "result.getArchetypes().size() = " + result.getArchetypes().size() 46 + " should be in [5,8], result = " + result, 47 ( 5 <= result.getArchetypes().size() ) && ( result.getArchetypes().size() <= 8 ) ); 48 49 // TODO: should write to another directory 50 // instance.writeCatalog(result, new File(repository, "archetype-catalog.xml")); 51 } 52 53 // public void testCrawl2 () 54 // throws Exception 55 // { 56 // System.out.println ( "\n\n\n\n\n\ncrawl2" ); 57 // 58 // File repository = new File("/home/rafale/.m2/repository"); 59 // //getTestFile ( "target/test-classes/repositories/central" ); 60 // RepositoryCrawler instance = 61 // (RepositoryCrawler) lookup ( RepositoryCrawler.class.getName () ); 62 // 63 // ArchetypeCatalog expResult = null; 64 // ArchetypeCatalog result = instance.crawl ( repository ); 65 // System.err.println("result = "+result); 66 // assertEquals ( expResult, result ); 67 // // TODO review the generated test code and remove the default call to fail. 68 //// fail ( "The test case is a prototype." ); 69 // } 70 }