mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Minor Audit test changes
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16015 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.audit.model.AuditApplication;
|
||||
import org.alfresco.repo.audit.model._3.AuditPath;
|
||||
import org.alfresco.service.cmr.audit.AuditInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -87,32 +88,38 @@ public interface AuditComponent
|
||||
* the same root path.
|
||||
* <p/>
|
||||
* The name of the application controls part of the audit model will be used. The root path must
|
||||
* start with the matching <b>key</b> attribute that was declared for the matching
|
||||
* <b>Application</b> element in the audit configuration.
|
||||
* start with the path separator '/' ({@link AuditApplication#AUDIT_PATH_SEPARATOR}) and the matching
|
||||
* <b>key</b> attribute that was declared for the <b>Application</b> element in the audit configuration.
|
||||
* <p/>
|
||||
* This is a read-write method. Client code must wrap calls in the appropriate transactional wrappers.
|
||||
*
|
||||
* @param applicationName the name of the application to log against
|
||||
* @param rootPath a base path of {@link AuditPath} key entries concatenated with <b>.</b> (period)
|
||||
* @return Returns the unique session
|
||||
* @param rootPath a base path of {@link AuditPath} key entries concatenated with
|
||||
* {@link AuditApplication#AUDIT_PATH_SEPARATOR}.
|
||||
* @return Returns the unique session or <tt>null</tt> if no session was created
|
||||
* @throws IllegalStateException if there is not a writable transaction present
|
||||
*/
|
||||
AuditSession startAuditSession(String applicationName, String rootPath);
|
||||
|
||||
/**
|
||||
* {@inheritDoc #startAuditSession(String, String)}
|
||||
* {@inheritDoc AuditComponent#startAuditSession(String, String)}
|
||||
|
||||
* @param applicationName the name of the application to log against
|
||||
* @param rootPath a base path of {@link AuditPath} key entries concatenated with the path separator
|
||||
* '/' ({@link AuditApplication#AUDIT_PATH_SEPARATOR})
|
||||
* @param values values to associate with the session. These values will override or
|
||||
* complement generated session-specific values
|
||||
* @param rootPath a base path of {@link AuditPath} key entries concatenated with
|
||||
* {@link AuditApplication#AUDIT_PATH_SEPARATOR}.
|
||||
* @throws IllegalStateException if there is not a writable transaction present
|
||||
*/
|
||||
AuditSession startAuditSession(String applicationName, String rootPath, Map<String, Serializable> values);
|
||||
|
||||
/**
|
||||
* Record a set of values against the given session. The map is a path (starting with '/') relative
|
||||
* to the root path given when {@link #startAuditSession(String, String) starting the session}. All
|
||||
* resulting path values (session root path + map entry paths) must have data recorder entries and
|
||||
* be enabled for data to be recorded.
|
||||
* Record a set of values against the given session. The map is a path - starting with '/'
|
||||
* ({@link AuditApplication#AUDIT_PATH_SEPARATOR}), relative to the root path given when
|
||||
* {@link #startAuditSession(String, String) starting the session}. All resulting path values
|
||||
* (session root path + map entry paths) must have data recorder entries and be enabled for data to be recorded.
|
||||
* <p/>
|
||||
* The return values reflect what was actually persisted and is controlled by the data extractors
|
||||
* defined in the audit configuration.
|
||||
|
@@ -60,6 +60,7 @@ import org.springframework.util.ResourceUtils;
|
||||
public class AuditComponentTest extends TestCase
|
||||
{
|
||||
private static final String APPLICATION_TEST = "Alfresco Test";
|
||||
private static final String APPLICATION_ACTIONS_TEST = "Actions Test";
|
||||
|
||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
||||
@@ -206,8 +207,8 @@ public class AuditComponentTest extends TestCase
|
||||
{
|
||||
public Map<String, Serializable> execute() throws Throwable
|
||||
{
|
||||
String actionPath = AuditApplication.buildPath("test/actions", action);
|
||||
AuditSession session = auditComponent.startAuditSession(APPLICATION_TEST, actionPath);
|
||||
String actionPath = AuditApplication.buildPath("actions-test/actions", action);
|
||||
AuditSession session = auditComponent.startAuditSession(APPLICATION_ACTIONS_TEST, actionPath);
|
||||
|
||||
return auditComponent.audit(session, adjustedValues);
|
||||
}
|
||||
@@ -215,6 +216,9 @@ public class AuditComponentTest extends TestCase
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(auditCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to compare a 'results' map with a map of expected values
|
||||
*/
|
||||
private void checkAuditMaps(Map<String, Serializable> result, Map<String, Serializable> expected)
|
||||
{
|
||||
Map<String, Serializable> copyResult = new HashMap<String, Serializable>(result);
|
||||
@@ -275,10 +279,10 @@ public class AuditComponentTest extends TestCase
|
||||
Map<String, Serializable> result = auditTestAction("action-01", nodeRef, parameters);
|
||||
|
||||
Map<String, Serializable> expected = new HashMap<String, Serializable>();
|
||||
expected.put("/test/actions/action-01/context-node/noderef", nodeRef);
|
||||
expected.put("/test/actions/action-01/params/A/value", valueA);
|
||||
expected.put("/test/actions/action-01/params/B/value", valueB);
|
||||
expected.put("/test/actions/action-01/params/C/value", valueC);
|
||||
expected.put("/actions-test/actions/action-01/context-node/noderef", nodeRef);
|
||||
expected.put("/actions-test/actions/action-01/params/A/value", valueA);
|
||||
expected.put("/actions-test/actions/action-01/params/B/value", valueB);
|
||||
expected.put("/actions-test/actions/action-01/params/C/value", valueC);
|
||||
|
||||
// Check
|
||||
checkAuditMaps(result, expected);
|
||||
|
@@ -26,7 +26,6 @@ package org.alfresco.service.cmr.audit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.audit.AuditState;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -43,7 +42,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@PublicService
|
||||
public interface AuditService
|
||||
{
|
||||
|
||||
/**
|
||||
* Add an application audit entry.
|
||||
*
|
||||
|
@@ -64,6 +64,10 @@
|
||||
</AuditPath>
|
||||
</AuditPath>
|
||||
</AuditPath>
|
||||
</Application>
|
||||
|
||||
<Application name="Actions Test" key="actions-test">
|
||||
<GenerateValue key="time" dataGenerator="systemTime" scope="SESSION"/>
|
||||
<AuditPath key="actions">
|
||||
<AuditPath key="action-01">
|
||||
<AuditPath key="context-node">
|
||||
|
Reference in New Issue
Block a user