svn commit: r743712 - in /lenya/trunk: org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/ org.apache.lenya.module.simplesite/ org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/ org.apache.lenya.module.simplesi...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Thu Feb 12 12:58:47 2009
New Revision: 743712

URL: http://svn.apache.org/viewvc?rev=743712&view=rev
Log:
Fixed SimpleSiteManagerTest.

Added:
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.spring.xml
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.xtest
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/test-components.xml
Modified:
    lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractLenyaTestCase.java
    lenya/trunk/org.apache.lenya.module.simplesite/pom.xml
    lenya/trunk/org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.java

Modified: lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractLenyaTestCase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractLenyaTestCase.java?rev=743712&r1=743711&r2=743712&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractLenyaTestCase.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/test/java/org/apache/lenya/cms/AbstractLenyaTestCase.java Thu Feb 12 12:58:47 2009
@@ -25,6 +25,7 @@
 
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.AbstractTestCase;
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.components.ContextHelper;
@@ -176,5 +177,10 @@
         logger.info("Context classpath: " + buildClassPath);
         return buildClassPath.toString();
     }
+
+    @Override
+    protected ServiceManager getManager() {
+        throw new UnsupportedOperationException("Use getBeanFactory() instead.");
+    }
     
 }

Modified: lenya/trunk/org.apache.lenya.module.simplesite/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/pom.xml?rev=743712&r1=743711&r2=743712&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.module.simplesite/pom.xml Thu Feb 12 12:58:47 2009
@@ -60,6 +60,31 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-ac</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-impl</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-core-resourcetype</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-module-sourcerepository</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lenya</groupId>
+      <artifactId>lenya-module-sitetree</artifactId>
+      <scope>runtime</scope>
+    </dependency>
     
   </dependencies>
 </project>

Modified: lenya/trunk/org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.java?rev=743712&r1=743711&r2=743712&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.java (original)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/test/java/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.java Thu Feb 12 12:58:47 2009
@@ -17,16 +17,15 @@
  */
 package org.apache.lenya.cms.site.simple;
 
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.lenya.cms.AbstractAccessControlTest;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.publication.ResourceTypeResolver;
 import org.apache.lenya.cms.publication.Session;
 import org.apache.lenya.cms.site.Link;
 import org.apache.lenya.cms.site.SiteException;
-import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteStructure;
 
@@ -45,69 +44,49 @@
     }
 
     protected void checkPublication(Publication pub) throws Exception {
-        DocumentManager docManager = null;
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
-        ServiceSelector resourceTypeSelector = null;
-
-        try {
-            selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
-            SiteStructure structure = siteManager.getSiteStructure(pub, Publication.AUTHORING_AREA);
-
-            docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
-
-            resourceTypeSelector = (ServiceSelector) getManager().lookup(
-                    ResourceType.ROLE + "Selector");
-            ResourceType type = (ResourceType) resourceTypeSelector.select("entry");
-            String contentSourceUri = "context://sitemap.xmap";
-
-            Document doc = docManager.add(type, contentSourceUri, pub, Publication.AUTHORING_AREA,
-                    "en", "xml");
-
-            structure.add(PATH, doc);
-            assertTrue(structure.contains(PATH));
-            Document linkDoc = structure.getNode(PATH).getLink("en").getDocument();
-            assertSame(linkDoc, doc);
-
-            if (!(structure instanceof DocumentStore)) {
-                Link link = doc.getLink();
-                checkSetLabel(link);
-            }
 
-            SiteNode[] nodes = structure.getNodes();
-            assertTrue(nodes.length > 0);
+        SiteStructure structure = pub.getArea(Publication.AUTHORING_AREA).getSite();
 
-            for (int i = 0; i < nodes.length; i++) {
+        DocumentManager docManager = (DocumentManager) getBeanFactory().getBean(
+                DocumentManager.ROLE);
 
-                assertTrue(structure.contains(nodes[i].getPath()));
+        ResourceTypeResolver resolver = (ResourceTypeResolver) getBeanFactory().getBean(
+                ResourceTypeResolver.class.getName());
+        ResourceType type = resolver.getResourceType("mock");
+        String contentSourceUri = pub.getSourceUri() + "/sitemap.xmap";
+
+        Document doc = docManager.add(type, contentSourceUri, pub, Publication.AUTHORING_AREA,
+                "en", "xml");
+
+        structure.add(PATH, doc);
+        assertTrue(structure.contains(PATH));
+        Document linkDoc = structure.getNode(PATH).getLink("en").getDocument();
+        assertSame(linkDoc, doc);
+
+        if (!(structure instanceof DocumentStore)) {
+            Link link = doc.getLink();
+            checkSetLabel(link);
+        }
 
-                SiteNode node = structure.getNode(nodes[i].getPath());
-                assertNotNull(node);
-                assertEquals(nodes[i], node);
+        SiteNode[] nodes = structure.getNodes();
+        assertTrue(nodes.length > 0);
 
-                checkLinks(siteManager, node);
-            }
+        for (int i = 0; i < nodes.length; i++) {
 
-            doc.getLink().delete();
-            assertFalse(structure.containsByUuid(doc.getUUID(), doc.getLanguage()));
-            assertFalse(structure.contains(PATH));
-            assertFalse(structure.contains(PARENT_PATH));
-
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                getManager().release(selector);
-            }
-            if (docManager != null) {
-                getManager().release(docManager);
-            }
-            if (resourceTypeSelector != null) {
-                getManager().release(resourceTypeSelector);
-            }
+            assertTrue(structure.contains(nodes[i].getPath()));
+
+            SiteNode node = structure.getNode(nodes[i].getPath());
+            assertNotNull(node);
+            assertEquals(nodes[i], node);
+
+            checkLinks(structure, node);
         }
+
+        doc.getLink().delete();
+        assertFalse(structure.containsByUuid(doc.getUUID(), doc.getLanguage()));
+        assertFalse(structure.contains(PATH));
+        assertFalse(structure.contains(PARENT_PATH));
+
         // session.commit();
     }
 
