tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drobia...@apache.org
Subject svn commit: r928373 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/internal/services/ test/app4/ test/java/org/apache/tapestry5/integration/app4/ test/java/org/apache/tapestry5/integration/app4/pages/ test/java/org/apa...
Date Sun, 28 Mar 2010 11:04:16 GMT
Author: drobiazko
Date: Sun Mar 28 11:04:16 2010
New Revision: 928373

URL: http://svn.apache.org/viewvc?rev=928373&view=rev
Log:
TAP5-1086: Localized root path request results in a 404 error if Index page is not available

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Start.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/ImmediateModeTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Start.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java?rev=928373&r1=928372&r2=928373&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
Sun Mar 28 11:04:16 2010
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.internal.services;
 
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.InternalConstants;
 import org.apache.tapestry5.ioc.Invokable;
 import org.apache.tapestry5.ioc.annotations.Inject;
@@ -43,6 +44,8 @@ public class ComponentClassResolverImpl 
     private final ClassNameLocator classNameLocator;
 
     private final String appRootPackage;
+    
+    private final String startPageName;
 
     // Map from folder name to a list of root package names.
     // The key does not begin or end with a slash.
@@ -102,6 +105,10 @@ public class ComponentClassResolverImpl 
     @Inject
     @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
     String appRootPackage,
+    
+    @Inject
+    @Symbol(SymbolConstants.START_PAGE_NAME)
+    String startPageName,
 
     Collection<LibraryMapping> mappings)
     {
@@ -110,6 +117,7 @@ public class ComponentClassResolverImpl 
         this.classNameLocator = classNameLocator;
 
         this.appRootPackage = appRootPackage;
+        this.startPageName = startPageName;
 
         addPackagesToInstantiatorSource(this.appRootPackage);
 
@@ -307,7 +315,7 @@ public class ComponentClassResolverImpl 
 
                 String lastTerm = lastSlashx < 0 ? logicalName : logicalName.substring(lastSlashx
+ 1);
 
-                if (lastTerm.equalsIgnoreCase("index"))
+                if (lastTerm.equalsIgnoreCase("index") || lastTerm.equalsIgnoreCase(startPageName))
                 {
                     String reducedName = lastSlashx < 0 ? "" : logicalName.substring(0,
lastSlashx);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Start.tml?rev=928373&r1=928372&r2=928373&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Start.tml Sun Mar 28 11:04:16 2010
@@ -5,7 +5,10 @@
 
     <body>
 
-        <h1>Start</h1>
+        <h1>Start Page</h1>
+        
+        <p>Index Page Exists: ${indexPageExists}</p>
+        <p>Start Page Exists: ${startPageExists}</p>
 
         <t:beaneditform object="this"/>
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/ImmediateModeTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/ImmediateModeTests.java?rev=928373&r1=928372&r2=928373&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/ImmediateModeTests.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/ImmediateModeTests.java
Sun Mar 28 11:04:16 2010
@@ -72,5 +72,33 @@ public class ImmediateModeTests extends 
                 "immediate mode");
 
     }
+    
+    /** TAP5-1086 */
+    @Test
+    public void localized_root_path_no_index_page()
+    {
+       openBaseURL();
+       assertTextPresent("Start Page");
+       
+       // This test relies on the fact that no 'Index' page is available 
+       // Following checks ensure that a refactoring (rename of Start to Index) breaks the
test
+       assertTextPresent("Index Page Exists: false");
+       assertTextPresent("Start Page Exists: true");
+       
+       open(getBaseURL()+"en");
+       assertTextPresent("Start Page");
+       
+       open(getBaseURL()+"start");
+       assertTextPresent("Start Page");
+       
+       open(getBaseURL()+"start/en");
+       assertTextPresent("Start Page");
+       
+       open(getBaseURL()+"index");
+       assertTextPresent("Start Page");
+       
+       open(getBaseURL()+"index/en");
+       assertTextPresent("Start Page");
+    }
 
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Start.java?rev=928373&r1=928372&r2=928373&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Start.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Start.java
Sun Mar 28 11:04:16 2010
@@ -15,13 +15,29 @@
 package org.apache.tapestry5.integration.app4.pages;
 
 import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.ComponentClassResolver;
 
 public class Start
 {
     @InjectPage
     private Destination destination;
+    
+    @Inject
+    private ComponentClassResolver componentClassResolver;
 
     private String input;
+    
+    
+    public boolean getIndexPageExists()
+    {
+        return componentClassResolver.isPageName("Index");
+    }
+    
+    public boolean getStartPageExists()
+    {
+        return componentClassResolver.isPageName("Start");
+    }
 
     public String getInput()
     {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java?rev=928373&r1=928372&r2=928373&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java
Sun Mar 28 11:04:16 2010
@@ -41,12 +41,13 @@ public class ComponentClassResolverImplT
 
     private static final String LIB_ROOT_PACKAGE = "org.example.lib";
 
+    
     private ComponentClassResolverImpl create(Logger logger, ComponentInstantiatorSource
source,
             ClassNameLocator locator, LibraryMapping... mappings)
     {
         List<LibraryMapping> list = Arrays.asList(mappings);
 
-        return new ComponentClassResolverImpl(logger, source, locator, APP_ROOT_PACKAGE,
list);
+        return new ComponentClassResolverImpl(logger, source, locator, APP_ROOT_PACKAGE,
"Start", list);
     }
 
     private Logger compliantLogger()
@@ -155,6 +156,34 @@ public class ComponentClassResolverImplT
 
         verify();
     }
+    
+    @Test
+    public void canonicalize_start_page()
+    {
+        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
+        ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
+
+        train_for_app_packages(source);
+
+        String className = APP_ROOT_PACKAGE + ".pages.HomePage";
+
+        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", className);
+
+        replay();
+        
+        List<LibraryMapping> mappings = Arrays.asList();
+
+        ComponentClassResolver resolver = new ComponentClassResolverImpl(logger, source,
locator, APP_ROOT_PACKAGE, "HomePage", mappings);
+
+        assertEquals(resolver.canonicalizePageName("HomePage"), "HomePage");
+        assertEquals(resolver.canonicalizePageName(""), "HomePage");
+        assertTrue(resolver.isPageName("HomePage"));
+
+        verify();
+    }
+    
+    
 
     @Test
     public void page_name_in_subfolder()



Mime
View raw message