mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-22 15:12:38 +00:00
MNT-16375 "CMISChangelog auditing enablement impacts CMIS connection if quantity records are excessive" replace use of template.select with template.selectList (to prevent MySQL streaming exceptions), fix up affected client classes, and add extra AuditDAOTests around audit query fromId, toId, fromTime, toTime and maxResults
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129387 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -419,7 +419,7 @@ public class AuditComponentTest extends TestCase
|
||||
|
||||
sb.delete(0, sb.length());
|
||||
rowCount.setValue(0);
|
||||
auditComponent.auditQuery(callback, params, -1);
|
||||
auditComponent.auditQuery(callback, params, Integer.MAX_VALUE);
|
||||
assertTrue("Expected some data", rowCount.intValue() > 0);
|
||||
logger.debug(sb.toString());
|
||||
int allResults = rowCount.intValue();
|
||||
@@ -435,7 +435,7 @@ public class AuditComponentTest extends TestCase
|
||||
sb.delete(0, sb.length());
|
||||
rowCount.setValue(0);
|
||||
params.setToTime(beforeTime);
|
||||
auditComponent.auditQuery(callback, params, -1);
|
||||
auditComponent.auditQuery(callback, params, Integer.MAX_VALUE);
|
||||
params.setToTime(null);
|
||||
logger.debug(sb.toString());
|
||||
int resultsBefore = rowCount.intValue();
|
||||
@@ -444,7 +444,7 @@ public class AuditComponentTest extends TestCase
|
||||
sb.delete(0, sb.length());
|
||||
rowCount.setValue(0);
|
||||
params.setFromTime(beforeTime);
|
||||
auditComponent.auditQuery(callback, params, -1);
|
||||
auditComponent.auditQuery(callback, params, Integer.MAX_VALUE);
|
||||
params.setFromTime(null);
|
||||
logger.debug(sb.toString());
|
||||
int resultsAfter = rowCount.intValue();
|
||||
@@ -456,7 +456,7 @@ public class AuditComponentTest extends TestCase
|
||||
sb.delete(0, sb.length());
|
||||
rowCount.setValue(0);
|
||||
params.setUser(user);
|
||||
auditComponent.auditQuery(callback, params, -1);
|
||||
auditComponent.auditQuery(callback, params, Integer.MAX_VALUE);
|
||||
params.setUser(null);
|
||||
assertTrue("Expected some data for specific user", rowCount.intValue() > 0);
|
||||
logger.debug(sb.toString());
|
||||
@@ -464,7 +464,7 @@ public class AuditComponentTest extends TestCase
|
||||
sb.delete(0, sb.length());
|
||||
rowCount.setValue(0);
|
||||
params.setUser("Numpty");
|
||||
auditComponent.auditQuery(callback, params, -1);
|
||||
auditComponent.auditQuery(callback, params, Integer.MAX_VALUE);
|
||||
params.setUser(null);
|
||||
assertTrue("Expected no data for bogus user", rowCount.intValue() == 0);
|
||||
logger.debug(sb.toString());
|
||||
@@ -607,7 +607,7 @@ public class AuditComponentTest extends TestCase
|
||||
clearAuditLog(APPLICATION_API_TEST);
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
logger.debug(sb.toString());
|
||||
assertTrue("There should be no audit entries for the API test after a clear", results.isEmpty());
|
||||
|
||||
@@ -641,7 +641,7 @@ public class AuditComponentTest extends TestCase
|
||||
// Check that the call was audited
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
logger.debug(sb.toString());
|
||||
assertFalse("Did not get any audit results after successful login", results.isEmpty());
|
||||
|
||||
@@ -672,7 +672,7 @@ public class AuditComponentTest extends TestCase
|
||||
{
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
if(results.size() == iterations)
|
||||
{
|
||||
break;
|
||||
@@ -690,11 +690,49 @@ public class AuditComponentTest extends TestCase
|
||||
"Clearing " + results.size() + " entries by ID took " + (System.currentTimeMillis() - before) + "ms.");
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
logger.debug(sb.toString());
|
||||
assertEquals("Explicit audit entries were not deleted", 0, results.size());
|
||||
}
|
||||
|
||||
|
||||
public void testAuditQuery_MinId() throws Exception
|
||||
{
|
||||
AuditQueryCallback auditQueryCallback = new AuditQueryCallback()
|
||||
{
|
||||
public boolean valuesRequired()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleAuditEntry(
|
||||
Long entryId,
|
||||
String applicationName,
|
||||
String user,
|
||||
long time,
|
||||
Map<String, Serializable> values)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(
|
||||
"Audit Entry " + entryId + ": " + applicationName + ", " + user + ", " + new Date(time) + "\n" +
|
||||
" Data: " + values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(errorMsg, error);
|
||||
}
|
||||
};
|
||||
|
||||
AuditQueryParameters params = new AuditQueryParameters();
|
||||
params.setApplicationName(APPLICATION_API_TEST);
|
||||
params.setForward(false);
|
||||
params.setToId(Long.MAX_VALUE);
|
||||
queryAuditLog(auditQueryCallback, params, 1);
|
||||
}
|
||||
|
||||
public void testAuditQuery_MaxId() throws Exception
|
||||
{
|
||||
AuditQueryCallback auditQueryCallback = new AuditQueryCallback()
|
||||
@@ -785,7 +823,7 @@ public class AuditComponentTest extends TestCase
|
||||
clearAuditLog(APPLICATION_ALF12638_TEST);
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
assertTrue("There should be no audit entries for the API test after a clear", results.isEmpty());
|
||||
|
||||
try
|
||||
@@ -801,7 +839,7 @@ public class AuditComponentTest extends TestCase
|
||||
boolean success = false;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
if (results.size() > 1)
|
||||
{
|
||||
logger.debug(sb.toString());
|
||||
@@ -936,7 +974,7 @@ public class AuditComponentTest extends TestCase
|
||||
clearAuditLog(APPLICATION_MNT10767_TEST);
|
||||
results.clear();
|
||||
sb.delete(0, sb.length());
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
assertTrue("There should be no audit entries for the API test after a clear", results.isEmpty());
|
||||
|
||||
PolicyComponent policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
|
||||
@@ -955,7 +993,7 @@ public class AuditComponentTest extends TestCase
|
||||
boolean success = false;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
queryAuditLog(auditQueryCallback, params, -1);
|
||||
queryAuditLog(auditQueryCallback, params, Integer.MAX_VALUE);
|
||||
if (results.size() > 1)
|
||||
{
|
||||
logger.debug(sb.toString());
|
||||
|
||||
Reference in New Issue
Block a user