Browse Source

cleanup formatting, and force all paths to use '/' so it works on Windows and Unix

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@359981 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-0.9-alpha-1
Brett Porter 18 years ago
parent
commit
80fd208935

+ 71
- 62
maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java View File

@@ -25,74 +25,83 @@ import org.codehaus.plexus.PlexusTestCase;
/**
* This class tests the DefaultMetadataDiscoverer class.
*/
public class DefaultMetadataDiscovererTest extends PlexusTestCase {
private MetadataDiscoverer discoverer;
public class DefaultMetadataDiscovererTest
extends PlexusTestCase
{
private MetadataDiscoverer discoverer;

private File repositoryLocation;
private File repositoryLocation;

/**
*
*/
public void setUp() throws Exception {
super.setUp();
/**
*
*/
public void setUp()
throws Exception
{
super.setUp();

discoverer = (MetadataDiscoverer) lookup(MetadataDiscoverer.ROLE,
"default");
repositoryLocation = getTestFile("src/test/repository");
}
discoverer = (MetadataDiscoverer) lookup( MetadataDiscoverer.ROLE, "default" );
repositoryLocation = getTestFile( "src/test/repository" );
}

/**
*
*/
public void tearDown() throws Exception {
super.tearDown();
discoverer = null;
}
/**
*
*/
public void tearDown()
throws Exception
{
super.tearDown();
discoverer = null;
}

/**
* Test DefaultMetadataDiscoverer when the all metadata paths are valid.
*
*/
public void testMetadataDiscovererSuccess() {
List metadataPaths = discoverer.discoverMetadata(repositoryLocation,
null);
assertNotNull("Check metadata not null", metadataPaths);
assertTrue(metadataPaths.size() == 3);
}
/**
* Test DefaultMetadataDiscoverer when the all metadata paths are valid.
*/
public void testMetadataDiscovererSuccess()
{
List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
assertNotNull( "Check metadata not null", metadataPaths );
assertTrue( metadataPaths.size() == 3 );
}

/**
* Test if metadata file in wrong directory was added to the kickedOutPaths.
*/
public void testKickoutWrongDirectory() {
List metadataPaths = discoverer.discoverMetadata(repositoryLocation,
null);
Iterator iter = discoverer.getKickedOutPathsIterator();
boolean found = false;
while (iter.hasNext() && !found) {
String dir = (String) iter.next();
if (dir.equals("javax\\maven-metadata-repository.xml")) {
found = true;
}
}
assertTrue(found);
}
/**
* Test if metadata file in wrong directory was added to the kickedOutPaths.
*/
public void testKickoutWrongDirectory()
{
List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
Iterator iter = discoverer.getKickedOutPathsIterator();
boolean found = false;
while ( iter.hasNext() && !found )
{
String dir = (String) iter.next();
String normalizedDir = dir.replace( '\\', '/' );
if ( "javax/maven-metadata-repository.xml".equals( normalizedDir ) )
{
found = true;
}
}
assertTrue( found );
}

/**
* Test if blank metadata file was added to the kickedOutPaths.
*/
public void testKickoutBlankMetadata() {
List metadataPaths = discoverer.discoverMetadata(repositoryLocation,
null);
Iterator iter = discoverer.getKickedOutPathsIterator();
boolean found = false;
while (iter.hasNext() && !found) {
String dir = (String) iter.next();
if (dir
.equals("org\\apache\\maven\\some-ejb\\1.0\\maven-metadata-repository.xml")) {
found = true;
}
}
assertTrue(found);
}
/**
* Test if blank metadata file was added to the kickedOutPaths.
*/
public void testKickoutBlankMetadata()
{
List metadataPaths = discoverer.discoverMetadata( repositoryLocation, null );
Iterator iter = discoverer.getKickedOutPathsIterator();
boolean found = false;
while ( iter.hasNext() && !found )
{
String dir = (String) iter.next();
String normalizedDir = dir.replace( '\\', '/' );
if ( "org/apache/maven/some-ejb/1.0/maven-metadata-repository.xml".equals( normalizedDir ) )
{
found = true;
}
}
assertTrue( found );
}

}

Loading…
Cancel
Save