diff --git a/source/java/org/alfresco/repo/content/RoutingContentServiceTest.java b/source/java/org/alfresco/repo/content/RoutingContentServiceTest.java index f626f7c0ea..49474f14ba 100644 --- a/source/java/org/alfresco/repo/content/RoutingContentServiceTest.java +++ b/source/java/org/alfresco/repo/content/RoutingContentServiceTest.java @@ -27,7 +27,9 @@ package org.alfresco.repo.content; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.io.Serializable; import java.util.Locale; +import java.util.Map; import javax.transaction.RollbackException; import javax.transaction.UserTransaction; @@ -791,4 +793,44 @@ public class RoutingContentServiceTest extends TestCase assertNotNull("Should be able to get reader", reader); assertEquals("Unknown mimetype was changed", bogusMimetype, reader.getMimetype()); } + + /** + * Checks that node copy and delete behaviour behaves correctly w.r.t. cleanup and shared URLs + */ + public void testPostCopyContentRetrieval() throws Exception + { + ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent("Some content"); + ContentData writerContentData = writer.getContentData(); + ContentData nodeContentData = (ContentData) nodeService.getProperty(contentNodeRef, ContentModel.PROP_CONTENT); + assertNotNull(nodeContentData); + assertEquals("ContentData not the same from NodeService and from ContentWriter", writerContentData, nodeContentData); + + Map copyProperties = nodeService.getProperties(contentNodeRef); + copyProperties.remove(ContentModel.PROP_NODE_UUID); + // Copy the node + NodeRef contentCopyNodeRef = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(TEST_NAMESPACE, GUID.generate()), + ContentModel.TYPE_CONTENT, + copyProperties).getChildRef(); + // Now get and check the ContentData for the copy + ContentData copyNodeContentData = (ContentData) nodeService.getProperty(contentCopyNodeRef, ContentModel.PROP_CONTENT); + assertNotNull(copyNodeContentData); + // The copy should share the same URL even + assertEquals("Copied node's cm:content ContentData was different", writerContentData, copyNodeContentData); + + // Delete the first node and ensure that the second valud remains good and the content is editable + nodeService.deleteNode(contentNodeRef); + copyNodeContentData = (ContentData) nodeService.getProperty(contentCopyNodeRef, ContentModel.PROP_CONTENT); + assertNotNull(copyNodeContentData); + assertEquals("Post-delete value didn't remain the same", writerContentData, copyNodeContentData); + ContentReader copyNodeContentReader = contentService.getReader(contentCopyNodeRef, ContentModel.PROP_CONTENT); + assertTrue("Physical content was removed", copyNodeContentReader.exists()); + + txn.commit(); + txn = null; + } } diff --git a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java index f838614109..5450e3f9a9 100644 --- a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java +++ b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleanerTest.java @@ -27,6 +27,7 @@ package org.alfresco.repo.content.cleanup; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,6 +46,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; @@ -96,6 +98,7 @@ public class ContentStoreCleanerTest extends TestCase ContentDataDAO contentDataDAO = (ContentDataDAO) ctx.getBean("contentDataDAO"); eagerCleaner = (EagerContentStoreCleaner) ctx.getBean("eagerContentStoreCleaner"); + eagerCleaner.setEagerOrphanCleanup(false); // we need a store store = new FileContentStore(ctx, TempFileProvider.getTempDir().getAbsolutePath()); @@ -225,61 +228,66 @@ public class ContentStoreCleanerTest extends TestCase assertFalse("Newly created content should be removed.", contentReaderNew.exists()); } -// /** -// * TODO: This test must be replaced with one that checks that the raw content binary lives -// * as long as there is a reference to it. Once the RM-hacks are removed, content -// * will once again be shared and must therefore be cleaned up based on unlinking of -// * references. -// */ -// public void testEagerCleanupAfterCopy() throws Exception -// { -// // Get the context-defined cleaner -// ContentStoreCleaner cleaner = (ContentStoreCleaner) ctx.getBean("contentStoreCleaner"); -// // Force eager cleanup -// cleaner.setEagerOrphanCleanup(true); -// cleaner.init(); -// // Create a new file, copy it -// RetryingTransactionCallback> copyFileCallback = new RetryingTransactionCallback>() -// { -// public Pair execute() throws Throwable -// { -// // Create some content -// StoreRef storeRef = nodeService.createStore("test", "testEagerCleanupAfterCopy-" + GUID.generate()); -// NodeRef rootNodeRef = nodeService.getRootNode(storeRef); -// Map properties = Collections.singletonMap(ContentModel.PROP_NAME, (Serializable)"test.txt"); -// NodeRef contentNodeRef = nodeService.createNode( -// rootNodeRef, -// ContentModel.ASSOC_CHILDREN, -// ContentModel.ASSOC_CHILDREN, -// ContentModel.TYPE_CONTENT, -// properties).getChildRef(); -// ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); -// writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); -// writer.putContent("INITIAL CONTENT"); -// // Now copy it -// NodeRef copiedNodeRef = copyService.copy( -// contentNodeRef, -// rootNodeRef, -// ContentModel.ASSOC_CHILDREN, -// ContentModel.ASSOC_CHILDREN); -// // Done -// return new Pair(contentNodeRef, copiedNodeRef); -// } -// }; -// Pair nodeRefPair = transactionService.getRetryingTransactionHelper().doInTransaction(copyFileCallback); -// // Check that the readers of the content have different URLs -// ContentReader contentReaderSource = contentService.getReader(nodeRefPair.getFirst(), ContentModel.PROP_CONTENT); -// assertNotNull("Expected reader for source cm:content", contentReaderSource); -// assertTrue("Expected content for source cm:content", contentReaderSource.exists()); -// ContentReader contentReaderCopy = contentService.getReader(nodeRefPair.getSecond(), ContentModel.PROP_CONTENT); -// assertNotNull("Expected reader for copy cm:content", contentReaderCopy); -// assertTrue("Expected content for copy cm:content", contentReaderCopy.exists()); -// String contentUrlSource = contentReaderSource.getContentUrl(); -// String contentUrlCopy = contentReaderCopy.getContentUrl(); -// assertFalse("Source and copy must have different URLs", -// EqualsHelper.nullSafeEquals(contentUrlSource, contentUrlCopy)); -// } -// + /** + * Create ContentData set it on a Node, delete the Node, then set the ContentData on a new node + * and check that the content is preserved during eager cleanup. + */ + public void testEagerCleanupDereferencing() throws Exception + { + eagerCleaner.setEagerOrphanCleanup(true); + + final StoreRef storeRef = nodeService.createStore("test", getName() + "-" + GUID.generate()); + RetryingTransactionCallback testCallback = new RetryingTransactionCallback() + { + public ContentData execute() throws Throwable + { + // Create some content + NodeRef rootNodeRef = nodeService.getRootNode(storeRef); + Map properties = new HashMap(13); + properties.put(ContentModel.PROP_NAME, (Serializable)"test.txt"); + NodeRef contentNodeRef = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + ContentModel.ASSOC_CHILDREN, + ContentModel.TYPE_CONTENT, + properties).getChildRef(); + ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.putContent("INITIAL CONTENT"); + ContentData contentData = writer.getContentData(); + + // Delete the first node + nodeService.deleteNode(contentNodeRef); + + ContentReader reader = contentService.getRawReader(contentData.getContentUrl()); + assertNotNull(reader); + assertTrue("Content was cleaned before end of transaction", reader.exists()); + + // Make a new copy using the same ContentData + properties.put(ContentModel.PROP_NAME, (Serializable)"test2.txt"); + properties.put(ContentModel.PROP_CONTENT, contentData); + contentNodeRef = nodeService.createNode( + rootNodeRef, + ContentModel.ASSOC_CHILDREN, + ContentModel.ASSOC_CHILDREN, + ContentModel.TYPE_CONTENT, + properties).getChildRef(); + + reader = contentService.getRawReader(contentData.getContentUrl()); + assertNotNull(reader); + assertTrue("Content was cleaned before end of transaction", reader.exists()); + + // Done + return contentData; + } + }; + ContentData contentData = transactionService.getRetryingTransactionHelper().doInTransaction(testCallback); + // Make sure that the content URL still exists + ContentReader reader = contentService.getRawReader(contentData.getContentUrl()); + assertNotNull(reader); + assertTrue("Content was cleaned despite being re-referenced in the transaction", reader.exists()); + } + public void testImmediateRemoval() throws Exception { cleaner.setProtectDays(0); diff --git a/source/java/org/alfresco/repo/domain/DomainTestSuite.java b/source/java/org/alfresco/repo/domain/DomainTestSuite.java new file mode 100644 index 0000000000..7db49bd7ad --- /dev/null +++ b/source/java/org/alfresco/repo/domain/DomainTestSuite.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.domain; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.alfresco.repo.domain.contentdata.ContentDataDAOTest; +import org.alfresco.repo.domain.encoding.EncodingDAOTest; +import org.alfresco.repo.domain.hibernate.HibernateSessionHelperTest; +import org.alfresco.repo.domain.locks.LockDAOTest; +import org.alfresco.repo.domain.mimetype.MimetypeDAOTest; + +/** + * Suite for domain-related tests. + * + * @author Derek Hulley + */ +public class DomainTestSuite extends TestSuite +{ + public static Test suite() + { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(ContentDataDAOTest.class); + suite.addTestSuite(EncodingDAOTest.class); + suite.addTestSuite(HibernateSessionHelperTest.class); + suite.addTestSuite(LockDAOTest.class); + suite.addTestSuite(MimetypeDAOTest.class); + suite.addTestSuite(LocaleDAOTest.class); + suite.addTestSuite(PropertyValueTest.class); + suite.addTestSuite(QNameDAOTest.class); + + return suite; + } +} diff --git a/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java b/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java index 5f05f0772f..1d5dd38808 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/contentdata/AbstractContentDataDAOImpl.java @@ -26,12 +26,16 @@ package org.alfresco.repo.domain.contentdata; import java.io.Serializable; import java.util.Locale; +import java.util.Set; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.content.cleanup.EagerContentStoreCleaner; import org.alfresco.repo.domain.LocaleDAO; import org.alfresco.repo.domain.encoding.EncodingDAO; import org.alfresco.repo.domain.mimetype.MimetypeDAO; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.TransactionListenerAdapter; +import org.alfresco.repo.transaction.TransactionalResourceHelper; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.util.Pair; import org.apache.commons.logging.Log; @@ -52,9 +56,13 @@ import org.springframework.dao.ConcurrencyFailureException; */ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO { - private static Log logger = LogFactory.getLog(AbstractContentDataDAOImpl.class); - + /** + * Content URL IDs to delete before final commit. + */ + private static final String KEY_PRE_COMMIT_CONTENT_URL_DELETIONS = "AbstractContentDataDAOImpl.PreCommitContentUrlDeletions"; private static final Long CACHE_NULL_LONG = Long.MIN_VALUE; + + private static Log logger = LogFactory.getLog(AbstractContentDataDAOImpl.class); private MimetypeDAO mimetypeDAO; private EncodingDAO encodingDAO; @@ -100,21 +108,22 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO */ protected void registerNewContentUrl(String contentUrl) { - if (contentStoreCleaner != null) - { - contentStoreCleaner.registerNewContentUrl(contentUrl); - } + contentStoreCleaner.registerNewContentUrl(contentUrl); } /** - * Register orphaned content for post-commit handling + * A content_url entity was dereferenced. This makes no assumptions about the + * current references - dereference deletion is handled in the commit phase. */ - protected void registerOrphanedContentUrl(String contentUrl) + protected void registerDereferenceContentUrl(String contentUrl) { - if (contentStoreCleaner != null) + Set contentUrls = TransactionalResourceHelper.getSet(KEY_PRE_COMMIT_CONTENT_URL_DELETIONS); + if (contentUrls.size() == 0) { - contentStoreCleaner.registerOrphanedContentUrl(contentUrl); + ContentUrlDeleteTransactionListener listener = new ContentUrlDeleteTransactionListener(); + AlfrescoTransactionSupport.bindListener(listener); } + contentUrls.add(contentUrl); } /** @@ -288,6 +297,13 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO */ protected abstract ContentUrlEntity getContentUrlEntity(String contentUrl); + /** + * @param contentUrl the URL of the content url entity + * @return Return the entity or null if it doesn't exist or is still + * referenced by a content_data entity + */ + protected abstract ContentUrlEntity getContentUrlEntityUnreferenced(String contentUrl); + /** * Delete the entity with the given ID * @return Returns the number of rows deleted @@ -315,4 +331,38 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO * @return Returns the number of rows deleted */ protected abstract int deleteContentDataEntity(Long id); + + /** + * Transactional listener that deletes unreferenced content_url entities. + * + * @author Derek Hulley + */ + public class ContentUrlDeleteTransactionListener extends TransactionListenerAdapter + { + @Override + public void beforeCommit(boolean readOnly) + { + // Ignore read-only + if (readOnly) + { + return; + } + Set contentUrls = TransactionalResourceHelper.getSet(KEY_PRE_COMMIT_CONTENT_URL_DELETIONS); + for (String contentUrl : contentUrls) + { + ContentUrlEntity contentUrlEntity = getContentUrlEntityUnreferenced(contentUrl); + if (contentUrlEntity == null) + { + // It is still referenced, so ignore it + continue; + } + // It needs to be deleted + Long contentUrlId = contentUrlEntity.getId(); + deleteContentUrlEntity(contentUrlId); + // Pop this in the queue for deletion from the content store + contentStoreCleaner.registerOrphanedContentUrl(contentUrl); + } + contentUrls.clear(); + } + } } diff --git a/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java b/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java index 01e2cb936d..b0d6765342 100644 --- a/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/contentdata/ibatis/ContentDataDAOImpl.java @@ -46,10 +46,10 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl { private static final String SELECT_CONTENT_URL_BY_ID = "select.ContentUrlById"; private static final String SELECT_CONTENT_URL_BY_KEY = "select.ContentUrlByKey"; + private static final String SELECT_CONTENT_URL_BY_KEY_UNREFERENCED = "select.ContentUrlByKeyUnreferenced"; private static final String SELECT_CONTENT_URLS = "select.ContentUrls"; private static final String SELECT_CONTENT_DATA_BY_ID = "select.ContentDataById"; private static final String SELECT_CONTENT_DATA_BY_NODE_AND_QNAME = "select.ContentDataByNodeAndQName"; - private static final String SELECT_CONTENT_DATA_BY_URL_ID = "select.ContentDataByContentUrlId"; private static final String INSERT_CONTENT_URL = "insert.ContentUrl"; private static final String INSERT_CONTENT_DATA = "insert.ContentData"; private static final String DELETE_CONTENT_DATA = "delete.ContentData"; @@ -105,6 +105,16 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl return template.delete(DELETE_CONTENT_URL, params); } + @Override + protected ContentUrlEntity getContentUrlEntityUnreferenced(String contentUrl) + { + ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); + contentUrlEntity.setContentUrl(contentUrl); + contentUrlEntity = (ContentUrlEntity) template.queryForObject(SELECT_CONTENT_URL_BY_KEY_UNREFERENCED, contentUrlEntity); + // Done + return contentUrlEntity; + } + @Override protected ContentDataEntity createContentDataEntity( Long contentUrlId, @@ -166,22 +176,13 @@ public class ContentDataDAOImpl extends AbstractContentDataDAOImpl } // Only check the content URLs if one is present String contentUrl = contentDataEntity.getContentUrl(); - Long contentUrlId = contentDataEntity.getContentUrlId(); // Delete the ContentData entity deleteContentData(id); // Check if the content URL was orphaned - if (contentUrlId != null) + if (contentUrl != null) { - params.clear(); - params.put("id", contentUrlId); - @SuppressWarnings("unchecked") - List contentDataEntities = (List) template.queryForList(SELECT_CONTENT_DATA_BY_URL_ID, params); - // If there is still ContentData associated with the content URL, then leave it - if (contentDataEntities.size() == 0) - { - // Orphaned - registerOrphanedContentUrl(contentUrl); - } + // It has been dereferenced and may be orphaned - we'll check later + registerDereferenceContentUrl(contentUrl); } } } diff --git a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperTest.java b/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperTest.java index cc978379b0..8ddf43fcc7 100644 --- a/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperTest.java +++ b/source/java/org/alfresco/repo/domain/hibernate/HibernateSessionHelperTest.java @@ -4,6 +4,10 @@ import java.io.Serializable; import java.util.Date; import java.util.Set; +import javax.transaction.UserTransaction; + +import junit.framework.TestCase; + import org.alfresco.model.ContentModel; import org.alfresco.repo.domain.AuditableProperties; import org.alfresco.repo.domain.Node; @@ -11,16 +15,32 @@ import org.alfresco.repo.domain.QNameDAO; import org.alfresco.repo.domain.Server; import org.alfresco.repo.domain.Store; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.util.BaseSpringTest; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.hibernate.Session; +import org.hibernate.SessionFactory; import org.hibernate.engine.EntityKey; +import org.springframework.context.ApplicationContext; +import org.springframework.orm.hibernate3.SessionFactoryUtils; -public class HibernateSessionHelperTest extends BaseSpringTest +public class HibernateSessionHelperTest extends TestCase { - + private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - protected void onTearDownInTransaction() + private UserTransaction txn; + private SessionFactory sessionFactory; + + @Override + protected void setUp() throws Exception { + sessionFactory = (SessionFactory) ctx.getBean("sessionFactory"); + ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); + TransactionService transactionService = serviceRegistry.getTransactionService(); + txn = transactionService.getUserTransaction(); + txn.begin(); + // force a flush to ensure that the database updates succeed try { @@ -33,6 +53,28 @@ public class HibernateSessionHelperTest extends BaseSpringTest } } + private Session getSession() + { + return SessionFactoryUtils.getSession(sessionFactory, true); + } + + @Override + protected void tearDown() + { + if (txn != null) + { + try + { + txn.rollback(); + } + catch (Throwable e) + { + // Don't let this hide errors coming from the tests + e.printStackTrace(); + } + } + } + public void testSimpleMark() { assertEquals(0, getSession().getStatistics().getEntityCount()); @@ -56,7 +98,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(2, getSession().getStatistics().getEntityCount()); - HibernateSessionHelper helper = (HibernateSessionHelper)getApplicationContext().getBean("hibernateSessionHelper"); + HibernateSessionHelper helper = (HibernateSessionHelper) ctx.getBean("hibernateSessionHelper"); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); helper.mark(); assertTrue(SessionSizeResourceManager.isDisableInTransaction()); @@ -92,7 +134,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(0, getSession().getStatistics().getEntityCount()); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); - QNameDAO qnameDAO = (QNameDAO) getApplicationContext().getBean("qnameDAO"); + QNameDAO qnameDAO = (QNameDAO) ctx.getBean("qnameDAO"); Long baseQNameId = qnameDAO.getOrCreateQName(ContentModel.TYPE_BASE).getFirst(); StoreImpl store = new StoreImpl(); @@ -118,7 +160,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(4, getSession().getStatistics().getEntityCount()); - HibernateSessionHelper helper = (HibernateSessionHelper)getApplicationContext().getBean("hibernateSessionHelper"); + HibernateSessionHelper helper = (HibernateSessionHelper)ctx.getBean("hibernateSessionHelper"); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); helper.mark(); assertTrue(SessionSizeResourceManager.isDisableInTransaction()); @@ -284,7 +326,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(2, getSession().getStatistics().getEntityCount()); - HibernateSessionHelper helper = (HibernateSessionHelper)getApplicationContext().getBean("hibernateSessionHelper"); + HibernateSessionHelper helper = (HibernateSessionHelper)ctx.getBean("hibernateSessionHelper"); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); helper.mark("One"); assertTrue(SessionSizeResourceManager.isDisableInTransaction()); @@ -320,7 +362,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(0, getSession().getStatistics().getEntityCount()); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); - QNameDAO qnameDAO = (QNameDAO) getApplicationContext().getBean("qnameDAO"); + QNameDAO qnameDAO = (QNameDAO) ctx.getBean("qnameDAO"); Long baseQNameId = qnameDAO.getOrCreateQName(ContentModel.TYPE_BASE).getFirst(); StoreImpl store = new StoreImpl(); @@ -346,7 +388,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(4, getSession().getStatistics().getEntityCount()); - HibernateSessionHelper helper = (HibernateSessionHelper)getApplicationContext().getBean("hibernateSessionHelper"); + HibernateSessionHelper helper = (HibernateSessionHelper)ctx.getBean("hibernateSessionHelper"); assertNull(helper.getCurrentMark()); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); helper.mark("One"); @@ -504,7 +546,7 @@ public class HibernateSessionHelperTest extends BaseSpringTest assertEquals(3, getSession().getStatistics().getEntityCount()); - HibernateSessionHelper helper = (HibernateSessionHelper)getApplicationContext().getBean("hibernateSessionHelper"); + HibernateSessionHelper helper = (HibernateSessionHelper)ctx.getBean("hibernateSessionHelper"); assertFalse(SessionSizeResourceManager.isDisableInTransaction()); helper.mark("One"); helper.mark("Two"); diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java index 0bb2726153..4b08fd34d1 100644 --- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java +++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java @@ -281,48 +281,6 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest } } - /** - * Checks that the string_value retrieval against a property type is working - */ - public void testGetContentDataValues() throws Exception - { - final DataTypeDefinition contentDataType = dictionaryService.getDataType(DataTypeDefinition.CONTENT); - - ContentData contentDataSingle = new ContentData("url-single", MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null); - ContentData contentDataMultiple = new ContentData("url-multiple", MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null); - // put this in as a random single property - nodeService.setProperty( - rootNodeRef, - QName.createQName(NAMESPACE, "random-single"), - contentDataSingle); - - // create a collection of mixed types - ArrayList collection = new ArrayList(3); - collection.add("abc"); - collection.add(new Integer(123)); - collection.add(contentDataMultiple); - nodeService.setProperty( - rootNodeRef, - QName.createQName(NAMESPACE, "random-multiple"), - collection); - - // get a list of all content values - final List allContentDatas = new ArrayList(500); - NodePropertyHandler handler = new NodePropertyHandler() - { - public void handle(NodeRef nodeRef, QName nodeTypeQName, QName propertyQName, Serializable value) - { - allContentDatas.add(value); - } - }; - nodeDaoService.getPropertyValuesByActualType(contentDataType, handler); - assertTrue("At least two instances expected", allContentDatas.size() >= 2); - assertTrue("Single content data not present in results", - allContentDatas.contains(contentDataSingle)); - assertTrue("Multi-valued buried content data not present in results", - allContentDatas.contains(contentDataMultiple)); - } - public void testMLTextValues() throws Exception { // Set the server default locale