summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-12-04 01:18:13 +0000
committerBrett Porter <brett@apache.org>2009-12-04 01:18:13 +0000
commit58b9f885e0ef21c05ad9f43b8d9a8793d0b2756b (patch)
treecc0806802c3d633c43dd5cc1943be5e6bbaf6152
parent3e47fdca1a98f346cc6a74a5fdb054c815bd17e0 (diff)
downloadarchiva-58b9f885e0ef21c05ad9f43b8d9a8793d0b2756b.tar.gz
archiva-58b9f885e0ef21c05ad9f43b8d9a8793d0b2756b.zip
improve test case to check stats
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@887026 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
index 1438af0a5..0c0825884 100644
--- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
@@ -33,6 +33,7 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint;
+import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
@@ -194,19 +195,20 @@ public class ArchivaRepositoryScanningTaskExecutorTest
RepositoryContentStatistics stats = new RepositoryContentStatistics();
stats.setDuration( 1234567 );
- stats.setNewFileCount( 8 );
+ stats.setNewFileCount( 31 );
stats.setRepositoryId( TEST_REPO_ID );
stats.setTotalArtifactCount( 8 );
- stats.setTotalFileCount( 8 );
+ stats.setTotalFileCount( 31 );
stats.setTotalGroupCount( 3 );
stats.setTotalProjectCount( 5 );
- stats.setTotalSize( 999999 );
+ stats.setTotalSize( 38545 );
stats.setWhenGathered( Calendar.getInstance().getTime() );
dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( stats );
taskExecutor.executeTask( repoTask );
+ // check no artifacts processed
ArtifactDAO adao = dao.getArtifactDAO();
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
@@ -214,6 +216,19 @@ public class ArchivaRepositoryScanningTaskExecutorTest
assertEquals( "Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0,
unprocessedResultList.size() );
+ // check correctness of new stats
+ List<RepositoryContentStatistics> results =
+ (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( TEST_REPO_ID ) );
+ RepositoryContentStatistics newStats = results.get( 0 );
+ assertEquals( 0, newStats.getNewFileCount() );
+ assertEquals( TEST_REPO_ID, newStats.getRepositoryId() );
+ assertEquals( 31, newStats.getTotalFileCount() );
+ // TODO: can't test these as they weren't stored in the database
+// assertEquals( 8, newStats.getTotalArtifactCount() );
+// assertEquals( 3, newStats.getTotalGroupCount() );
+// assertEquals( 5, newStats.getTotalProjectCount() );
+ assertEquals( 38545, newStats.getTotalSize() );
+
File newArtifactGroup = new File( repoDir, "org/apache/archiva" );
FileUtils.copyDirectoryStructure( new File( getBasedir(), "target/test-classes/test-repo/org/apache/archiva" ),
@@ -234,6 +249,19 @@ public class ArchivaRepositoryScanningTaskExecutorTest
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
unprocessedResultList.size() );
+
+ // check correctness of new stats
+ results =
+ (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( TEST_REPO_ID ) );
+ RepositoryContentStatistics updatedStats = results.get( 0 );
+ assertEquals( 2, updatedStats.getNewFileCount() );
+ assertEquals( TEST_REPO_ID, updatedStats.getRepositoryId() );
+ assertEquals( 33, updatedStats.getTotalFileCount() );
+ // TODO: can't test these as they weren't stored in the database
+// assertEquals( 8, newStats.getTotalArtifactCount() );
+// assertEquals( 3, newStats.getTotalGroupCount() );
+// assertEquals( 5, newStats.getTotalProjectCount() );
+ assertEquals( 43687, updatedStats.getTotalSize() );
}
public void testExecutorForceScanAll()