mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-21837 - License expires 23h earlier - correction (#544)
* period.getMillis() (joda lib) returns an int instead of a long, so on larger periods (like 30days) we get an error that the value cannot fit in an int * Changed the validation to only calculate the remaining milliseconds in the edge case of the remaining days being zero (as both 23h before and 23h after correspond to 0 remaining days) * Added a unit test that validates the usage 60 days up from the licence expiring to validate the problem stops occurring Added a unit test that validates the usage 30 days after the licence expiring to cover all use cases
This commit is contained in:
@@ -297,6 +297,65 @@ public class RepoUsageComponentTest extends TestCase
|
||||
assertEquals("System is not at Locked Level",status.getLevel(),RepoUsageLevel.LOCKED_DOWN);
|
||||
}
|
||||
|
||||
|
||||
public void testLicenceMonthsBeforeExpiration() throws Exception
|
||||
{
|
||||
// Update usage
|
||||
updateUsage(UsageType.USAGE_ALL);
|
||||
|
||||
// Set the restrictions for license to expire in 60 days from now
|
||||
RepoUsage restrictions = new RepoUsage(
|
||||
System.currentTimeMillis(),
|
||||
5000L,
|
||||
100000L,
|
||||
LicenseMode.TEAM,
|
||||
System.currentTimeMillis() + TimeUnit.DAYS.toMillis(60),
|
||||
false);
|
||||
repoUsageComponent.setRestrictions(restrictions);
|
||||
|
||||
// Update use
|
||||
updateUsage(UsageType.USAGE_ALL);
|
||||
|
||||
// Get the usage
|
||||
RepoUsage usage = getUsage();
|
||||
|
||||
// Check
|
||||
assertFalse("Usage is in read-only mode",usage.isReadOnly());
|
||||
assertTrue("System is in read-only mode",transactionService.getAllowWrite());
|
||||
|
||||
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||
assertEquals("System is not at OK Level",status.getLevel(),RepoUsageLevel.OK);
|
||||
}
|
||||
|
||||
public void testLicenceDaysAfterExpiration() throws Exception
|
||||
{
|
||||
// Update usage
|
||||
updateUsage(UsageType.USAGE_ALL);
|
||||
|
||||
// Set the restrictions for license expired 5 days ago
|
||||
RepoUsage restrictions = new RepoUsage(
|
||||
System.currentTimeMillis(),
|
||||
5000L,
|
||||
100000L,
|
||||
LicenseMode.TEAM,
|
||||
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5),
|
||||
false);
|
||||
repoUsageComponent.setRestrictions(restrictions);
|
||||
|
||||
// Update use
|
||||
updateUsage(UsageType.USAGE_ALL);
|
||||
|
||||
// Get the usage
|
||||
RepoUsage usage = getUsage();
|
||||
|
||||
// Check we are in read-only mode
|
||||
assertTrue("Usage is not in read-only mode",usage.isReadOnly());
|
||||
assertFalse("System is not in read-only mode",transactionService.getAllowWrite());
|
||||
|
||||
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||
assertEquals("System is not at Locked Level",status.getLevel(),RepoUsageLevel.LOCKED_DOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that concurrent updates are prevented
|
||||
*
|
||||
|
Reference in New Issue
Block a user