You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2006/12/05 18:35:14 UTC

svn commit: r482719 [3/4] - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/annotations/ main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/jav...

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/infrastructure.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/infrastructure.apt?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/infrastructure.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/infrastructure.apt Tue Dec  5 09:35:05 2006
@@ -7,17 +7,20 @@
   Tapestry includes an object provider, "infrastructure:", which is used to access
   the key built-in services provided by Tapestry.  This allows you to inject, 
   into  your components or services, any of the services, using a shorter name, i.e.,
-  "infrastructure:request" vs. "service:tapestry.WebRequest".
+  "infrastructure:Request" vs. "service:tapestry.Request".
 
-  This functionaliy serves a separate, and ultimately more important purpose.
+  This functionaliy serves a separate, and ultimately more important, purpose.
   
   In the vast majority of applications developed using Tapestry, the built in set of 
   services does exactly what you need them to do. However, there are always outliers,
-  very special cases that aren't addressed. The infrastructure mechanism 
+  very special cases that aren't addressed. The infrastructure mechanism includes the ability
+  to <<override>> these services.  If infrastructure:AssetSource doesn't do quite what you need,
+  you will be able to provide your own service and make that infrastructure:AssetSource. It will be
+  your implementation that is injected into both your own services and components and the
+  services built into Tapestry (both public and internal).
 
 infrastructure: object provider
 
