]> source.dussan.org Git - archiva.git/commitdiff
-added startTime variable to contain when the consumers were executed
authorMaria Odea B. Ching <oching@apache.org>
Mon, 28 Apr 2008 06:21:54 +0000 (06:21 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Mon, 28 Apr 2008 06:21:54 +0000 (06:21 +0000)
-added get and set method for the variable to be able to set it in the tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@652068 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumers.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryContentConsumersTest.java

index 549aba12abfc31c0f75c5b321e7e0c991a1edcb1..045ed6a8b54980ab871d339d18580e3b92ebcf5e 100644 (file)
@@ -71,6 +71,8 @@ public class RepositoryContentConsumers
     private List<KnownRepositoryContentConsumer> selectedKnownConsumers;
 
     private List<InvalidRepositoryContentConsumer> selectedInvalidConsumers;
+    
+    private Date startTime;
 
     /**
      * <p>
@@ -264,7 +266,7 @@ public class RepositoryContentConsumers
         // Run the repository consumers
         try
         {   
-            Closure triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ) );
+            Closure triggerBeginScan = new TriggerBeginScanClosure( repository, getStartTime() );
 
             List<KnownRepositoryContentConsumer> selectedKnownConsumers = getSelectedKnownConsumers();
             List<InvalidRepositoryContentConsumer> selectedInvalidConsumers = getSelectedInvalidConsumers();
@@ -307,4 +309,18 @@ public class RepositoryContentConsumers
     {
         this.selectedInvalidConsumers = selectedInvalidConsumers;
     }
+    
+    public void setStartTime( Date startTime )
+    {
+        this.startTime = startTime;
+    }
+    
+    public Date getStartTime()
+    {
+        if( startTime == null )
+        {
+            startTime = new Date( System.currentTimeMillis() );
+        }
+        return startTime;
+    }
 }
index e39878fce1c2f790ffae47a6f6e47bd261d8702b..06fd18abb3166377331eeb21a89fcb6a8ef50895 100644 (file)
@@ -29,6 +29,7 @@ import org.easymock.MockControl;
 import java.io.File;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -209,7 +210,9 @@ public class RepositoryContentConsumersTest
         ManagedRepositoryConfiguration repo = createRepository( "id", "name", getTestFile( "target/test-repo" ) );
         File testFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
 
-        selectedKnownConsumer.beginScan( repo, null );
+        Date startTime = new Date( System.currentTimeMillis() );
+        
+        selectedKnownConsumer.beginScan( repo, startTime );
         selectedKnownConsumer.getExcludes();
         knownControl.setReturnValue( Collections.EMPTY_LIST );
         selectedKnownConsumer.getIncludes();
@@ -218,10 +221,11 @@ public class RepositoryContentConsumersTest
         //        knownConsumer.completeScan();
         knownControl.replay();
 
-        selectedInvalidConsumer.beginScan( repo, null );
+        selectedInvalidConsumer.beginScan( repo, startTime );
         //        invalidConsumer.completeScan();
         invalidControl.replay();
 
+        consumers.setStartTime( startTime );
         consumers.executeConsumers( repo, testFile );
 
         knownControl.verify();
@@ -232,7 +236,7 @@ public class RepositoryContentConsumersTest
 
         File notIncludedTestFile = getTestFile( "target/test-repo/path/to/test-file.xml" );
 
-        selectedKnownConsumer.beginScan( repo, null );
+        selectedKnownConsumer.beginScan( repo, startTime );
         selectedKnownConsumer.getExcludes();
         knownControl.setReturnValue( Collections.EMPTY_LIST );
         selectedKnownConsumer.getIncludes();
@@ -240,7 +244,7 @@ public class RepositoryContentConsumersTest
         //        knownConsumer.completeScan();
         knownControl.replay();
 
-        selectedInvalidConsumer.beginScan( repo, null );
+        selectedInvalidConsumer.beginScan( repo, startTime );
         selectedInvalidConsumer.processFile( _OS( "path/to/test-file.xml" ) );
         selectedInvalidConsumer.getId();
         invalidControl.setReturnValue( "invalid" );
@@ -257,13 +261,13 @@ public class RepositoryContentConsumersTest
 
         File excludedTestFile = getTestFile( "target/test-repo/path/to/test-file.txt" );
 
-        selectedKnownConsumer.beginScan( repo, null );
+        selectedKnownConsumer.beginScan( repo, startTime );
         selectedKnownConsumer.getExcludes();
         knownControl.setReturnValue( Collections.singletonList( "**/test-file.txt" ) );
         //        knownConsumer.completeScan();
         knownControl.replay();
 
-        selectedInvalidConsumer.beginScan( repo, null );
+        selectedInvalidConsumer.beginScan( repo, startTime );
         selectedInvalidConsumer.processFile( _OS( "path/to/test-file.txt" ) );
         selectedInvalidConsumer.getId();
         invalidControl.setReturnValue( "invalid" );