Author: ard
Date: Tue Sep 11 09:18:09 2012
New Revision: 1383307

URL: http://svn.apache.org/viewvc?rev=1383307&view=rev
Log:
RAVE-695 remove unneeded PageDefinitions interface and initial check in for 
EnhancedPagesConfigManager unit tests

Added:
    
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/PageRoutesManagerImplTest.java
    
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-routes-manager-impl-test-config.xml
Removed:
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/PageDefinitions.java
Modified:
    rave/sandbox/content-services/pom.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/EnhancedPagesConfigManager.java
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPageDefinitions.java
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
    
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/config/JaxbMappingsTest.java

Modified: rave/sandbox/content-services/pom.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/pom.xml?rev=1383307&r1=1383306&r2=1383307&view=diff
==============================================================================
--- rave/sandbox/content-services/pom.xml (original)
+++ rave/sandbox/content-services/pom.xml Tue Sep 11 09:18:09 2012
@@ -189,7 +189,7 @@
     <module>rave-jcr-integration</module>
     <module>rave-jcr-utils</module>
     <module>rave-web-hmvc</module>
-    <module>rave-web-jcr</module>
+    <!--<module>rave-web-jcr</module>-->
     <module>rave-jcr-tools</module>
     <!-- disable incomple simple-app module
     <module>simple-app</module>

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/EnhancedPagesConfigManager.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/EnhancedPagesConfigManager.java?rev=1383307&r1=1383306&r2=1383307&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/EnhancedPagesConfigManager.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/EnhancedPagesConfigManager.java
 Tue Sep 11 09:18:09 2012
@@ -20,16 +20,15 @@ package org.apache.rave.portal.web.mvc.c
 
 /**
  * <p>
- *  This {@link EnhancedPagesConfigManager} is about enhancing and validating 
{@link PageDefinitions} and {@link PagesConfig}s.
+ *  This {@link EnhancedPagesConfigManager} is about enhancing and validating 
{@link PageDefinition}s and {@link PagesConfig}s.
  *  It takes a {@link PagesConfigManager} implementation as constructor 
argument. Typically, this delegate {@link PagesConfigManager}
- *  gets its {@link PageDefinitions} and {@link Config} bootstrapped from 
either file system sources,
+ *  gets its {@link PageDefinition}s and {@link Config} bootstrapped from 
either file system sources,
  *  or sources stored in some repository, like {@link javax.jcr.Repository}. 
  * </p>
  * <p>
  *  This {@link EnhancedPagesConfigManager} is agnostic about the backing 
storage, but is targeting the glue between the
  *  {@link Route} and {@link PageDefinition}s and about the enhancement like 
resolving
- *  the <code>extend</code> logic of the {@link PageDefinition}s and {@link 
PageFragment}s of the 
-
+ *  the <code>extend</code> logic of the {@link PageDefinition}s and {@link 
PageFragment}s of the
  * </p>
  */
 public class EnhancedPagesConfigManager implements PagesConfigManager {

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPageDefinitions.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPageDefinitions.java?rev=1383307&r1=1383306&r2=1383307&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPageDefinitions.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPageDefinitions.java
 Tue Sep 11 09:18:09 2012
@@ -25,17 +25,13 @@ import javax.xml.bind.annotation.XmlAttr
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.rave.portal.web.mvc.config.PageDefinitions;
 import org.apache.rave.portal.web.mvc.config.PageDefinition;
 import org.apache.rave.portal.web.mvc.config.PageFragment;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 @XmlRootElement(name = "pageDefinitions")
-public class XmlPageDefinitions implements PageDefinitions {
+public class XmlPageDefinitions {
 
-    private static final Logger log = 
LoggerFactory.getLogger(XmlPageDefinitions.class);
     private String name;
 
     private List<PageDefinition> pageDefinitions;
@@ -51,7 +47,6 @@ public class XmlPageDefinitions implemen
     }
 
     @XmlElement(name = "pageDefinition", type = XmlPageDefinition.class)
-    @Override
     public List<PageDefinition> getPageDefinitions() {
         return pageDefinitions;
     }

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java?rev=1383307&r1=1383306&r2=1383307&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/mvc/config/xml/XmlPagesConfigManager.java
 Tue Sep 11 09:18:09 2012
@@ -33,7 +33,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.rave.portal.web.mvc.config.InvalidConfigurationException;
 import org.apache.rave.portal.web.mvc.config.PageDefinition;
-import org.apache.rave.portal.web.mvc.config.PageDefinitions;
 import org.apache.rave.portal.web.mvc.config.PagesConfig;
 import org.apache.rave.portal.web.mvc.config.PagesConfigManager;
 import org.apache.rave.portal.web.mvc.config.Route;
@@ -123,7 +122,7 @@ public class XmlPagesConfigManager imple
                 throw new InvalidConfigurationException("Both 
configurationPath and urlMappingsPath should be set " +
                         "to point to file location");
             }
-            PageDefinitions pageDefinitions = getPageDefinitions();
+            XmlPageDefinitions pageDefinitions = getPageDefinitions();
             if (pageDefinitions == null) {
                 throw new InvalidConfigurationException("Provided 
PageDefinitions was null");
             }
@@ -156,7 +155,7 @@ public class XmlPagesConfigManager imple
         }
     }
 
