Support 'alf_prop_string_value'

- Simple ID-string table
 - Non-unique and case-sensitive, but with re-use of entries as far as possible


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15430 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-07-27 13:55:08 +00:00
parent e7e001ed69
commit fc2e47a119
10 changed files with 477 additions and 53 deletions

View File

@@ -118,4 +118,54 @@ public class PropertyValueDAOTest extends TestCase
};
txnHelper.doInTransaction(noHitCallback, false);
}
public void testPropertyStringValue() throws Exception
{
final String stringValue = "One Two Three";
final String stringValueUpper = stringValue.toUpperCase();
final String stringValueLower = stringValue.toLowerCase();
RetryingTransactionCallback<Pair<Long, String>> createStringCallback = new RetryingTransactionCallback<Pair<Long, String>>()
{
public Pair<Long, String> execute() throws Throwable
{
// Get the classes
return propertyValueDAO.getOrCreatePropertyStringValue(stringValue);
}
};
final Pair<Long, String> stringEntityPair = txnHelper.doInTransaction(createStringCallback, false);
assertNotNull(stringEntityPair);
assertNotNull(stringEntityPair.getFirst());
assertEquals(stringValue, stringEntityPair.getSecond());
// Check that the uppercase and lowercase strings don't have entries
RetryingTransactionCallback<Void> getClassCallback = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
Pair<Long, String> checkPair1 = propertyValueDAO.getPropertyStringValue(stringValue);
assertNotNull(checkPair1);
assertEquals(stringValue, checkPair1.getSecond());
Pair<Long, String> checkPair2 = propertyValueDAO.getPropertyStringValue(stringValueUpper);
assertNull(checkPair2);
Pair<Long, String> checkPair3 = propertyValueDAO.getPropertyStringValue(stringValueLower);
assertNull(checkPair3);
return null;
}
};
txnHelper.doInTransaction(getClassCallback, true);
RetryingTransactionCallback<Pair<Long, String>> createStringUpperCallback = new RetryingTransactionCallback<Pair<Long, String>>()
{
public Pair<Long, String> execute() throws Throwable
{
// Get the classes
return propertyValueDAO.getOrCreatePropertyStringValue(stringValueUpper);
}
};
final Pair<Long, String> stringUpperEntityPair = txnHelper.doInTransaction(createStringUpperCallback, false);
assertNotNull(stringUpperEntityPair);
assertNotNull(stringUpperEntityPair.getFirst());
assertEquals(stringValueUpper, stringUpperEntityPair.getSecond());
assertNotSame("String IDs were not different", stringEntityPair.getFirst(), stringUpperEntityPair.getFirst());
}
}