mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.0.N (5.0.3) to 5.1.N (5.1.1) (PARTIAL MERGE)
114790 amorarasu: MNT-15007: CLONE - String values when migrating from MySQL to other DBs Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3) 114311 amorarasu: Merged V4.1-BUG-FIX (4.1.11) to V4.2-BUG-FIX (4.2.6) 114245 tvalkevych: Merged V4.1.9 (4.1.9.13) to V4.1-BUG-FIX (4.1.11) 113717 dhulley: MNT-14911: String values when migrating from MySQL to other DBs - Add a new job that allows node string values to be re-persisted according to the current 'system.maximumStringLength' value - Job is unscheduled by default - Set the 'system.maximumStringLength' and the 'system.maximumStringLength.jobCronExpression' - Various touched code format fixes, method naming fixes, etc git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@114988 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,9 +19,12 @@
|
||||
package org.alfresco.repo.domain.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -33,8 +36,10 @@ import org.alfresco.repo.domain.node.NodeDAO.NodeRefQueryCallback;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
@@ -106,6 +111,80 @@ public class NodeDAOTest extends TestCase
|
||||
assertNotNull("Txn ID should be present by forcing it", txnId2);
|
||||
}
|
||||
|
||||
public void testSelectNodePropertiesByTypes() throws Exception
|
||||
{
|
||||
final Set<QName> qnames = Collections.singleton(ContentModel.PROP_NAME);
|
||||
RetryingTransactionCallback<List<NodePropertyEntity>> callback = new RetryingTransactionCallback<List<NodePropertyEntity>>()
|
||||
{
|
||||
public List<NodePropertyEntity> execute() throws Throwable
|
||||
{
|
||||
return nodeDAO.selectNodePropertiesByTypes(qnames);
|
||||
}
|
||||
};
|
||||
List<NodePropertyEntity> props = txnHelper.doInTransaction(callback, true);
|
||||
if (props.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
NodePropertyEntity prop = props.get(0);
|
||||
String value = prop.getValue().getStringValue();
|
||||
assertNotNull(value);
|
||||
}
|
||||
|
||||
public void testSelectNodePropertiesByDataType() throws Exception
|
||||
{
|
||||
// Prepare the bits that repeat the actual query
|
||||
final AtomicLong min = new AtomicLong(0L);
|
||||
final AtomicLong max = new AtomicLong(0L);
|
||||
RetryingTransactionCallback<List<NodePropertyEntity>> callback = new RetryingTransactionCallback<List<NodePropertyEntity>>()
|
||||
{
|
||||
public List<NodePropertyEntity> execute() throws Throwable
|
||||
{
|
||||
long minNodeId = min.get();
|
||||
long maxNodeId = max.get();
|
||||
return nodeDAO.selectNodePropertiesByDataType(DataTypeDefinition.TEXT, minNodeId, maxNodeId);
|
||||
}
|
||||
};
|
||||
|
||||
// Get the current max node id
|
||||
Long minNodeId = nodeDAO.getMinNodeId();
|
||||
if (minNodeId == null)
|
||||
{
|
||||
return; // there are no nodes!
|
||||
}
|
||||
Long maxNodeId = nodeDAO.getMaxNodeId(); // won't be null at this point as we have a min
|
||||
min.set(minNodeId.longValue());
|
||||
|
||||
// Iterate across all nodes in the system
|
||||
while (min.longValue() <= maxNodeId.longValue())
|
||||
{
|
||||
max.set(min.get() + 1000L); // 1K increments
|
||||
|
||||
// Get the properties
|
||||
List<NodePropertyEntity> props = txnHelper.doInTransaction(callback, true);
|
||||
for (NodePropertyEntity prop : props)
|
||||
{
|
||||
// Check the property
|
||||
Long nodeId = prop.getNodeId();
|
||||
assertNotNull(nodeId);
|
||||
assertTrue("the min should be inclusive.", min.longValue() <= nodeId.longValue());
|
||||
assertTrue("the max should be exclusive.", max.longValue() > nodeId.longValue());
|
||||
NodePropertyValue propVal = prop.getValue();
|
||||
assertNotNull(propVal);
|
||||
assertEquals("STRING", propVal.getActualTypeString());
|
||||
String valueStr = propVal.getStringValue();
|
||||
Serializable valueSer = propVal.getSerializableValue();
|
||||
assertTrue("Test is either TEXT or SERIALIZABLE", valueStr != null || valueSer != null);
|
||||
String value = (String) propVal.getValue(DataTypeDefinition.TEXT);
|
||||
assertNotNull(value);
|
||||
// This all checks out
|
||||
}
|
||||
|
||||
// Shift the window up
|
||||
min.set(max.get());
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetNodesWithAspects() throws Throwable
|
||||
{
|
||||
final NodeRefQueryCallback callback = new NodeRefQueryCallback()
|
||||
@@ -130,6 +209,16 @@ public class NodeDAOTest extends TestCase
|
||||
}, true);
|
||||
}
|
||||
|
||||
public void testGetMinMaxNodeId() throws Exception
|
||||
{
|
||||
Long minNodeId = nodeDAO.getMinNodeId();
|
||||
assertNotNull(minNodeId);
|
||||
assertTrue(minNodeId.longValue() > 0L);
|
||||
Long maxNodeId = nodeDAO.getMaxNodeId();
|
||||
assertNotNull(maxNodeId);
|
||||
assertTrue(maxNodeId.longValue() > minNodeId.longValue());
|
||||
}
|
||||
|
||||
public void testGetPrimaryChildAcls() throws Throwable
|
||||
{
|
||||
List<NodeIdAndAclId> acls = nodeDAO.getPrimaryChildrenAcls(1L);
|
||||
@@ -150,6 +239,25 @@ public class NodeDAOTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public void testCacheNodes() throws Throwable
|
||||
{
|
||||
Long minNodeId = nodeDAO.getMinNodeId();
|
||||
final List<Long> nodeIds = new ArrayList<Long>(10000);
|
||||
for (long i = 0; i < 1000; i++)
|
||||
{
|
||||
nodeIds.add(Long.valueOf(minNodeId.longValue() + i));
|
||||
}
|
||||
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
nodeDAO.cacheNodesById(nodeIds);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
txnHelper.doInTransaction(callback, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the {@link NodeEntity} values cached as root nodes are valid instances.
|
||||
* <p/>
|
||||
|
Reference in New Issue
Block a user