-    public PageDefinitions getPageDefinitions() {
+    public XmlPageDefinitions getPageDefinitions() {
         log.info("Loading configuration: {}", configurationPath);
 
         InputStream is = null;
@@ -171,7 +170,7 @@ public class XmlPagesConfigManager imple
             }
             JAXBContext context = 
JAXBContext.newInstance(XmlPageDefinitions.class);
             Unmarshaller unmarshaller = context.createUnmarshaller();
-            return (PageDefinitions) unmarshaller.unmarshal(is);
+            return (XmlPageDefinitions) unmarshaller.unmarshal(is);
         } catch (JAXBException e) {
             throw new InvalidConfigurationException("Error parsing 
configuration file: " + configurationPath, e);
         } finally {

Added: 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/PageRoutesManagerImplTest.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/PageRoutesManagerImplTest.java?rev=1383307&view=auto
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/PageRoutesManagerImplTest.java
 (added)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/PageRoutesManagerImplTest.java
 Tue Sep 11 09:18:09 2012
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package org.apache.rave.portal.web.mvc;
+
+import java.util.Map;
+
+import org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager;
+import org.apache.rave.portal.web.mvc.config.PageDefinition;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({"classpath:page-routes-manager-impl-test-config.xml"})
+public class PageRoutesManagerImplTest {
+
+    @Autowired
+    private ApplicationContext applicationContext;
+
+    @Test
+    public void noExtensionsPageRoutesManager() throws Exception {
+        EnhancedPagesConfigManager enhancedPagesConfigManager = 
(EnhancedPagesConfigManager)applicationContext.getBean("noExtensionsEnhancedPagesConfigManager");
+        final Map<String,PageDefinition> pageDefinitions = 
enhancedPagesConfigManager.getConfig().getPageDefinitions();
+
+        assertEquals(1, pageDefinitions.size());
+
+        final PageDefinition pageDefinition = pageDefinitions.get(0);
+        assertEquals("top", pageDefinition.getName());
+        assertNull(pageDefinition.getExtend());
+        assertNull(pageDefinition.getViewName());
+        assertEquals("org.apache.rave.unittest.NonExistingController", 
pageDefinition.getController());
+        assertEquals(3, pageDefinition.getChildren().size());
+    }
+
+
+    @Test
+    public void singlePageExtensionPageRoutesManager() throws Exception {
+        EnhancedPagesConfigManager enhancedPagesConfigManager = 
(EnhancedPagesConfigManager)applicationContext.getBean("singlePageExtensionEnhancedPagesConfigManager");
+        final Map<String,PageDefinition> pageDefinitions = 
enhancedPagesConfigManager.getConfig().getPageDefinitions();
+        assertEquals(4, pageDefinitions.size());
+    }
+
+
+}
+
+

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/config/JaxbMappingsTest.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/config/JaxbMappingsTest.java?rev=1383307&r1=1383306&r2=1383307&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/config/JaxbMappingsTest.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/mvc/config/JaxbMappingsTest.java
 Tue Sep 11 09:18:09 2012
@@ -40,7 +40,7 @@ public class JaxbMappingsTest {
     @Test
     public void testSinglePageDefintion() {
             String testSrc = "singlePageDefinition.xml";
-            final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+            final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
             
             assertNotNull(xmlPageDefinitions);
 
@@ -117,7 +117,7 @@ public class JaxbMappingsTest {
     @Test
     public void testMultiplPageDefintion() {
         String testSrc = "multiplePageDefintion.xml";
-        final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+        final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
         assertNotNull(xmlPageDefinitions);
 
         assertEquals("default", xmlPageDefinitions.getName());
@@ -146,7 +146,7 @@ public class JaxbMappingsTest {
     @Test
     public void testSinglePageFragment() {
         String testSrc = "singlePageFragment.xml";
-        final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+        final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
         assertNotNull(xmlPageDefinitions);
 
         assertEquals("default", xmlPageDefinitions.getName());
@@ -179,7 +179,7 @@ public class JaxbMappingsTest {
     @Test
     public void testMultiplePageFragment() {
         String testSrc = "multiplePageFragment.xml";
-        final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+        final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
         assertNotNull(xmlPageDefinitions);
 
         assertEquals("default", xmlPageDefinitions.getName());
@@ -201,7 +201,7 @@ public class JaxbMappingsTest {
     @Test
     public void testPageDefintionsAndRootPageFragments() {
         String testSrc = "pageDefintionsAndRootPageFragments.xml";
-        final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+        final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
         assertNotNull(xmlPageDefinitions);
 
         assertEquals("default", xmlPageDefinitions.getName());
@@ -221,7 +221,7 @@ public class JaxbMappingsTest {
     @Test
     public void testSameNameSiblings() {
         String testSrc = "sameNameSiblings.xml";
-        final PageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
+        final XmlPageDefinitions xmlPageDefinitions = 
loadPageConfiguration(testSrc);
         assertNotNull(xmlPageDefinitions);
 
         assertEquals("default", xmlPageDefinitions.getName());
@@ -237,7 +237,7 @@ public class JaxbMappingsTest {
         assertTrue(fragment1.getName().equals(fragment2.getName()));
     }
 
-    public static PageDefinitions loadPageConfiguration(String configPath) {
+    public static XmlPageDefinitions loadPageConfiguration(String configPath) {
         InputStream is = null;
         String testSrc = TEST_CONFIG_PATH_JAXB_MAPPINGS + "/" + configPath;
         try {
@@ -248,7 +248,7 @@ public class JaxbMappingsTest {
             }
             JAXBContext context = 
JAXBContext.newInstance(XmlPageDefinitions.class);
             Unmarshaller unmarshaller = context.createUnmarshaller();
-            return (PageDefinitions) unmarshaller.unmarshal(is);
+            return (XmlPageDefinitions) unmarshaller.unmarshal(is);
         } catch (JAXBException e) {
             throw new InvalidConfigurationException("Error parsing 
configuration file: " + testSrc, e);
         } finally {

Added: 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-routes-manager-impl-test-config.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-routes-manager-impl-test-config.xml?rev=1383307&view=auto
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-routes-manager-impl-test-config.xml
 (added)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/page-routes-manager-impl-test-config.xml
 Tue Sep 11 09:18:09 2012
@@ -0,0 +1,73 @@
+<!--
+  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.xsd";>
+
+
+  <bean id="noExtensionsEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/noExtensionsPageDefinitions.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+  <bean id="singlePageExtensionEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/singlePageExtensionPageDefinitions.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+  <bean id="hierarchicalMultiplePageExtensionEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/hierarchicalMultiplePageExtension.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+  <bean id="complexExtensionsEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/complexExtensionsPageRoutesManager.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+  <bean id="recursiveExtensionsEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/recursiveExtensionsPageRoutesManager.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+  <bean id="pageFragmentExtensionsEnhancedPagesConfigManager" 
class="org.apache.rave.portal.web.mvc.config.EnhancedPagesConfigManager">
+    <constructor-arg>
+      <bean 
class="org.apache.rave.portal.web.mvc.config.xml.XmlPagesConfigManager">
+        <property name="configurationPath" 
value="classpath:testmappings/pageFragmentExtensionsPageRoutesManager.xml"/>
+      </bean>
+    </constructor-arg>
+  </bean>
+
+</beans>
+


Reply via email to