]> source.dussan.org Git - archiva.git/commitdiff
more tests
authorOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:17:10 +0000 (22:17 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:17:10 +0000 (22:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1339395 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactContentEntryComparator.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java

index aa78a671edf8555a15ca6d577adca32e254aa358..8a782ba29a0fa0915c0a3270a9727069cd1152fb 100644 (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 ) );
                     }
                 }
             }
index dbfa115f028165969aefbb2f63c73e349ea60955..98a5498785f6897555510deb70314f6b256b3aac 100644 (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() );
     }
 }
index 7edaf5a7b4fe1662e6da8b9b57ecfacc7016b8cb..cf805f40c63e508b8017edfd9d12153070de927c 100644 (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 ) );
 
     }
 
index 9d3d03d86c1db40958a788fef4ccf118decc8062..43af4eb45c2587f124ff7eba6b0b5d7b269d3761 100644 (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 );
     }