mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-20250: Model updates not working for deployment in cluster (#37)
- added includeNewCheck to putAndCheckUpdate as a new optional parameter (default to false) - updated tests
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.cache;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -131,6 +131,45 @@ public class DefaultSimpleCacheTest extends SimpleCacheTestBase<DefaultSimpleCac
|
||||
assertEquals(false, cache.putAndCheckUpdate(104, "104"));
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void putAndCheckUpdateIncludeNewCheck()
|
||||
{
|
||||
// Put an initial value
|
||||
cache.put(101, "101");
|
||||
// Update it
|
||||
assertEquals(true, cache.putAndCheckUpdate(101, "99101", true));
|
||||
// Check the value really was updated
|
||||
assertEquals("99101", cache.get(101));
|
||||
|
||||
// Precondition: no value for key 102
|
||||
assertFalse(cache.contains(102));
|
||||
// Put a value - and test the return
|
||||
assertEquals(true, cache.putAndCheckUpdate(102, "102", true));
|
||||
assertEquals("102", cache.get(102));
|
||||
|
||||
cache.put(103, null);
|
||||
assertEquals(true, cache.putAndCheckUpdate(103, "103", true));
|
||||
// Repeat the put, this should not be an update
|
||||
assertEquals(false, cache.putAndCheckUpdate(103, "103", true));
|
||||
|
||||
assertFalse(cache.contains(104));
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, null, true));
|
||||
// Repeat putting null - still not an update, as we had that value a moment ago.
|
||||
assertEquals(false, cache.putAndCheckUpdate(104, null, true));
|
||||
// Now an update
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, "104", true));
|
||||
// Another update
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, "99104", true));
|
||||
// Another update, back to null
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, null, true));
|
||||
// Not an update - still null
|
||||
assertEquals(false, cache.putAndCheckUpdate(104, null, true));
|
||||
|
||||
cache.remove(104);
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, "104", true));
|
||||
assertEquals(true, cache.putAndCheckUpdate(104, null, true));
|
||||
}
|
||||
|
||||
// TODO: Timer-based tests are not ideal. An alternative approach is to factor out the CacheBuilder.newBuilder()
|
||||
// call to a protected method, override that in this test class to return a mock and use the mock to check
|
||||
@@ -198,6 +237,6 @@ public class DefaultSimpleCacheTest extends SimpleCacheTestBase<DefaultSimpleCac
|
||||
{
|
||||
throw new RuntimeException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user