Merged 5.1.N (5.1.1) to HEAD (5.2)

122526 dhulley: More explicit recording of attribute keys for multi-threaded test of property value cleaner (ACE-5153)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123673 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 22:27:29 +00:00
parent 03c9eaeb9f
commit d3cc1d0761

View File

@@ -19,10 +19,12 @@
package org.alfresco.repo.domain.propval; package org.alfresco.repo.domain.propval;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.attributes.AttributeService; import org.alfresco.service.cmr.attributes.AttributeService;
@@ -131,10 +133,9 @@ public class PropertyValueCleanupTest
// Runnable // Runnable
String key1 = runnables[i].key1; String key1 = runnables[i].key1;
String key2 = runnables[i].key2; String key2 = runnables[i].key2;
int maxKey3 = runnables[i].counter.get() - 1; // The last number did not get in List<Integer> key3s = new ArrayList<Integer>(runnables[i].key3s); // Copy entire list
for (int j = 0; j < maxKey3; j++) for (Integer key3 : key3s)
{ {
Integer key3 = j;
// Get the attribute // Get the attribute
byte[] propFetched = (byte[]) attributeService.getAttribute(key1, key2, key3); byte[] propFetched = (byte[]) attributeService.getAttribute(key1, key2, key3);
assertTrue( assertTrue(
@@ -155,15 +156,17 @@ public class PropertyValueCleanupTest
{ {
private final String key1; private final String key1;
private final String key2; private final String key2;
private List<Integer> key3s;
private final byte[] prop; private final byte[] prop;
private AtomicBoolean running = new AtomicBoolean(true); private AtomicBoolean running = new AtomicBoolean(true);
private AtomicInteger counter = new AtomicInteger(0); private int counter = 0;
private InsertSerializableAttributes() throws UnsupportedEncodingException private InsertSerializableAttributes() throws UnsupportedEncodingException
{ {
key1 = "PropertyValueCleanupTest"; key1 = "PropertyValueCleanupTest";
key2 = UUID.randomUUID().toString(); key2 = UUID.randomUUID().toString();
key3s = Collections.synchronizedList(new ArrayList<Integer>(200));
prop = new String("Key is " + key2).getBytes("US-ASCII"); prop = new String("Key is " + key2).getBytes("US-ASCII");
} }
@@ -172,10 +175,12 @@ public class PropertyValueCleanupTest
{ {
while (running.get()) while (running.get())
{ {
Integer key3 = counter.get(); Integer key3 = Integer.valueOf(counter);
attributeService.createAttribute(prop, key1, key2, key3); attributeService.createAttribute(prop, key1, key2, key3);
// Record the successful addition
key3s.add(key3);
// Increment the counter // Increment the counter
counter.incrementAndGet(); counter++;
// Wait a bit so that we don't drown the test // Wait a bit so that we don't drown the test
try { wait(10L); } catch (InterruptedException e) {} try { wait(10L); } catch (InterruptedException e) {}
} }