mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)
137899 aforascu: REPO-1785 / REPO-2585 - Retrieve Audit Application info - added a negative test (501 response code) for testGetAuditApp() Junit - added AuditTest class as an extra layer for methods and objects common to audit Junits (e.g enabling / disabling system audit) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137963 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
69
source/test-java/org/alfresco/rest/api/tests/AuditTest.java
Normal file
69
source/test-java/org/alfresco/rest/api/tests/AuditTest.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.alfresco.rest.AbstractSingleNetworkSiteTest;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
* Added as an extra layer for Rest-Api Audit methods and objects that can be used by all junits
|
||||
* E.g enableSystemAudit, disableSystemAudit
|
||||
*
|
||||
*/
|
||||
|
||||
public class AuditTest extends AbstractSingleNetworkSiteTest
|
||||
{
|
||||
protected PermissionService permissionService;
|
||||
protected AuthorityService authorityService;
|
||||
protected AuditService auditService;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception
|
||||
{
|
||||
super.setup();
|
||||
|
||||
permissionService = applicationContext.getBean("permissionService", PermissionService.class);
|
||||
authorityService = (AuthorityService) applicationContext.getBean("AuthorityService");
|
||||
auditService = applicationContext.getBean("AuditService", AuditService.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void enableSystemAudit()
|
||||
{
|
||||
boolean isEnabled = auditService.isAuditEnabled();
|
||||
if (!isEnabled)
|
||||
{
|
||||
auditService.setAuditEnabled(true);
|
||||
isEnabled = auditService.isAuditEnabled();
|
||||
if (!isEnabled)
|
||||
{
|
||||
fail("Failed to enable system audit for testing");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void disableSystemAudit()
|
||||
{
|
||||
boolean isEnabled = auditService.isAuditEnabled();
|
||||
if (isEnabled)
|
||||
{
|
||||
auditService.setAuditEnabled(false);
|
||||
isEnabled = auditService.isAuditEnabled();
|
||||
if (isEnabled)
|
||||
{
|
||||
fail("Failed to disable system audit for testing");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user