1 package org.apache.maven.repository.discovery;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.codehaus.plexus.PlexusTestCase;
22 import java.util.Iterator;
23 import java.util.List;
26 * This class tests the DefaultMetadataDiscoverer class.
28 public class DefaultMetadataDiscovererTest
29 extends PlexusTestCase
31 private MetadataDiscoverer discoverer;
33 private File repositoryLocation;
43 discoverer = (MetadataDiscoverer) lookup( MetadataDiscoverer.ROLE, "default" );
44 repositoryLocation = getTestFile( "src/test/repository" );
50 public void tearDown()
58 * Test DefaultMetadataDiscoverer when the all metadata paths are valid.
60 public void testMetadataDiscovererSuccess()
62 List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
63 assertNotNull( "Check metadata not null", metadataPaths );
64 assertTrue( metadataPaths.size() == 3 );
68 * Test if metadata file in wrong directory was added to the kickedOutPaths.
70 public void testKickoutWrongDirectory()
72 List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
73 Iterator iter = discoverer.getKickedOutPathsIterator();
74 boolean found = false;
75 while ( iter.hasNext() && !found )
77 String dir = (String) iter.next();
78 String normalizedDir = dir.replace( '\\', '/' );
79 if ( "javax/maven-metadata-repository.xml".equals( normalizedDir ) )
88 * Test if blank metadata file was added to the kickedOutPaths.
90 public void testKickoutBlankMetadata()
92 List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
93 Iterator iter = discoverer.getKickedOutPathsIterator();
94 boolean found = false;
95 while ( iter.hasNext() && !found )
97 String dir = (String) iter.next();
98 String normalizedDir = dir.replace( '\\', '/' );
99 if ( "org/apache/maven/some-ejb/1.0/maven-metadata-repository.xml".equals( normalizedDir ) )