summaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/audit/src
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-02-16 09:48:16 +0000
committerBrett Porter <brett@apache.org>2010-02-16 09:48:16 +0000
commitec255eb8ee3c41c39c7c1a3fb655d2133c0623f9 (patch)
tree11946e4e0cd998b2a787d0048c78d806ef2681f8 /archiva-modules/plugins/audit/src
parentcad485de242900f1ed7aa5d48b0ee3dafc173c7f (diff)
downloadarchiva-ec255eb8ee3c41c39c7c1a3fb655d2133c0623f9.tar.gz
archiva-ec255eb8ee3c41c39c7c1a3fb655d2133c0623f9.zip
avoid timing issues with audit logs
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@910447 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/audit/src')
-rw-r--r--archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java6
-rw-r--r--archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java16
2 files changed, 12 insertions, 10 deletions
diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
index 96065838e..1a5b1ef18 100644
--- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
+++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java
@@ -57,10 +57,10 @@ public class DefaultAuditManager
List<AuditRecord> records = new ArrayList<AuditRecord>();
for ( String repositoryId : repositoryIds )
{
- List<String> timestamps = metadataRepository.getMetadataFacets( repositoryId, AuditEvent.FACET_ID );
- for ( String timestamp : timestamps )
+ List<String> names = metadataRepository.getMetadataFacets( repositoryId, AuditEvent.FACET_ID );
+ for ( String name : names )
{
- records.add( new AuditRecord( repositoryId, timestamp ) );
+ records.add( new AuditRecord( repositoryId, name ) );
}
}
Collections.sort( records );
diff --git a/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
index 3825ed062..f70f7b04f 100644
--- a/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
+++ b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
@@ -178,10 +178,11 @@ public class AuditManagerTest
eventNames.put( TEST_REPO_ID_2, new ArrayList<String>() );
for ( int i = 0; i < numEvents; i++ )
{
- String name = createEventName( TIMESTAMP_FORMAT.parse( AUDIT_EVENT_BASE + MILLIS_FORMAT.format( i ) ) );
String repositoryId = i % 2 == 0 ? TEST_REPO_ID : TEST_REPO_ID_2;
- eventNames.get( repositoryId ).add( name );
- events.add( createTestEvent( repositoryId, name ) );
+ String num = MILLIS_FORMAT.format( i );
+ AuditEvent event = createEvent( repositoryId, AUDIT_EVENT_BASE + num, getDefaultTestResourceName( num ) );
+ events.add( event );
+ eventNames.get( repositoryId ).add( event.getName() );
}
metadataRepositoryControl.expectAndReturn(
@@ -551,10 +552,10 @@ public class AuditManagerTest
}
private static String createEventName( Date timestamp )
+ throws ParseException
{
- AuditEvent event = new AuditEvent();
- event.setTimestamp( timestamp );
- return event.getName();
+ // TODO: I think we can reverse the calls.
+ return createEvent( TEST_REPO_ID, TIMESTAMP_FORMAT.format( timestamp ), null ).getName();
}
private static AuditEvent createTestEvent( String name )
@@ -566,7 +567,8 @@ public class AuditManagerTest
private static AuditEvent createTestEvent( String repoId, String name )
throws ParseException
{
- return createEvent( repoId, name, getDefaultTestResourceName( name.substring( name.length() - 3 ) ) );
+ return createEvent( repoId, name, getDefaultTestResourceName(
+ name.substring( AUDIT_EVENT_BASE.length(), AUDIT_EVENT_BASE.length() + 3 ) ) );
}
private static AuditEvent createEvent( String repositoryId, String timestamp, String resource )