From 68a681dcfe212a8a7d4a2f09617e3a8a0229b459 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Thu, 26 Aug 2010 12:17:34 +0000 Subject: [PATCH] Added extra checks on MLText and null values git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22016 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/node/FullNodeServiceTest.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/source/java/org/alfresco/repo/node/FullNodeServiceTest.java b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java index fc184269b9..af45bb1fb7 100644 --- a/source/java/org/alfresco/repo/node/FullNodeServiceTest.java +++ b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java @@ -121,14 +121,32 @@ public class FullNodeServiceTest extends BaseNodeServiceTest public void testNullMLText() throws Exception { - Map properties = nodeService.getProperties(rootNodeRef); // Set an ML value to null - properties.put(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null); nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null); // Get them again Serializable mlTextSer = nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); MLText mlText = DefaultTypeConverter.INSTANCE.convert(MLText.class, mlTextSer); assertNull("Value returned is not null", mlText); + + // Now create an MLText object with a null entry + mlText = new MLText(null); + nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null); + MLText mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); + assertNull("MLText value should have been converted to a null String", mlTextCheck); + + // Do the same as ML-aware + MLPropertyInterceptor.setMLAware(true); + try + { + mlText = new MLText(null); + nodeService.setProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, null); + mlTextCheck = (MLText) nodeService.getProperty(rootNodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); + assertEquals("MLText value was not pulled out the same as it went in", mlText, mlTextCheck); + } + finally + { + MLPropertyInterceptor.setMLAware(false); // Don't mess up the thread + } } public void testMLValuesOnCreate() throws Exception @@ -335,10 +353,6 @@ public class FullNodeServiceTest extends BaseNodeServiceTest assertEquals("First collection incorrect", 2, ((Collection)checkValues.get(0)).size()); assertEquals("Second collection incorrect", 2, ((Collection)checkValues.get(1)).size()); } - catch (DictionaryException e) - { - // expected - } finally { try { txn.rollback(); } catch (Throwable e) {}