You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/02/27 16:12:38 UTC

svn commit: r381354 - in /lenya/trunk/src/test/org/apache/lenya/cms/publication/util: ./ XLinkCollectionTest.java

Author: andreas
Date: Mon Feb 27 07:12:31 2006
New Revision: 381354

URL: http://svn.apache.org/viewcvs?rev=381354&view=rev
Log:
Added XLinkCollectionTest

Added:
    lenya/trunk/src/test/org/apache/lenya/cms/publication/util/
    lenya/trunk/src/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java

Added: lenya/trunk/src/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java?rev=381354&view=auto
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java (added)
+++ lenya/trunk/src/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java Mon Feb 27 07:12:31 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication.util;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.impl.AccessControlTest;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentIdentifier;
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.PublicationUtil;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.site.SiteManager;
+import org.apache.lenya.cms.site.SiteUtil;
+import org.apache.lenya.transaction.TransactionException;
+
+/**
+ * XLink collection teest.
+ */
+public class XLinkCollectionTest extends AccessControlTest {
+
+    public void testXLinkCollection() throws PublicationException, AccessControlException,
+            TransactionException, ServiceException {
+        
+        DocumentIdentityMap map = getIdentityMap();
+        Session session = new Session(map.getIdentityMap(), getIdentity(), getLogger());
+        
+        Publication pub = PublicationUtil.getPublication(getManager(), "test");
+        DocumentIdentifier identifier = new DocumentIdentifier(pub, Publication.AUTHORING_AREA, "/collection", "en");
+        XlinkCollection collection = new XlinkCollection(getManager(), map, identifier, getLogger());
+        
+        SiteUtil.getSiteStructure(getManager(), collection).getRepositoryNode().lock();
+        
+        SiteManager siteManager = null;
+        ServiceSelector selector = null;
+        try {
+            selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
+            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
+            
+            siteManager.add(collection);
+        }
+        finally {
+            selector.release(siteManager);
+            getManager().release(selector);
+        }
+
+        Document doc = map.get(pub, Publication.AUTHORING_AREA, "/index", "en");
+        
+        collection.getRepositoryNode().lock();
+        collection.add(doc);
+        
+        collection.save();
+        
+        collection.getRepositoryNode().unlock();
+        SiteUtil.getSiteStructure(getManager(), collection).getRepositoryNode().unlock();
+        
+        
+        Collection coll2 = new XlinkCollection(getManager(), map, identifier, getLogger());
+        
+        assertSame(collection.getRepositoryNode(), coll2.getRepositoryNode());
+        
+        assertEquals(collection.getSourceURI(), coll2.getSourceURI());
+        assertEquals(coll2.size(), 1);
+        assertTrue(coll2.contains(doc));
+        
+    }
+    
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org