Browse Source

more tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1339395 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-1.4-M3
Olivier Lamy 12 years ago
parent
commit
ff8de40f52

+ 2
- 2
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java View File

@@ -681,7 +681,7 @@ public class DefaultBrowseService

artifactContentEntryMap.put( entryRootPath,
new ArtifactContentEntry( entryRootPath, !currentEntry.isDirectory(),
depth ) );
depth, true ) );
}
else
{
@@ -690,7 +690,7 @@ public class DefaultBrowseService
{
artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName,
!currentEntry.isDirectory(),
depth ) );
depth, true ) );
}
}
}

+ 1
- 1
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactContentEntryComparator.java View File

@@ -33,6 +33,6 @@ public class ArtifactContentEntryComparator
public int compare( ArtifactContentEntry artifactContentEntry, ArtifactContentEntry artifactContentEntry1 )
{
// include depth too in comparaison ?
return artifactContentEntry.getName().compareTo( artifactContentEntry1.getName() );
return artifactContentEntry.getText().compareTo( artifactContentEntry1.getText() );
}
}

+ 55
- 4
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java View File

@@ -50,6 +50,57 @@ public class ArtifactContentEntriesTests
return System.getProperty( "basedir" );
}

@Test
public void readArtifactContentEntriesRootPathNull()
throws Exception
{

File file = new File( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );

List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, null );

log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );

}

@Test
public void readArtifactContentEntriesRootPathEmpty()
throws Exception
{

File file = new File( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );

List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, "" );

log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );

}

@Test
public void readArtifactContentEntriesRootSlash()
throws Exception
{

File file = new File( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );

List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, "/" );

log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );

}

@Test
public void readArtifactContentEntriesSecondDepthOnlyOneDirectory()
throws Exception
@@ -63,7 +114,7 @@ public class ArtifactContentEntriesTests
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
new ArtifactContentEntry( "org/apache", false, 1 ) );
new ArtifactContentEntry( "org/apache", false, 1, true ) );

}

@@ -81,7 +132,7 @@ public class ArtifactContentEntriesTests
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 16 ).contains(
new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5 ) );
new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5, true ) );

}

@@ -99,8 +150,8 @@ public class ArtifactContentEntriesTests
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );

}


+ 4
- 4
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java View File

@@ -246,7 +246,7 @@ public class BrowseServiceTest
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
new ArtifactContentEntry( "org", false, 0,true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
deleteTestRepo( testRepoId );
}

@@ -272,7 +272,7 @@ public class BrowseServiceTest
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
new ArtifactContentEntry( "org/apache", false, 1 ) );
new ArtifactContentEntry( "org/apache", false, 1, true ) );
deleteTestRepo( testRepoId );
}

@@ -298,8 +298,8 @@ public class BrowseServiceTest
log.info( "artifactContentEntries: {}", artifactContentEntries );

assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );
deleteTestRepo( testRepoId );
}


Loading…
Cancel
Save