@@ -120,7 +99,7 @@
         link.setLabel(oldLabel);
     }
 
-    protected void checkLinks(SiteManager siteManager, SiteNode node) throws SiteException {
+    protected void checkLinks(SiteStructure site, SiteNode node) throws SiteException {
         String[] languages = node.getLanguages();
         for (int i = 0; i < languages.length; i++) {
             Link link = node.getLink(languages[i]);
@@ -140,7 +119,7 @@
 
                 // it may not be allowed to insert the doc twice
                 try {
-                    siteManager.add("/sidebar", doc);
+                    site.add("/sidebar", doc);
                     assertTrue("No exception thrown", false);
                 } catch (Exception expected) {
                 }

Added: lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.spring.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.spring.xml?rev=743712&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.spring.xml (added)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.spring.xml Thu Feb 12 12:58:47 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+  <import resource="classpath:test-components.xml"/>
+</beans>

Added: lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.xtest
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.xtest?rev=743712&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.xtest (added)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/org/apache/lenya/cms/site/simple/SimpleSiteManagerTest.xtest Thu Feb 12 12:58:47 2009
@@ -0,0 +1,41 @@
+<?xml version="1.0" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<testcase>
+  <roles>
+    <role name="org.apache.excalibur.source.SourceFactorySelector"
+      shorthand="source-factories"
+      default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+    <role name="org.apache.excalibur.source.SourceResolver"
+      shorthand="source-resolver"
+      default-class="org.apache.excalibur.source.impl.SourceResolverImpl"
+    />
+  </roles>
+  
+  <components>
+    
+    <source-factories>
+      <component-instance class="org.apache.cocoon.components.source.impl.XMLizableSourceFactory" name="xml" logger="core.xmlsource"/>
+      <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file" logger="core.filesource"/>
+      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource" logger="core.resourcesource"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+    </source-factories>
+    
+  </components>
+  
+</testcase>

Added: lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/test-components.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/test-components.xml?rev=743712&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/test-components.xml (added)
+++ lenya/trunk/org.apache.lenya.module.simplesite/src/test/resources/test-components.xml Thu Feb 12 12:58:47 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+  
+  <import resource="classpath:META-INF/cocoon/spring/lenya-core-ac-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-core-impl-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-core-observation-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-core-repository-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-core-resourcetype-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-module-sitetree-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/lenya-module-sourcerepository-components.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/cocoon-xml-impl.xml"/>
+  
+</beans>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.