Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)

119576 adavis: Merged 5.0.3 (5.0.3) to 5.0.N (5.0.4)
      119521 amukha: Merged 5.0.3-MNT-15258 (5.0.3) to 5.0.3 (5.0.3)
         118559 amukha: MNT-15258: Huge database after upgrade to 5.1.c
            - Added usage of JobLockService for prop cleanup job.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@119609 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2015-12-04 08:58:36 +00:00
parent 2021c3b0ec
commit 38ab389189
5 changed files with 167 additions and 25 deletions

View File

@@ -21,7 +21,6 @@ package org.alfresco.repo.attributes;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.alfresco.repo.domain.propval.PropertyValueDAO;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.CronTriggerBean;
import org.junit.Before;
@@ -57,7 +56,7 @@ public class PropTablesCleanupJobIntegrationTest
{
JobDetail jobDetail = jobTrigger.getJobDetail();
assertEquals(PropTablesCleanupJob.class, jobDetail.getJobClass());
assertTrue("JobDetail did not contain PropertyValueDAO reference",
jobDetail.getJobDataMap().get("propertyValueDAO") instanceof PropertyValueDAO);
assertTrue("JobDetail did not contain PropTablesCleaner reference",
jobDetail.getJobDataMap().get("propTablesCleaner") instanceof PropTablesCleaner);
}
}

View File

@@ -1,10 +1,9 @@
package org.alfresco.repo.attributes;
import static org.junit.Assert.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.alfresco.repo.domain.propval.PropertyValueDAO;
import org.alfresco.error.AlfrescoRuntimeException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -25,14 +24,14 @@ public class PropTablesCleanupJobTest
{
private PropTablesCleanupJob cleanupJob;
private @Mock JobExecutionContext jobCtx;
private @Mock PropertyValueDAO propValueDAO;
private @Mock PropTablesCleaner propTablesCleaner;
private JobDetail jobDetail;
@Before
public void setUp() throws Exception
{
jobDetail = new JobDetail("propTablesCleanupJob", PropTablesCleanupJob.class);
jobDetail.getJobDataMap().put(PropTablesCleanupJob.PROPERTY_VALUE_DAO_KEY, propValueDAO);
jobDetail.getJobDataMap().put("propTablesCleaner", propTablesCleaner);
cleanupJob = new PropTablesCleanupJob();
when(jobCtx.getJobDetail()).thenReturn(jobDetail);
@@ -43,20 +42,20 @@ public class PropTablesCleanupJobTest
{
cleanupJob.execute(jobCtx);
verify(propValueDAO).cleanupUnusedValues();
verify(propTablesCleaner).execute();
}
@Test(expected=IllegalArgumentException.class)
public void testMissingPropertyValueDAO() throws JobExecutionException
@Test(expected=AlfrescoRuntimeException.class)
public void testMissingPropTablesCleaner() throws JobExecutionException
{
jobDetail.getJobDataMap().put(PropTablesCleanupJob.PROPERTY_VALUE_DAO_KEY, null);
jobDetail.getJobDataMap().put("propTablesCleaner", null);
cleanupJob.execute(jobCtx);
}
@Test(expected=ClassCastException.class)
public void testWrongTypeForPropertyValueDAO() throws JobExecutionException
@Test(expected=AlfrescoRuntimeException.class)
public void testWrongTypeForPropTablesCleaner() throws JobExecutionException
{
jobDetail.getJobDataMap().put(PropTablesCleanupJob.PROPERTY_VALUE_DAO_KEY, "This is not a PropertyValueDAO");
jobDetail.getJobDataMap().put("propTablesCleaner", "This is not a PropTablesCleaner");
cleanupJob.execute(jobCtx);
}