aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins/audit/src/test
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-12-29 06:14:04 +0000
committerBrett Porter <brett@apache.org>2010-12-29 06:14:04 +0000
commitf56609efad6393b10c861446ec11ddda00f9a218 (patch)
tree05aad2cd341eff4c2c1e3397e8a93570ef27bcfc /archiva-modules/plugins/audit/src/test
parenta44b2ac9dd664f3a93e2a7001afd507abb218110 (diff)
downloadarchiva-f56609efad6393b10c861446ec11ddda00f9a218.tar.gz
archiva-f56609efad6393b10c861446ec11ddda00f9a218.zip
[MRM-1330] refactor access around the concept of a "repository session". See Javadoc for some notes. This should be a single entry point for application users of either the metadata repository, resolution, or storage access. The session needs to be explicitly closed (and modifications saved) to facilitate some storage mechanisms.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1053542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/audit/src/test')
-rw-r--r--archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java54
1 files changed, 27 insertions, 27 deletions
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 2ac2ddcc0..7602511ac 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
@@ -78,7 +78,6 @@ public class AuditManagerTest
metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
- auditManager.setMetadataRepository( metadataRepository );
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
repository.setId( TEST_REPO_ID );
@@ -108,7 +107,8 @@ public class AuditManagerTest
}
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getMostRecentAuditEvents( Collections.singletonList( TEST_REPO_ID ) );
+ List<AuditEvent> events = auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ) );
assertNotNull( events );
assertEquals( numEvents - 1, events.size() );
int expectedTimestampCounter = numEvents - 1;
@@ -144,7 +144,8 @@ public class AuditManagerTest
}
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getMostRecentAuditEvents( Collections.singletonList( TEST_REPO_ID ) );
+ List<AuditEvent> events = auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ) );
assertNotNull( events );
assertEquals( numEvents, events.size() );
int expectedTimestampCounter = numEvents - 1;
@@ -190,7 +191,8 @@ public class AuditManagerTest
}
metadataRepositoryControl.replay();
- events = auditManager.getMostRecentAuditEvents( Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ) );
+ events = auditManager.getMostRecentAuditEvents( metadataRepository, Arrays.asList( TEST_REPO_ID,
+ TEST_REPO_ID_2 ) );
assertNotNull( events );
assertEquals( numEvents - 1, events.size() );
int expectedTimestampCounter = numEvents - 1;
@@ -214,7 +216,8 @@ public class AuditManagerTest
Collections.emptyList() );
metadataRepositoryControl.replay();
- assertTrue( auditManager.getMostRecentAuditEvents( Collections.singletonList( TEST_REPO_ID ) ).isEmpty() );
+ assertTrue( auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ) ).isEmpty() );
metadataRepositoryControl.verify();
}
@@ -229,7 +232,7 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- auditManager.addAuditEvent( event );
+ auditManager.addAuditEvent( metadataRepository, event );
metadataRepositoryControl.verify();
}
@@ -244,7 +247,7 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- auditManager.addAuditEvent( event );
+ auditManager.addAuditEvent( metadataRepository, event );
metadataRepositoryControl.verify();
}
@@ -257,7 +260,7 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- auditManager.deleteAuditEvents( TEST_REPO_ID );
+ auditManager.deleteAuditEvents( metadataRepository, TEST_REPO_ID );
metadataRepositoryControl.verify();
}
@@ -286,9 +289,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- new Date( current.getTime() - 4000 ), new Date(
- current.getTime() - 2000 ) );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), new Date( current.getTime() - 4000 ), new Date( current.getTime() - 2000 ) );
assertEquals( 1, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( expectedTimestamp ), expectedEvent.getResource() );
@@ -323,8 +325,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- new Date( current.getTime() - 4000 ), current );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), new Date( current.getTime() - 4000 ), current );
assertEquals( 2, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -360,9 +362,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- new Date( current.getTime() - 20000 ), new Date(
- current.getTime() - 2000 ) );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), new Date( current.getTime() - 20000 ), new Date( current.getTime() - 2000 ) );
assertEquals( 2, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( expectedTimestamp ), expectedEvent2.getResource() );
@@ -403,8 +404,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- new Date( current.getTime() - 20000 ), current );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), new Date( current.getTime() - 20000 ), current );
assertEquals( 3, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -447,9 +448,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- TEST_RESOURCE_BASE, new Date(
- current.getTime() - 20000 ), current );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), TEST_RESOURCE_BASE, new Date( current.getTime() - 20000 ), current );
assertEquals( 2, events.size() );
assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -489,8 +489,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ), "foo",
- new Date( current.getTime() - 20000 ), current );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), "foo", new Date( current.getTime() - 20000 ), current );
assertEquals( 0, events.size() );
@@ -533,7 +533,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ),
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Arrays.asList( TEST_REPO_ID,
+ TEST_REPO_ID_2 ),
new Date( current.getTime() - 20000 ), current );
assertEquals( 3, events.size() );
@@ -561,9 +562,8 @@ public class AuditManagerTest
metadataRepositoryControl.replay();
- List<AuditEvent> events = auditManager.getAuditEventsInRange( Collections.singletonList( TEST_REPO_ID ),
- new Date( current.getTime() - 20000 ), new Date(
- current.getTime() - 16000 ) );
+ List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
+ TEST_REPO_ID ), new Date( current.getTime() - 20000 ), new Date( current.getTime() - 16000 ) );
assertEquals( 0, events.size() );