-
   The infrastructure 
   {{{http://tapestry.apache.org/tapestry5/tapestry-ioc/provider.html}object provider}} 
   is a key element in making Tapestry extensible; it adds a layer of
@@ -43,59 +46,73 @@
   In many cases, the original service can be injected into the new implementation; this must be done
   using the original service's fully qualified service id.
   
-  The following table identifies the properties that are available via the infrastructure provider
+  The following table identifies the services that are available via the infrastructure provider
   by default:
   
-  [assetSource]
+  [AssetSource]
     {{{../apidocs/org/apache/tapestry/services/AssetSource.html}AssetSource}} (tapestry.AssetSource)
     
     Obtains assets from public and internal resources.
+    
+  [ClasspathAssetAliasManager]
+    {{{../apidocs/org/apache/tapestry/services/ClasspathAssetAliasManager.html}ClasspathAssetAliasManager}} (tapestry.ClasspathAssetAliasManager)
+  
+    Used to convert resource paths for classpath resources into client URLs, which includes a configurable way of assigning
+    path aliases (resulting in shorter, more readable URLs).
   
-  [bindingSource]
+  [BindingSource]
     {{{../apidocs/org/apache/tapestry/services/BindingSource.html}BindingSource}} (tapestry.BindingSource)
     
     Central factory for creating all types of component Binding objects.
   
-  [componentSource]
-  	{{{../apidocs/org/apache/tapestry/services/ComponentSource.html}ComponentSource}} (tapestry.ComponentSource)
-  	
-  	Used to retrieve component instances via their complete id.
-  	
-  [componentMessagesSource]
+   	
+  [ComponentMessagesSource]
   	{{{../apidocs/org/apache/tapestry/services/ComponentMessagesSource.html}ComponentMessagesSource}} (tapestry.ComponentMessagesSource)
   	
   	Access to message catalogs for components.
   	
-  [environment]
+ [ComponentSource]
+  	{{{../apidocs/org/apache/tapestry/services/ComponentSource.html}ComponentSource}} (tapestry.ComponentSource)
+  	
+  	Used to retrieve component instances via their complete id.
+
+  [Environment]
     {{{../apidocs/org/apache/tapestry/services/Environment.html}Environment}} (tapestry.Environment)
     
     Used to access environmental services (typically, to install a new environmental service).
 
-  [markupWriterFactory]
+  [MarkupWriterFactory]
     {{{../apidocs/org/apache/tapestry/services/MarkupWriterFactory.html}MarkupWriterFactory}} (tapestry.MarkupWriterFactory)
     
     Used as a source for MarkupWriter instances.
     
-  [persistentFieldManager]
+  [PersistentFieldManager]
     {{{../apidocs/org/apache/tapestry/services/PersistentFieldManager.html}PersistentFieldManager}} (tapestry.PersistentFieldManager)
     
     Main access point between components and persistent field storage.  Delegates out most behavior to
     particular persistent strategies.
     
-  [request]
-    {{{../apidocs/org/apache/tapestry/services/WebRequest.html}WebRequest}}  (tapestry.WebRequest)
+  [Request]
+    {{{../apidocs/org/apache/tapestry/services/Request.html}Request}}  (tapestry.Request)
     
      The current request object (for the current thread).        
      
-  [response]
-    {{{../apidocs/org/apache/tapestry/services/WebResponse.html}WebResponse}}  (tapestry.WebResponse)
+  [ResourceDigestGenerator]
+    {{{../apidocs/org/apache/tapestry/services/ResourceDigestGenerator.html}ResourceDigestGenerator}} (tapestry.ResourceDigestGenerator)
+    
+    Responsible for identifying which classpath resources require a digest as part of thier URL, and generates the digest for files
+    as needed.  Digests are required for files which represent a security hazard, such as Java class files.
+       
+  [Response]
+    {{{../apidocs/org/apache/tapestry/services/Response.html}Response}}  (tapestry.Response)
     
     The current response object (for the current thread).
     
-  [typeCoercer]
+  [TypeCoercer]
     {{{http://tapestry.apache.org/tapestry5/tapestry-ioc/org/apache/tapestry/ioc/services/TypeCoercer.html}TypeCoercer}} (tapestry.ioc.TypeCoercer)
     
-    Used to coerce values from one type to another (such as string to integer).
+    Used to coerce values from one type to another (such as string to integer). Used throughout Tapestry, especially including
+    parameter type coercions.
 
 Contributing to Infrastructure
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/inject.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/inject.apt?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/inject.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/inject.apt Tue Dec  5 09:35:05 2006
@@ -46,11 +46,11 @@
   Example:
   
 +----+
-@Inject("infrastructure:request")
-private WebRequest _request;
+@Inject("infrastructure:Request")
+private Request _request;
 +----+
 
-  Here, a component requires access to the current WebRequest object, which is defined in tapestry.Infrastructure using the key "request".
+  Here, a component requires access to the current Request object, which is defined in tapestry.Infrastructure using the key "request".
   
 * Annonymous Injection
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/request.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/request.apt?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/request.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/request.apt Tue Dec  5 09:35:05 2006
@@ -35,18 +35,18 @@
     service. This is a threaded service that stores per-thread/per-request information.
     
   * It wraps the request and response as a
-    {{{../apidocs/org/apache/tapestry/services/WebRequest.html}WebRequest}} and
-    {{{../apidocs/org/apache/tapestry/services/WebResponse.html}WebResponse}}, and passes them into the
-    {{{../apidocs/org/apache/tapestry/services/WebRequestHandler.html}tapestry.WebRequestHandler}} pipeline.
+    {{{../apidocs/org/apache/tapestry/services/Request.html}Request}} and
+    {{{../apidocs/org/apache/tapestry/services/Response.html}Response}}, and passes them into the
+    {{{../apidocs/org/apache/tapestry/services/RequestHandler.html}tapestry.RequestHandler}} pipeline.
  
   []
      
-WebRequestHandler Pipeline
+RequestHandler Pipeline
  
-   This pipeline is where most extensions related to requests take place.  WebRequest represents an abstraction on top of HttpServletRequest; this
+   This pipeline is where most extensions related to requests take place.  Request represents an abstraction on top of HttpServletRequest; this
    is necessary to support non-servlet applications, such as portlet applications. Where other code and services within
    Tapestry require access to information in the request, such as query parameters, that information is obtained from the
-   WebRequest (or WebResponse) objects.
+   Request (or Response) objects.
    
    The pipeline includes two built-in filters.  One filter is responsible for {{{reload.html}class and template reloading}}.
    
@@ -56,7 +56,7 @@
    
    <<TODO: Describe request dispatch, once that is understood.>>
    
-   The terminator for this pipeline stores the WebRequest and the WebResponse into RequestGlobals.
+   The terminator for this pipeline stores the Request and the Response into RequestGlobals.
    
 RequestGlobals Service
 
@@ -64,13 +64,13 @@
   has a lifecycle of perthread; this means that a seperate instance exists for every thread, and therefore,
   for every request.  The terminators of the two handler pipelines store the request/response pairs into the RequestGlobals service.
   
-WebRequest Service
+Request Service
 
-  The tapestry.WebRequest service is a 
+  The tapestry.Request service is a 
   {{{../ioc/shadow.html}shadow}}
   of the RequestGlobals services' request property. That is, any methods invoked
   on this service are delegated to the request object stored inside the RequestGlobals.
   
-  This service is also accessible with the object reference <<<infrastructure:request>>>.
+  This service is also accessible with the object reference <<<infrastructure:Request>>>.
    
   

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt Tue Dec  5 09:35:05 2006
@@ -31,6 +31,20 @@
   
   <<TODO: Is the ".html" template still useful? And do we need control over the template extension?>>
   
+Template Localization
+
+  Templates are {{{localization.html}localized}} in much the same way as individual files of a component's message
+  catalog: the effective locale is inserted into the name of the file.  Thus a German users will see the content
+  generated from <<<MyPage_de.html>>> and French users will see content generated from <<<MyPage_fr.html>>>.  When no
+  specific localization is available, the default location (<<<MyPage.html>>>) is used.  
+  
+Template Inheritance
+
+  If a component does not have a template, but extends from a component class that does have
+  a template, then the parent class' template will be used by the child component.
+  
+  This allows a component to extend from a base class but not have to duplicate the base class' template.
+    
 Tapestry Namespace
 
   Component templates should include the Tapestry namespace, defining it in the root element of the template.
@@ -59,7 +73,7 @@
 
   The \<comp\> element is used to identify an <embedded component> within the template.
   
-  Embedded components have two parameters:
+  Embedded components have three parameters:
   
   * id: A unique id for the component (within its container).
   
@@ -69,7 +83,7 @@
   
   [] 
   
-  Either id or type must be specified.
+  Either id or type <<must>> be specified.
   
   If the id attribute is ommitted, Tapestry will assign a unique id for the element.
   
@@ -175,6 +189,6 @@
   Tapestry 4 users will note that expansions are a concise, easy replacement for the
   Insert component, and for the \<span key="..."\> directive.
   
-  
+
   
   

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt Tue Dec  5 09:35:05 2006
@@ -15,7 +15,7 @@
   We're keeping the <essence> of Tapestry 4, but starting with a brand new code base designed
   to provide a stable, powerful, extensible platform for many years to come.
   
-  Here's a few of the planned features:
+  Here's a few of the planned and implemented features:
   
   * Simplified, minimal API based on annotations
   
@@ -102,5 +102,5 @@
   Finally, Tapestry 5 explicitly seperates actions (requests that change things) and rendering (requests that
   render pages) into two seperate requests.  Performing an action, such as clicking a link or submitting a form,
   results in a <client side redirect> to the new page. This is often called "redirect after post". This helps ensure
-  that URLs in the browser are book-markable ... but also requires that more information be stored in the session
+  that URLs in the browser are book-markable ... but also requires that a bit more information be stored in the session
   between requests (using the @Persist annotation).  

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html Tue Dec  5 09:35:05 2006
@@ -51,6 +51,9 @@
             <li>
                 <a href="AssetDemo.html">AssetDemo</a> -- declaring an using Assets
             </li>
+            <li>
+                <a href="ExpansionSubclass.html">ExpansionSubclass</a> -- components can inherit templates from base classes
+            </li>
             </ul>
         </p>
     </body>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Tue Dec  5 09:35:05 2006
@@ -14,6 +14,15 @@
 
 package org.apache.tapestry.integration;
 
+import static java.lang.String.format;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tapestry.ioc.Resource;
+import org.apache.tapestry.ioc.internal.util.ClasspathResource;
 import org.openqa.selenium.server.SeleniumServer;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
@@ -33,7 +42,7 @@
 {
     private static final int JETTY_PORT = 9999;
 
-    private static final String BASE_URL = "http://localhost:9999/";
+    private static final String BASE_URL = format("http://localhost:%d/", JETTY_PORT);
 
     /** 60 seconds */
     public static final String PAGE_LOAD_TIMEOUT = "600000";
@@ -63,8 +72,8 @@
     public void shutdownBackground() throws Exception
     {
         // Thread.sleep(10000);
-
         _selenium.stop();
+
         _selenium = null;
 
         _server.stop();
@@ -122,7 +131,7 @@
         clickAndWait("link=Inject Demo");
 
         // This is a test for a named @Inject:
-        assertTextPresent("<Proxy for tapestry.WebRequest(org.apache.tapestry.services.WebRequest)>");
+        assertTextPresent("<Proxy for tapestry.Request(org.apache.tapestry.services.Request)>");
 
         // This is a test for an annonymous @Inject and ComponentResourcesInjectionProvider
         assertTextPresent("ComponentResources[org.apache.tapestry.integration.app1.pages.InjectDemo]");
@@ -198,6 +207,16 @@
     }
 
     @Test
+    public void app1_subclass_inherits_parent_template()
+    {
+        _selenium.open(BASE_URL);
+
+        clickAndWait("link=ExpansionSubclass");
+
+        assertTextPresent("[value provided, in the subclass, via a template expansion]");
+    }
+
+    @Test
     public void app1_exception_report()
     {
         _selenium.open(BASE_URL);
@@ -321,18 +340,62 @@
     }
 
     @Test
-    public void app1_assets()
+    public void app1_assets() throws Exception
     {
         _selenium.open(BASE_URL);
         clickAndWait("link=AssetDemo");
 
         assertText("//img[@id='img']/@src", "/images/tapestry_banner.gif");
+
+        // This doesn't prove that the image shows up in the client browser (it does, but
+        // it could just as easily be a broken image). Haven't figured out how Selenium
+        // allows this to be verified. Note that the path below represents some aliasing
+        // of the raw classpath resource path.
+
+        assertText("//img[@id='img_0']/@src", "/asset/app1/pages/tapestry-button.png");
+
+        // Read the byte stream for the asset and compare to the real copy.
+
+        URL url = new URL("http", "localhost", JETTY_PORT, "/asset/app1/pages/tapestry-button.png");
+
+        byte[] downloaded = readContent(url);
+
+        Resource classpathResource = new ClasspathResource(
+                "org/apache/tapestry/integration/app1/pages/tapestry-button.png");
+
+        byte[] actual = readContent(classpathResource.toURL());
+
+        assertEquals(downloaded, actual);
+    }
+
+    private byte[] readContent(URL url) throws Exception
+    {
+        InputStream is = new BufferedInputStream(url.openStream());
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+        byte[] buffer = new byte[10000];
+
+        while (true)
+        {
+            int length = is.read(buffer);
+
+            if (length < 0)
+                break;
+
+            os.write(buffer, 0, length);
+        }
+
+        os.close();
+        is.close();
+
+        return os.toByteArray();
     }
 
     private void assertText(String locator, String expected)
     {
         String actual = null;
-        
+
         try
         {
             actual = _selenium.getText(locator);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AssetDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AssetDemo.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AssetDemo.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AssetDemo.java Tue Dec  5 09:35:05 2006
@@ -24,8 +24,16 @@
     @Inject("context:images/tapestry_banner.gif")
     private Asset _icon;
 
+    @Inject("tapestry-button.png")
+    private Asset _button;
+
     public Asset getIcon()
     {
         return _icon;
+    }
+
+    public Asset getButton()
+    {
+        return _button;
     }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/ExpansionSubclass.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/ExpansionSubclass.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/ExpansionSubclass.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/ExpansionSubclass.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,10 @@
+package org.apache.tapestry.integration.app1.pages;
+
+public class ExpansionSubclass extends Expansion
+{
+    @Override
+    public String getExpansionValue()
+    {
+        return "value provided, in the subclass, via a template expansion";
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/InjectDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/InjectDemo.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/InjectDemo.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/InjectDemo.java Tue Dec  5 09:35:05 2006
@@ -20,14 +20,14 @@
 import org.apache.tapestry.annotations.InjectPage;
 import org.apache.tapestry.annotations.OnEvent;
 import org.apache.tapestry.services.BindingSource;
-import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.Request;
 
 @ComponentClass
 public class InjectDemo
 {
     // Named
-    @Inject("infrastructure:request")
-    private WebRequest _request;
+    @Inject("infrastructure:Request")
+    private Request _request;
 
     // Via ComponentResourcesInjectionProvider
     @Inject
@@ -49,7 +49,7 @@
         return _bindingSource;
     }
 
-    public WebRequest getRequest()
+    public Request getRequest()
     {
         return _request;
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/Localization.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/Localization.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/Localization.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/Localization.java Tue Dec  5 09:35:05 2006
@@ -20,7 +20,7 @@
 import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.services.ClassFactory;
-import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.Request;
 
 @ComponentClass
 public class Localization
@@ -37,15 +37,15 @@
     @Inject
     private Locale _locale;
 
-    @Inject("infrastructure:request")
-    private WebRequest _request;
+    @Inject("infrastructure:Request")
+    private Request _request;
 
     public Locale getLocale()
     {
         return _locale;
     }
 
-    public WebRequest getRequest()
+    public Request getRequest()
     {
         return _request;
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/services/AppModule.java Tue Dec  5 09:35:05 2006
@@ -12,57 +12,61 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.integration.app1.services;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.OrderedConfiguration;
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.services.WebRequest;
-import org.apache.tapestry.services.WebRequestFilter;
-import org.apache.tapestry.services.WebRequestHandler;
-import org.apache.tapestry.services.WebResponse;
-
-/**
- * I was just dying to see how fast requests are!
- * 
- * 
- */
-@Id("app")
-public class AppModule
-{
-    public WebRequestFilter buildTimingFilter(final Log log)
-    {
-        return new WebRequestFilter()
-        {
-            public boolean service(WebRequest request, WebResponse response,
-                    WebRequestHandler handler) throws IOException
-            {
-                long startTime = System.currentTimeMillis();
-
-                try
-                {
-                    return handler.service(request, response);
-                }
-                finally
-                {
-                    long elapsed = System.currentTimeMillis() - startTime;
-
-                    log.info(String.format("Request time: %d ms", elapsed));
-                }
-            }
-        };
-    }
-
-    @Contribute("tapestry.WebRequestHandler")
-    public void contributeWebRequestFilters(OrderedConfiguration<WebRequestFilter> configuration,
-            @InjectService("TimingFilter")
-            WebRequestFilter filter)
-    {
-        configuration.add("Timing", filter);
-    }
-
-}
+package org.apache.tapestry.integration.app1.services;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.annotations.Contribute;
+import org.apache.tapestry.ioc.annotations.Id;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.RequestFilter;
+import org.apache.tapestry.services.RequestHandler;
+import org.apache.tapestry.services.Response;
+
+/**
+ * I was just dying to see how fast requests are!
+ */
+@Id("app")
+public class AppModule
+{
+    public RequestFilter buildTimingFilter(final Log log)
+    {
+        return new RequestFilter()
+        {
+            public boolean service(Request request, Response response,
+                    RequestHandler handler) throws IOException
+            {
+                long startTime = System.currentTimeMillis();
+
+                try
+                {
+                    return handler.service(request, response);
+                }
+                finally
+                {
+                    long elapsed = System.currentTimeMillis() - startTime;
+
+                    log.info(String.format("Request time: %d ms", elapsed));
+                }
+            }
+        };
+    }
+
+    @Contribute("tapestry.WebRequestHandler")
+    public void contributeRequestFilters(OrderedConfiguration<RequestFilter> configuration,
+            @InjectService("TimingFilter")
+            RequestFilter filter)
+    {
+        configuration.add("Timing", filter);
+    }
+
+    @Contribute("tapestry.ClasspathAssetAliasManager")
+    public void contributeAliases(MappedConfiguration<String, String> configuration)
+    {
+        configuration.add("app1/", "org/apache/tapestry/integration/app1/");
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetDispatcherTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetDispatcherTest.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetDispatcherTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetDispatcherTest.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,268 @@
+// Copyright 2006 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.tapestry.internal.services;
+
+import static org.easymock.EasyMock.contains;
+import static org.easymock.EasyMock.eq;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.Resource;
+import org.apache.tapestry.ioc.internal.util.ClasspathResource;
+import org.apache.tapestry.services.ClasspathAssetAliasManager;
+import org.apache.tapestry.services.Dispatcher;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
+import org.testng.annotations.Test;
+
+public class AssetDispatcherTest extends InternalBaseTestCase
+{
+    private static final String SMILEY_CLIENT_URL = "/asset/app1/pages/smiley.png";
+
+    private static final String SMILEY_PATH = "org/apache/tapestry/integration/app1/pages/smiley.png";
+
+    private static final Resource SMILEY = new ClasspathResource(SMILEY_PATH);
+
+    @Test
+    public void not_an_asset_request() throws Exception
+    {
+        Request request = newRequest();
+
+        train_getPath(request, "/foo/bar/Baz.gif");
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(null, null, null);
+
+        assertFalse(d.dispatch(request, null));
+
+        verify();
+    }
+
+    @Test
+    public void unprotected_asset() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+
+        train_getPath(request, SMILEY_CLIENT_URL);
+
+        train_toResourcePath(aliasManager, SMILEY_CLIENT_URL, SMILEY_PATH);
+
+        train_requiresDigest(cache, SMILEY, false);
+
+        train_getDateHeader(request, AssetDispatcher.IF_MODIFIED_SINCE_HEADER, -1);
+
+        streamer.streamResource(SMILEY);
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    @Test
+    public void protected_asset_without_an_extension() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+
+        String clientURL = "/asset/app1/pages/smiley_png";
+        String resourcePath = "org/apache/tapestry/integration/app1/pages/smiley_png";
+
+        train_getPath(request, clientURL);
+
+        train_toResourcePath(aliasManager, clientURL, resourcePath);
+
+        train_requiresDigest(cache, new ClasspathResource(resourcePath), true);
+
+        response.sendError(eq(HttpServletResponse.SC_FORBIDDEN), contains(resourcePath));
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    @Test
+    public void protected_asset_with_incorrect_digest_in_url() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+
+        String clientURL = "/asset/app1/pages/smiley.WRONG.png";
+        String resourcePath = "org/apache/tapestry/integration/app1/pages/smiley.WRONG.png";
+
+        train_getPath(request, clientURL);
+
+        train_toResourcePath(aliasManager, clientURL, resourcePath);
+
+        train_requiresDigest(cache, new ClasspathResource(resourcePath), true);
+
+        train_getDigest(cache, SMILEY, "RIGHT");
+
+        response.sendError(eq(HttpServletResponse.SC_FORBIDDEN), contains(SMILEY_PATH));
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    @Test
+    public void protected_asset_wth_correct_digest_in_url() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+
+        String clientURL = "/asset/app1/pages/smiley.RIGHT.png";
+        String resourcePath = "org/apache/tapestry/integration/app1/pages/smiley.RIGHT.png";
+
+        train_getPath(request, clientURL);
+
+        train_toResourcePath(aliasManager, clientURL, resourcePath);
+
+        train_requiresDigest(cache, new ClasspathResource(resourcePath), true);
+
+        train_getDigest(cache, SMILEY, "RIGHT");
+
+        train_getDateHeader(request, AssetDispatcher.IF_MODIFIED_SINCE_HEADER, -1);
+
+        streamer.streamResource(SMILEY);
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    protected final void train_getDigest(ResourceCache cache, Resource resource, String digest)
+    {
+        expect(cache.getDigest(resource)).andReturn(digest).atLeastOnce();
+    }
+
+    @Test
+    public void protected_asset_without_digest() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+
+        train_getPath(request, SMILEY_CLIENT_URL);
+
+        train_toResourcePath(aliasManager, SMILEY_CLIENT_URL, SMILEY_PATH);
+
+        train_requiresDigest(cache, SMILEY, true);
+
+        response.sendError(eq(HttpServletResponse.SC_FORBIDDEN), contains(SMILEY_PATH));
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    @Test
+    public void client_cache_upto_date() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+        long now = System.currentTimeMillis();
+
+        train_getPath(request, SMILEY_CLIENT_URL);
+
+        train_toResourcePath(aliasManager, SMILEY_CLIENT_URL, SMILEY_PATH);
+
+        train_requiresDigest(cache, SMILEY, false);
+
+        train_getDateHeader(request, AssetDispatcher.IF_MODIFIED_SINCE_HEADER, now);
+
+        train_getTimeModified(cache, SMILEY, now - 1000);
+
+        response.sendError(HttpServletResponse.SC_NOT_MODIFIED, "");
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+
+    @Test
+    public void client_cache_out_of_date() throws Exception
+    {
+        Request request = newRequest();
+        Response response = newResponse();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+        ResourceCache cache = newResourceCache();
+        ResourceStreamer streamer = newResourceStreamer();
+        long now = System.currentTimeMillis();
+
+        train_getPath(request, SMILEY_CLIENT_URL);
+
+        train_toResourcePath(aliasManager, SMILEY_CLIENT_URL, SMILEY_PATH);
+
+        train_requiresDigest(cache, SMILEY, false);
+
+        train_getDateHeader(request, AssetDispatcher.IF_MODIFIED_SINCE_HEADER, now - 1000);
+
+        train_getTimeModified(cache, SMILEY, now + 1000);
+
+        streamer.streamResource(SMILEY);
+
+        replay();
+
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+
+        assertTrue(d.dispatch(request, response));
+
+        verify();
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImplTest.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImplTest.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,93 @@
+// Copyright 2006 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.tapestry.internal.services;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.Map;
+
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.services.ClasspathAssetAliasManager;
+import org.apache.tapestry.services.Request;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class ClasspathAssetAliasManagerImplTest extends InternalBaseTestCase
+{
+
+    public Map<String, String> configuration()
+    {
+        Map<String, String> configuration = newMap();
+
+        configuration.put("tapestry/", "org/apache/tapestry/");
+        configuration.put("tapestry-internal/", "org/apache/tapestry/internal/");
+        configuration.put("mylib/", "com/example/mylib/");
+
+        return configuration;
+    }
+
+    @Test(dataProvider = "to_client_url_data")
+    public void to_client_url(String resourcePath, String expectedClientURL)
+    {
+        Request request = newRequest();
+
+        train_getContextPath(request, "/ctx");
+
+        replay();
+
+        ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(request,
+                configuration());
+
+        assertEquals(manager.toClientURL(resourcePath), "/ctx" + expectedClientURL);
+
+        verify();
+    }
+
+    @DataProvider(name = "to_client_url_data")
+    public Object[][] to_client_url_data()
+    {
+        return new Object[][]
+        {
+        { "foo/bar/Baz.txt", "/asset/foo/bar/Baz.txt" },
+        { "com/example/mylib/Foo.bar", "/asset/mylib/Foo.bar" },
+        { "com/example/mylib/nested/Foo.bar", "/asset/mylib/nested/Foo.bar" },
+        { "org/apache/tapestry/internal/Foo.bar", "/asset/tapestry-internal/Foo.bar" },
+        { "org/apache/tapestry/Foo.bar", "/asset/tapestry/Foo.bar" }, };
+    }
+
+    @Test(dataProvider = "to_resource_path_data")
+    public void to_resource_path(String clientURL, String expectedResourcePath)
+    {
+        ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(null,
+                configuration());
+
+        assertEquals(manager.toResourcePath(clientURL), expectedResourcePath);
+    }
+
+    @DataProvider(name = "to_resource_path_data")
+    public Object[][] to_resource_path_data()
+    {
+        Object[][] data = to_client_url_data();
+
+        for (Object[] pair : data)
+        {
+            Object buffer = pair[0];
+            pair[0] = pair[1];
+            pair[1] = buffer;
+        }
+
+        return data;
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetFactoryTest.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetFactoryTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ClasspathAssetFactoryTest.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,126 @@
+// Copyright 2006 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.tapestry.internal.services;
+
+import org.apache.tapestry.Asset;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.Resource;
+import org.apache.tapestry.ioc.internal.util.ClasspathResource;
+import org.apache.tapestry.services.AssetFactory;
+import org.apache.tapestry.services.ClasspathAssetAliasManager;
+import org.testng.annotations.Test;
+
+public class ClasspathAssetFactoryTest extends InternalBaseTestCase
+{
+    @Test
+    public void asset_client_URL_is_cached()
+    {
+        ResourceCache cache = newResourceCache();
+
+        Resource r = new ClasspathResource("foo/Bar.txt");
+
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+
+        train_requiresDigest(cache, r, false);
+
+        String expectedClientURL = "/context/asset/foo/Bar.txt";
+
+        train_toClientURL(aliasManager, "foo/Bar.txt", expectedClientURL);
+
+        replay();
+
+        ClasspathAssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+
+        Asset asset = factory.createAsset(r);
+
+        assertEquals(asset.toClientURL(), expectedClientURL);
+
+        // Now, to check the cache:
+
+        assertEquals(asset.toClientURL(), expectedClientURL);
+
+        verify();
+
+        // Now, to test cache clearing:
+        train_requiresDigest(cache, r, false);
+
+        train_toClientURL(aliasManager, "foo/Bar.txt", expectedClientURL);
+
+        replay();
+
+        factory.objectWasInvalidated();
+
+        assertEquals(asset.toClientURL(), expectedClientURL);
+
+        verify();
+    }
+
+    @Test
+    public void simple_asset_client_URL()
+    {
+        ResourceCache cache = newResourceCache();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+
+        Resource r = new ClasspathResource("foo/Bar.txt");
+
+        train_requiresDigest(cache, r, false);
+
+        String expectedClientURL = "/context/asset/foo/Bar.txt";
+
+        train_toClientURL(aliasManager, "foo/Bar.txt", expectedClientURL);
+
+        replay();
+
+        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+
+        Asset asset = factory.createAsset(r);
+
+        assertSame(asset.getResource(), r);
+        assertEquals(asset.toClientURL(), expectedClientURL);
+        assertEquals(asset.toString(), asset.toClientURL());
+
+        verify();
+    }
+
+    @Test
+    public void protected_asset_client_URL()
+    {
+        ResourceCache cache = newResourceCache();
+        ClasspathAssetAliasManager aliasManager = newClasspathAssetAliasManager();
+
+        Resource r = new ClasspathResource("foo/Bar.txt");
+
+        train_requiresDigest(cache, r, true);
+
+        expect(cache.getDigest(r)).andReturn("ABC123");
+
+        String expectedClientURL = "/context/asset/foo/Bar.ABC123.txt";
+
+        train_toClientURL(aliasManager, "foo/Bar.ABC123.txt", expectedClientURL);
+
+        replay();
+
+        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);
+
+        Asset asset = factory.createAsset(r);
+
+        assertSame(asset.getResource(), r);
+        assertEquals(asset.toClientURL(), expectedClientURL);
+        assertEquals(asset.toString(), asset.toClientURL());
+
+        verify();
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java Tue Dec  5 09:35:05 2006
@@ -29,7 +29,7 @@
     @BeforeClass
     public void setup_coercer()
     {
-        _coercer = getObject("infrastructure:typeCoercer", TypeCoercer.class);
+        _coercer = getObject("infrastructure:TypeCoercer", TypeCoercer.class);
     }
 
     @AfterClass

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentTemplateSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentTemplateSourceImplTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentTemplateSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentTemplateSourceImplTest.java Tue Dec  5 09:35:05 2006
@@ -12,170 +12,208 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.internal.services;
-
-
-import java.io.File;
-import java.net.URLClassLoader;
-import java.util.Locale;
-
-import org.apache.tapestry.events.InvalidationListener;
-import org.apache.tapestry.internal.parser.ComponentTemplate;
-import org.apache.tapestry.internal.test.InternalBaseTestCase;
+package org.apache.tapestry.internal.services;
+
+import java.io.File;
+import java.net.URLClassLoader;
+import java.util.Locale;
+
+import org.apache.tapestry.events.InvalidationListener;
+import org.apache.tapestry.internal.parser.ComponentTemplate;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.ioc.internal.util.ClasspathResource;
-import org.testng.annotations.Test;
-
-/**
- * 
- */
-public class ComponentTemplateSourceImplTest extends InternalBaseTestCase
-{
-    private static final String PACKAGE = "org.apache.tapestry.internal.pageload";
-
-    static public final String PATH = "org/apache/tapestry/internal/pageload";
-
-    private final ClassLoader _loader = Thread.currentThread().getContextClassLoader();
-
-    @Test
-    public void caching()
-    {
-        Resource r = newResource("Fred.html");
-
-        TemplateParser parser = newTemplateParser();
-        ComponentTemplate template = newComponentTemplate();
-
-        train_parseTemplate(parser, r, template);
-
-        replay();
-
-        ComponentTemplateSource source = new ComponentTemplateSourceImpl(parser);
-
-        String name = PACKAGE + ".Fred";
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        // A second pass will test the caching (the
-        // parser is not invoked).
-
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        verify();
-    }
-
-    /** Tests resource invalidation. */
-    @Test
-    public void invalidation() throws Exception
-    {
-        File rootDir = createClasspathRoot();
-        URLClassLoader loader = newLoaderWithClasspathRoot(rootDir);
-
-        File packageDir = new File(rootDir, "baz");
-        packageDir.mkdirs();
-
-        File f = new File(packageDir, "Biff.html");
-
-        f.createNewFile();
-
-        Resource localized = new ClasspathResource(loader, "baz/Biff.html");
-
-        TemplateParser parser = newTemplateParser();
-        ComponentTemplate template = newComponentTemplate();
-        InvalidationListener listener = newMock(InvalidationListener.class);
-
-        train_parseTemplate(parser, localized, template);
-
-        replay();
-
-        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(loader, parser);
-        source.addInvalidationListener(listener);
-
-        String name = "baz.Biff";
-
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        // Check for updates (which won't be found).
-        source.checkForUpdates();
-
-        // A second pass will test the caching (the
-        // parser is not invoked).
-
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        verify();
-
-        // Now, change the file and process an UpdateEvent.
-
-        touch(f);
-
-        listener.objectWasInvalidated();
-
-        replay();
-
-        // Check for updates (which will be found).
-        source.checkForUpdates();
-
-        verify();
-
-        // Check that the cache really is cleared.
-
-        train_parseTemplate(parser, localized, template);
-
-        replay();
-
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        verify();
-    }
-
-    /** Checks that localization to the same resource works (w/ caching). */
-    @Test
-    public void localization_to_same()
-    {
-        Resource r = newResource("Fred.html");
-
-        TemplateParser parser = newTemplateParser();
-        ComponentTemplate template = newComponentTemplate();
-
-        train_parseTemplate(parser, r, template);
-
-        replay();
-
-        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser);
-
-        String name = PACKAGE + ".Fred";
-        assertSame(source.getTemplate(name, Locale.ENGLISH), template);
-
-        // A second pass finds the same resource, but using a different
-        // path/locale combination.
-
-        assertSame(source.getTemplate(name, Locale.FRENCH), template);
-
-        // A third pass should further demonstrate the caching.
-
-        assertSame(source.getTemplate(name, Locale.FRENCH), template);
-
-        verify();
-    }
-
-    @Test
-    public void not_found()
-    {
-        TemplateParser parser = newTemplateParser();
-
-        replay();
-
-        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser);
-
-        String name = PACKAGE + ".Barney";
-        ComponentTemplate template = source.getTemplate(name, Locale.ENGLISH);
-        
-        assertTrue(template.isMissing());
-
-        verify();
-    }
-
-    private Resource newResource(String name)
-    {
-        return new ClasspathResource(_loader, PATH + "/" + name);
-    }
-}
+import org.apache.tapestry.model.ComponentModel;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ */
+public class ComponentTemplateSourceImplTest extends InternalBaseTestCase
+{
+    private static final String PACKAGE = "org.apache.tapestry.internal.pageload";
+
+    static public final String PATH = "org/apache/tapestry/internal/pageload";
+
+    private final ClassLoader _loader = Thread.currentThread().getContextClassLoader();
+
+    @Test
+    public void caching()
+    {
+        Resource r = newResource("Fred.html");
+
+        TemplateParser parser = newTemplateParser();
+        ComponentTemplate template = newComponentTemplate();
+        ComponentModel model = newComponentModel();
+
+        train_getComponentClassName(model, PACKAGE + ".Fred");
+
+        train_parseTemplate(parser, r, template);
+
+        replay();
+
+        ComponentTemplateSource source = new ComponentTemplateSourceImpl(parser);
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        // A second pass will test the caching (the
+        // parser is not invoked).
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        verify();
+    }
+
+    /** Tests resource invalidation. */
+    @Test
+    public void invalidation() throws Exception
+    {
+        File rootDir = createClasspathRoot();
+        URLClassLoader loader = newLoaderWithClasspathRoot(rootDir);
+        ComponentModel model = newComponentModel();
+
+        File packageDir = new File(rootDir, "baz");
+        packageDir.mkdirs();
+
+        File f = new File(packageDir, "Biff.html");
+
+        f.createNewFile();
+
+        Resource localized = new ClasspathResource(loader, "baz/Biff.html");
+
+        TemplateParser parser = newTemplateParser();
+        ComponentTemplate template = newComponentTemplate();
+        InvalidationListener listener = newInvalidationListener();
+
+        train_getComponentClassName(model, "baz.Biff");
+
+        train_parseTemplate(parser, localized, template);
+
+        replay();
+
+        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(loader, parser);
+        source.addInvalidationListener(listener);
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        // Check for updates (which won't be found).
+        source.checkForUpdates();
+
+        // A second pass will test the caching (the
+        // parser is not invoked).
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        verify();
+
+        // Now, change the file and process an UpdateEvent.
+
+        touch(f);
+
+        listener.objectWasInvalidated();
+
+        replay();
+
+        // Check for updates (which will be found).
+        source.checkForUpdates();
+
+        verify();
+
+        // Check that the cache really is cleared.
+
+        train_getComponentClassName(model, "baz.Biff");
+
+        train_parseTemplate(parser, localized, template);
+
+        replay();
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        verify();
+    }
+
+    /** Checks that localization to the same resource works (w/ caching). */
+    @Test
+    public void localization_to_same()
+    {
+        Resource r = newResource("Fred.html");
+
+        TemplateParser parser = newTemplateParser();
+        ComponentTemplate template = newComponentTemplate();
+        ComponentModel model = newComponentModel();
+
+        train_getComponentClassName(model, PACKAGE + ".Fred");
+
+        train_parseTemplate(parser, r, template);
+
+        replay();
+
+        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser);
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        // A second pass finds the same resource, but using a different
+        // path/locale combination.
+
+        assertSame(source.getTemplate(model, Locale.FRENCH), template);
+
+        // A third pass should further demonstrate the caching.
+
+        assertSame(source.getTemplate(model, Locale.FRENCH), template);
+
+        verify();
+    }
+
+    @Test
+    public void no_template_found()
+    {
+        TemplateParser parser = newTemplateParser();
+        ComponentModel model = newComponentModel();
+
+        train_getComponentClassName(model, PACKAGE + ".Barney");
+
+        train_getParentModel(model, null);
+
+        replay();
+
+        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser);
+
+        ComponentTemplate template = source.getTemplate(model, Locale.ENGLISH);
+
+        assertTrue(template.isMissing());
+
+        verify();
+    }
+
+    @Test
+    public void child_component_inherits_parent_template()
+    {
+        Resource r = newResource("Fred.html");
+
+        TemplateParser parser = newTemplateParser();
+        ComponentTemplate template = newComponentTemplate();
+        ComponentModel model = newComponentModel();
+        ComponentModel parentModel = newComponentModel();
+
+        train_getComponentClassName(model, PACKAGE + ".Barney");
+
+        train_getParentModel(model, parentModel);
+
+        train_getComponentClassName(parentModel, PACKAGE + ".Fred");
+
+        train_parseTemplate(parser, r, template);
+
+        replay();
+
+        ComponentTemplateSource source = new ComponentTemplateSourceImpl(parser);
+
+        assertSame(source.getTemplate(model, Locale.ENGLISH), template);
+
+        verify();
+    }
+
+    private Resource newResource(String name)
+    {
+        return new ClasspathResource(_loader, PATH + "/" + name);
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextAssetFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextAssetFactoryTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextAssetFactoryTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextAssetFactoryTest.java Tue Dec  5 09:35:05 2006
@@ -18,8 +18,8 @@
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.services.AssetFactory;
-import org.apache.tapestry.services.WebContext;
-import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.Context;
+import org.apache.tapestry.services.Request;
 import org.testng.annotations.Test;
 
 public class ContextAssetFactoryTest extends InternalBaseTestCase
@@ -27,8 +27,8 @@
     @Test
     public void root_resource()
     {
-        WebContext context = newWebContext();
-        WebRequest request = newWebRequest();
+        Context context = newContext();
+        Request request = newRequest();
 
         replay();
 
@@ -40,10 +40,12 @@
     }
 
     @Test
-    public void generated_asset()
+    public void asset_client_URL()
     {
-        WebContext context = newWebContext();
-        WebRequest request = newWebRequest();
+        Context context = newContext();
+        Request request = newRequest();
+
+        Resource r = new ContextResource(context, "foo/Bar.txt");
 
         train_getContextPath(request, "/context");
 
@@ -51,8 +53,6 @@
 
         AssetFactory factory = new ContextAssetFactory(request, context);
 
-        Resource r = factory.getRootResource().forFile("foo/Bar.txt");
-
         Asset asset = factory.createAsset(r);
 
         assertSame(asset.getResource(), r);
@@ -61,4 +61,5 @@
 
         verify();
     }
+
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextResourceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextResourceTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextResourceTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextResourceTest.java Tue Dec  5 09:35:05 2006
@@ -18,7 +18,7 @@
 
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Resource;
-import org.apache.tapestry.services.WebContext;
+import org.apache.tapestry.services.Context;
 import org.testng.annotations.Test;
 
 public class ContextResourceTest extends InternalBaseTestCase
@@ -28,7 +28,7 @@
     {
         URL url = getClass().getResource("ContextResourceTest.class");
 
-        WebContext context = newWebContext();
+        Context context = newContext();
 
         expect(context.getResource("/foo/Bar.txt")).andReturn(url);
 
@@ -44,7 +44,7 @@
     @Test
     public void to_string()
     {
-        WebContext context = newWebContext();
+        Context context = newContext();
 
         replay();
 
@@ -58,8 +58,8 @@
     @Test
     public void hash_code()
     {
-        WebContext context1 = newWebContext();
-        WebContext context2 = newWebContext();
+        Context context1 = newContext();
+        Context context2 = newContext();
 
         replay();
 
@@ -78,8 +78,8 @@
     @Test
     public void equals()
     {
-        WebContext context1 = newWebContext();
-        WebContext context2 = newWebContext();
+        Context context1 = newContext();
+        Context context2 = newContext();
         Resource r = newResource();
 
         replay();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java Tue Dec  5 09:35:05 2006
@@ -21,12 +21,12 @@
 import org.apache.tapestry.services.ClassTransformation;
 import org.apache.tapestry.services.ComponentClassTransformWorker;
 import org.apache.tapestry.services.InjectionProvider;
-import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.Request;
 import org.testng.annotations.Test;
 
 public class InjectAnonymousWorkerTest extends InternalBaseTestCase
 {
-    private static final String WEBREQUEST_CLASS_NAME = WebRequest.class.getName();
+    private static final String WEBREQUEST_CLASS_NAME = Request.class.getName();
 
     @Test
     public void anonymous_injection()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java Tue Dec  5 09:35:05 2006
@@ -20,13 +20,13 @@
 import org.apache.tapestry.ioc.ServiceLocator;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.services.ClassTransformation;
-import org.apache.tapestry.services.WebRequest;
+import org.apache.tapestry.services.Request;
 import org.testng.annotations.Test;
 
 public class InjectNamedWorkerTest extends InternalBaseTestCase
 {
 
-    private static final String WEBREQUEST_CLASS_NAME = WebRequest.class.getName();
+    private static final String WEBREQUEST_CLASS_NAME = Request.class.getName();
 
     @Test
     public void annotation_has_value()
@@ -36,7 +36,7 @@
         Inject annotation = newMock(Inject.class);
         ClassTransformation ct = newClassTransformation();
         MutableComponentModel model = newMutableComponentModel();
-        WebRequest injected = newWebRequest();
+        Request injected = newRequest();
 
         train_findFieldsWithAnnotation(ct, Inject.class, "myfield");
         train_getFieldAnnotation(ct, "myfield", Inject.class, annotation);
@@ -44,9 +44,9 @@
         train_value(annotation, "foo:Bar");
 
         train_getFieldType(ct, "myfield", WEBREQUEST_CLASS_NAME);
-        train_toClass(ct, WEBREQUEST_CLASS_NAME, WebRequest.class);
+        train_toClass(ct, WEBREQUEST_CLASS_NAME, Request.class);
 
-        train_provide(provider, "foo:Bar", WebRequest.class, locator, injected);
+        train_provide(provider, "foo:Bar", Request.class, locator, injected);
 
         ct.injectField("myfield", injected);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java Tue Dec  5 09:35:05 2006
@@ -22,8 +22,8 @@
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.internal.util.Holder;
 import org.apache.tapestry.services.ComponentClassResolver;
-import org.apache.tapestry.services.WebRequest;
-import org.apache.tapestry.services.WebResponse;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.testng.annotations.Test;
@@ -68,8 +68,8 @@
     @Test
     public void page_link()
     {
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        Request request = newRequest();
+        Response response = newResponse();
         ComponentClassResolver resolver = newComponentClassResolver();
         Page page = newPage();
         ComponentPageElement rootElement = newComponentPageElement();
@@ -153,8 +153,8 @@
     private void run(String pageClassName, String logicalPageName, String nestedId,
             String contextPath, String expectedURI, Object... context)
     {
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        Request request = newRequest();
+        Response response = newResponse();
         ComponentClassResolver resolver = newComponentClassResolver();
         ComponentPageElement element = newComponentPageElement();
         Page page = newPage();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java Tue Dec  5 09:35:05 2006
@@ -18,7 +18,7 @@
 
 import org.apache.tapestry.Link;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.services.WebResponse;
+import org.apache.tapestry.services.Response;
 import org.testng.annotations.Test;
 
 public class LinkImplTest extends InternalBaseTestCase
@@ -28,7 +28,7 @@
     @Test
     public void url_with_parameters()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         train_encodeURL(response, "/foo/bar?barney=rubble&fred=flintstone", ENCODED);
 
@@ -47,7 +47,7 @@
     @Test
     public void retrieve_parameter_values()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         replay();
 
@@ -66,7 +66,7 @@
     @Test
     public void ensure_parameter_values_are_encoded()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         train_encodeURL(response, "/foo/bar?fred=flint+stone%3F", ENCODED);
 
@@ -84,7 +84,7 @@
     @Test
     public void parameter_names_are_returned_sorted()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         replay();
 
@@ -101,7 +101,7 @@
     @Test
     public void parameter_names_must_be_unique()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         replay();
 
@@ -126,7 +126,7 @@
     @Test
     public void to_form_URI_does_not_include_parameters()
     {
-        WebResponse response = newWebResponse();
+        Response response = newResponse();
 
         train_encodeURL(response, "/foo/bar", ENCODED);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LocalizationFilterTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LocalizationFilterTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LocalizationFilterTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LocalizationFilterTest.java Tue Dec  5 09:35:05 2006
@@ -18,10 +18,10 @@
 import java.util.Locale;
 
 import org.apache.tapestry.ioc.services.ThreadLocale;
-import org.apache.tapestry.services.WebRequest;
-import org.apache.tapestry.services.WebRequestFilter;
-import org.apache.tapestry.services.WebRequestHandler;
-import org.apache.tapestry.services.WebResponse;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.RequestFilter;
+import org.apache.tapestry.services.RequestHandler;
+import org.apache.tapestry.services.Response;
 import org.apache.tapestry.test.TapestryTestCase;
 import org.testng.annotations.Test;
 
@@ -71,9 +71,9 @@
     public void known_locale() throws IOException
     {
         ThreadLocale threadLocale = newThreadLocale();
-        WebRequestHandler handler = newWebRequestHandler();
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        RequestHandler handler = newRequestHandler();
+        Request request = newRequest();
+        Response response = newResponse();
 
         train_getLocale(request, Locale.CANADA_FRENCH);
 
@@ -87,7 +87,7 @@
 
         replay();
 
-        WebRequestFilter filter = new LocalizationFilter(threadLocale, "en,fr");
+        RequestFilter filter = new LocalizationFilter(threadLocale, "en,fr");
 
         assertTrue(filter.service(request, response, handler));
 
@@ -98,9 +98,9 @@
     public void unknown_locale_uses_default_locale() throws IOException
     {
         ThreadLocale threadLocale = newThreadLocale();
-        WebRequestHandler handler = newWebRequestHandler();
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        RequestHandler handler = newRequestHandler();
+        Request request = newRequest();
+        Response response = newResponse();
 
         train_getLocale(request, Locale.JAPANESE);
 
@@ -113,7 +113,7 @@
 
         replay();
 
-        WebRequestFilter filter = new LocalizationFilter(threadLocale, "en,fr");
+        RequestFilter filter = new LocalizationFilter(threadLocale, "en,fr");
 
         assertFalse(filter.service(request, response, handler));
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java Tue Dec  5 09:35:05 2006
@@ -58,8 +58,8 @@
 
         train_getComponentClassName(model, PAGE_CLASS_NAME);
 
-        train_getTemplate(templateSource, PAGE_CLASS_NAME, LOCALE, template);
-        
+        train_getTemplate(templateSource, model, LOCALE, template);
+
         train_isMissing(template, false);
 
         train_getLog(model, log);
@@ -110,7 +110,7 @@
 
         train_getComponentClassName(model, PAGE_CLASS_NAME);
 
-        train_getTemplate(templateSource, PAGE_CLASS_NAME, LOCALE, template);
+        train_getTemplate(templateSource, model, LOCALE, template);
 
         train_isMissing(template, false);
 
@@ -153,7 +153,7 @@
         train_getComponentResources(childElement, childResources);
         train_getComponentModel(childResources, childModel);
         train_getComponentClassName(childModel, CHILD_CLASS_NAME);
-        train_getTemplate(templateSource, CHILD_CLASS_NAME, LOCALE, childTemplate   );
+        train_getTemplate(templateSource, childModel, LOCALE, childTemplate);
         train_isMissing(childTemplate, true);
         train_newRenderBodyElement(elementFactory, childElement, body);
         childElement.addToTemplate(body);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderDispatcherTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderDispatcherTest.java?view=diff&rev=482719&r1=482718&r2=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderDispatcherTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderDispatcherTest.java Tue Dec  5 09:35:05 2006
@@ -20,8 +20,8 @@
 import org.apache.tapestry.internal.structure.Page;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.services.Dispatcher;
-import org.apache.tapestry.services.WebRequest;
-import org.apache.tapestry.services.WebResponse;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
 import org.easymock.EasyMock;
 import org.testng.annotations.Test;
 
@@ -32,8 +32,8 @@
     {
         PageResponseRenderer renderer = newPageResponseRenderer();
         RequestPageCache cache = newRequestPageCache();
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        Request request = newRequest();
+        Response response = newResponse();
 
         train_getPath(request, "/foo/Bar.baz");
 
@@ -51,8 +51,8 @@
     {
         PageResponseRenderer renderer = newPageResponseRenderer();
         RequestPageCache cache = newRequestPageCache();
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        Request request = newRequest();
+        Response response = newResponse();
         Page page = newPage();
         ComponentPageElement rootElement = newComponentPageElement();
 
@@ -84,8 +84,8 @@
     {
         PageResponseRenderer renderer = newPageResponseRenderer();
         RequestPageCache cache = newRequestPageCache();
-        WebRequest request = newWebRequest();
-        WebResponse response = newWebResponse();
+        Request request = newRequest();
+        Response response = newResponse();
         Page page = newPage();
         ComponentPageElement rootElement = newComponentPageElement();
 
@@ -125,10 +125,4 @@
     {
         return newMock(PageResponseRenderer.class);
     }
-
-    protected final void train_getPath(WebRequest request, String path)
-    {
-        expect(request.getPath()).andReturn(path).atLeastOnce();
-    }
-
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceCacheImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceCacheImplTest.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceCacheImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceCacheImplTest.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,171 @@
+// Copyright 2006 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.tapestry.internal.services;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.tapestry.events.InvalidationListener;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.Resource;
+import org.apache.tapestry.services.ResourceDigestGenerator;
+import org.testng.annotations.Test;
+
+public class ResourceCacheImplTest extends InternalBaseTestCase
+{
+    private static final String PATH = "foo/Bar.gif";
+
+    private static final String DIGEST = "abc123";
+
+    @Test
+    public void properties_for_simple_resource() throws Exception
+    {
+        ResourceDigestGenerator generator = newResourceDigestGenerator();
+
+        File f = createTestFile();
+        URL url = f.toURL();
+        Resource r = newResource();
+
+        long lastUpdated = f.lastModified();
+
+        train_getPath(r, PATH);
+        train_toURL(r, url);
+
+        train_requiresDigest(generator, PATH, false);
+
+        replay();
+
+        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
+
+        assertEquals(cache.requiresDigest(r), false);
+        assertEquals(cache.getTimeModified(r), lastUpdated);
+        assertEquals(cache.getDigest(r), null);
+
+        verify();
+    }
+
+    @Test
+    public void properties_for_missing_resource() throws Exception
+    {
+        ResourceDigestGenerator generator = newResourceDigestGenerator();
+
+        Resource r = newResource();
+
+        train_getPath(r, PATH);
+        train_toURL(r, null);
+
+        train_requiresDigest(generator, PATH, true);
+
+        replay();
+
+        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
+
+        assertEquals(cache.requiresDigest(r), true);
+        assertEquals(cache.getTimeModified(r), ResourceCacheImpl.MISSING_RESOURCE_TIME_MODIFIED);
+        assertEquals(cache.getDigest(r), null);
+
+        verify();
+    }
+
+    @Test
+    public void properties_for_protected_resource() throws Exception
+    {
+        ResourceDigestGenerator generator = newResourceDigestGenerator();
+
+        File f = createTestFile();
+        URL url = f.toURL();
+        Resource r = newResource();
+
+        long lastUpdated = f.lastModified();
+
+        train_getPath(r, PATH);
+        train_toURL(r, url);
+
+        train_requiresDigest(generator, PATH, true);
+        train_generateChecksum(generator, url, DIGEST);
+
+        replay();
+
+        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
+
+        assertEquals(cache.requiresDigest(r), true);
+        assertEquals(cache.getTimeModified(r), lastUpdated);
+        assertEquals(cache.getDigest(r), DIGEST);
+
+        verify();
+    }
+
+    @Test
+    public void caching_and_invalidation() throws Exception
+    {
+        ResourceDigestGenerator generator = newResourceDigestGenerator();
+        InvalidationListener listener = newInvalidationListener();
+        File f = createTestFile();
+        URL url = f.toURL();
+        Resource r = newResource();
+
+        long lastUpdated = f.lastModified();
+
+        train_getPath(r, PATH);
+        train_toURL(r, url);
+
+        train_requiresDigest(generator, PATH, true);
+        train_generateChecksum(generator, url, DIGEST);
+
+        replay();
+
+        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
+        cache.addInvalidationListener(listener);
+
+        assertEquals(cache.requiresDigest(r), true);
+        assertEquals(cache.getTimeModified(r), lastUpdated);
+        assertEquals(cache.getDigest(r), DIGEST);
+
+        // No updates yet.
+
+        cache.checkForUpdates();
+
+        verify();
+
+        touch(f);
+
+        lastUpdated = f.lastModified();
+
+        String expectedDigest = "FREDBARNEY";
+
+        train_getPath(r, PATH);
+        train_toURL(r, url);
+        train_requiresDigest(generator, PATH, true);
+        train_generateChecksum(generator, url, expectedDigest);
+
+        listener.objectWasInvalidated();
+
+        replay();
+
+        cache.checkForUpdates();
+
+        assertEquals(cache.requiresDigest(r), true);
+        assertEquals(cache.getTimeModified(r), lastUpdated);
+        assertEquals(cache.getDigest(r), expectedDigest);
+
+        verify();
+    }
+
+    private File createTestFile() throws IOException
+    {
+        return File.createTempFile("ResourceCacheImplTest.", ".tst");
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceDigestGeneratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceDigestGeneratorImplTest.java?view=auto&rev=482719
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceDigestGeneratorImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ResourceDigestGeneratorImplTest.java Tue Dec  5 09:35:05 2006
@@ -0,0 +1,82 @@
+// Copyright 2006 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.tapestry.internal.services;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.services.ResourceDigestGenerator;
+import org.testng.annotations.Test;
+
+public class ResourceDigestGeneratorImplTest extends InternalBaseTestCase
+{
+    @Test
+    public void typical_file() throws Exception
+    {
+        URL url = getClass().getResource("ResourceDigestGeneratorImplTest.class");
+
+        ResourceDigestGenerator g = new ResourceDigestGeneratorImpl();
+
+        String digest = g.generateDigest(url);
+
+        assertTrue(digest.length() > 0);
+
+        String checksum2 = g.generateDigest(url);
+
+        assertEquals(checksum2, digest);
+    }
+
+    @Test
+    public void digest_changes_with_changes_to_file() throws Exception
+    {
+        File file = File.createTempFile("digest.", ".dat");
+
+        URL url = file.toURL();
+
+        ResourceDigestGenerator g = new ResourceDigestGeneratorImpl();
+
+        String prevDigest = g.generateDigest(url);
+
+        for (int i = 0; i < 5; i++)
+        {
+            writeJunkTofile(file);
+
+            String digest = g.generateDigest(url);
+
+            assertFalse(digest.equals(prevDigest));
+
+            prevDigest = digest;
+
+        }
+    }
+
+    private void writeJunkTofile(File file) throws IOException
+    {
+        OutputStream os = new BufferedOutputStream(new FileOutputStream(file, true));
+
+        OutputStreamWriter writer = new OutputStreamWriter(os);
+
+        for (int i = 0; i < 1000; i++)
+            writer.write("All work and no play makes Jack a dull boy. ");
+
+        writer.close();
+    }
+}