Author: cstamas
Date: Wed Mar 30 10:07:35 2011
New Revision: 1086889

URL: http://svn.apache.org/viewvc?rev=1086889&view=rev
Log:
NEXUS-4152: added UT covering the same issue

Modified:
    
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java

Modified: 
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
URL: 
http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java?rev=1086889&r1=1086888&r2=1086889&view=diff
==============================================================================
--- 
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
 (original)
+++ 
maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/packer/NEXUS4149TransferFormatTest.java
 Wed Mar 30 10:07:35 2011
@@ -4,6 +4,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.List;
 
 import junit.framework.Assert;
 
@@ -15,6 +16,7 @@ import org.apache.maven.index.context.In
 import org.apache.maven.index.context.MergedIndexingContext;
 import org.apache.maven.index.packer.IndexPackingRequest.IndexFormat;
 import org.apache.maven.index.updater.IndexDataReader;
+import org.codehaus.plexus.util.StringUtils;
 
 public class NEXUS4149TransferFormatTest
     extends AbstractNexusIndexerTest
@@ -49,9 +51,14 @@ public class NEXUS4149TransferFormatTest
                 "repo3" ), null, null, MIN_CREATORS );
         nexusIndexer.scan( ctx3 );
 
+        IndexingContext ctx4 =
+            nexusIndexer.addIndexingContext( "repo4", "repo4", new File( 
reposBase, "repo4" ), new File( idxsBase,
+                "repo4" ), null, null, MIN_CREATORS );
+        nexusIndexer.scan( ctx4 );
+
         context =
             nexusIndexer.addMergedIndexingContext( "ctx", "ctx", new File( 
reposBase, "merged" ), new File( idxsBase,
-                "merged" ), false, Arrays.asList( ctx1, ctx2, ctx3 ) );
+                "merged" ), false, Arrays.asList( ctx1, ctx2, ctx3, ctx4 ) );
 
         context.getIndexDirectoryFile().mkdirs();
     }
@@ -118,6 +125,8 @@ public class NEXUS4149TransferFormatTest
             int totalDocs = 0;
             int specialDocs = 0;
             int artifactDocs = 0;
+            String allGroups = null;
+            String rootGroups = null;
             Document doc;
             while ( ( doc = reader.readDocument() ) != null )
             {
@@ -126,6 +135,15 @@ public class NEXUS4149TransferFormatTest
                     || doc.getField( ArtifactInfo.ROOT_GROUPS ) != null )
                 {
                     specialDocs++;
+
+                    if ( doc.get( ArtifactInfo.ALL_GROUPS ) != null )
+                    {
+                        allGroups = doc.get( ArtifactInfo.ALL_GROUPS_LIST );
+                    }
+                    if ( doc.get( ArtifactInfo.ROOT_GROUPS ) != null )
+                    {
+                        rootGroups = doc.get( ArtifactInfo.ROOT_GROUPS_LIST );
+                    }
                 }
                 else
                 {
@@ -133,15 +151,35 @@ public class NEXUS4149TransferFormatTest
                 }
             }
 
+            Assert.assertNotNull( "Group transport file should contain 
allGroups!", allGroups );
+            Assert.assertNotNull( "Group transport file should contain 
rootGroups!", rootGroups );
+            checkListOfStringDoesNotContainEmptyString( ArtifactInfo.str2lst( 
allGroups ) );
+            checkListOfStringDoesNotContainEmptyString( ArtifactInfo.str2lst( 
rootGroups ) );
+
             Assert.assertEquals( 15, totalDocs );
             // 1 descriptor + 1 allGroups + 1 rootGroups
             Assert.assertEquals( 3, specialDocs );
             // repo1 has 1 artifact, repo2 has 1 artifact and repo3 has 10 
artifact
             Assert.assertEquals( 12, artifactDocs );
+
         }
         finally
         {
             fis.close();
         }
     }
+
+    protected void checkListOfStringDoesNotContainEmptyString( List<String> 
lst )
+    {
+        if ( lst != null )
+        {
+            for ( String str : lst )
+            {
+                if ( StringUtils.isBlank( str ) )
+                {
+                    throw new IllegalArgumentException( "List " + lst + " 
contains empty string!" );
+                }
+            }
+        }
+    }
 }


Reply via email to