Author: hlship
Date: Wed Jan  7 22:43:59 2009
New Revision: 732624

URL: http://svn.apache.org/viewvc?rev=732624&view=rev
Log:
TAP5-90: Context assets should be versioned and provided with a far future 
expires header, just like classpath assets

Modified:
    tapestry/tapestry5/trunk/src/site/apt/guide/compress.apt
    tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
    tapestry/tapestry5/trunk/src/site/apt/index.apt
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetDispatcher.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestConstants.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/ExceptionReport.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AssetDispatcherTest.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/compress.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/compress.apt?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/compress.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/compress.apt Wed Jan  7 
22:43:59 2009
@@ -8,10 +8,10 @@
   signifcantly reduce the amount of network traffic for a Tapestry 
application, at the cost of extra processing time
   on the server to compress the response stream.
 
-  This applies to both rendered pages and streamed assets from the classpath.
+  This directly applies to both rendered pages and streamed assets from the 
classpath.
 
-  It does not (yet) apply to ordinary files in the web application context; 
those are not streamed by Tapestry; they
-  are handled by the servlet container.
+  Context assets will also be compressed ... but this requires referencing 
such assets using the
+  "asset:context:" prefix, so that generated URL is handled by Tapestry and 
not the servlet container.
 
 Compression Configuration
 

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt Wed Jan  7 22:43:59 
2009
@@ -103,6 +103,14 @@
   Many of these symbols have an associated constant in the class
   {{{../apidocs/org/apache/tapestry5/SymbolConstants.html}SymbolConstants}}.
 
+  [tapestry.application-version]
+    The version of the application, which is incorporated into URLs for 
context assets. Context assets
+    may be {{{compress.html}compressed}}, and will have far-future expiration 
headers; they will be aggresively
+    cached by the client web browser. You should change the application 
version on each new deployment of the
+    application to force clients to re-download changed versions of files.  If 
you do not specify
+    an application version, a <random> one will be assigned on every 
deployment (which is good for development
+    but very bad for production).
+
   [tapestry.charset]
     The character encoding used when generating output (or parsing input).  
The default is "UTF-8".
 

Modified: tapestry/tapestry5/trunk/src/site/apt/index.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/index.apt?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/index.apt Wed Jan  7 22:43:59 2009
@@ -79,7 +79,8 @@
 
 New And Of Note
 
-  * Tapestry now {{{guide/compress.html}compresses}} responses for clients 
that support it.
+  * Tapestry now {{{guide/compress.html}compresses}} responses for clients 
that support it.  Context and classpath assets
+    are now handled uniformly: versioned URLs, far-future expiration headers, 
and GZIP compression where applicable.
 
   * Ordered and mapped configurations can now have overrides.
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -99,7 +99,6 @@
      */
     public static final String SCRIPTS_AT_TOP = "tapestry.script-at-top";
 
-
     /**
      * Identifies the default persistence strategy for all pages that do not 
provide an override (using this value as
      * {...@link org.apache.tapestry5.annotations.Meta key}).
@@ -116,4 +115,13 @@
      * @since 5.1.0.0
      */
     public static final String MIN_GZIP_SIZE = "tapestry.min-gzip-size";
+
+    /**
+     * Version number integrated into URLs for context assets. This should be 
changed for each release, otherwise
+     * out-of-date files may be used from the client's local cache (due to 
far-future expired headers). The default
+     * value is semi-random and different for each execution.
+     *
+     * @since 5.1.0.0
+     */
+    public static final String APPLICATION_VERSION = 
"tapestry.application-version";
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -54,6 +54,11 @@
     @Property(write = false)
     private String tapestryVersion;
 
+    @Inject
+    @Symbol(SymbolConstants.APPLICATION_VERSION)
+    @Property(write = false)
+    private String applicationVersion;
+
     @Property(write = false)
     private Throwable rootException;
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetDispatcher.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetDispatcher.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetDispatcher.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AssetDispatcher.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2009 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.
@@ -14,12 +14,12 @@
 
 package org.apache.tapestry5.internal.services;
 
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
-import org.apache.tapestry5.services.ClasspathAssetAliasManager;
-import org.apache.tapestry5.services.Dispatcher;
-import org.apache.tapestry5.services.Request;
-import org.apache.tapestry5.services.Response;
+import org.apache.tapestry5.services.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -40,14 +40,30 @@
 
     private final ResourceCache resourceCache;
 
+    private final String applicationAssetPrefix;
+
+    private final AssetFactory contextAssetFactory;
+
     static final String IF_MODIFIED_SINCE_HEADER = "If-Modified-Since";
 
-    public AssetDispatcher(ResourceStreamer streamer, 
ClasspathAssetAliasManager aliasManager,
-                           ResourceCache resourceCache)
+    public AssetDispatcher(ResourceStreamer streamer,
+
+                           ClasspathAssetAliasManager aliasManager,
+
+                           ResourceCache resourceCache,
+
+                           @Inject @Symbol(SymbolConstants.APPLICATION_VERSION)
+                           String applicationVersion,
+
+                           @ContextProvider
+                           AssetFactory contextAssetFactory)
     {
         this.streamer = streamer;
         this.aliasManager = aliasManager;
         this.resourceCache = resourceCache;
+        this.contextAssetFactory = contextAssetFactory;
+
+        applicationAssetPrefix = RequestConstants.ASSET_PATH_PREFIX + 
RequestConstants.APP_FOLDER + applicationVersion + "/";
     }
 
     public boolean dispatch(Request request, Response response) throws 
IOException
@@ -61,9 +77,7 @@
 
         // ClassLoaders like their paths to start with a leading slash.
 
-        String resourcePath = aliasManager.toResourcePath(path);
-
-        Resource resource = findResourceAndValidateDigest(response, 
resourcePath);
+        Resource resource = findResourceAndValidateDigest(response, path);
 
         if (resource == null) return true;
 
@@ -104,14 +118,19 @@
     }
 
     /**
-     * @param response     used to send errors back to the client
-     * @param resourcePath the path to the requested resource, from the request
+     * @param response used to send errors back to the client
+     * @param path     the URI path
      * @return the resource for the path, with the digest stripped out of the 
URL, or null if the digest is invalid (and
      *         an error has been sent back to the client)
      * @throws IOException
      */
-    private Resource findResourceAndValidateDigest(Response response, String 
resourcePath) throws IOException
+    private Resource findResourceAndValidateDigest(Response response, String 
path) throws IOException
     {
+        if (path.startsWith(applicationAssetPrefix))
+            return 
findContextResource(path.substring(applicationAssetPrefix.length()));
+
+        String resourcePath = aliasManager.toResourcePath(path);
+
         Resource resource = new ClasspathResource(resourcePath);
 
         if (!resourceCache.requiresDigest(resource)) return resource;
@@ -156,4 +175,9 @@
 
         return result;
     }
+
+    private Resource findContextResource(String contextPath)
+    {
+        return contextAssetFactory.getRootResource().forFile(contextPath);
+    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClasspathAssetFactory.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -38,10 +38,14 @@
 
     private final Map<Resource, String> resourceToClientURL = 
newConcurrentMap();
 
+    private final ClasspathResource rootResource;
+
     public ClasspathAssetFactory(final ResourceCache cache, final 
ClasspathAssetAliasManager aliasManager)
     {
         this.cache = cache;
         this.aliasManager = aliasManager;
+
+        rootResource = new ClasspathResource("");
     }
 
     public void objectWasInvalidated()
@@ -107,6 +111,6 @@
 
     public Resource getRootResource()
     {
-        return new ClasspathResource("");
+        return rootResource;
     }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ContextAssetFactory.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -15,7 +15,10 @@
 package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.Asset;
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.AssetFactory;
 import org.apache.tapestry5.services.Context;
 import org.apache.tapestry5.services.Request;
@@ -23,7 +26,7 @@
 /**
  * Implementation of {...@link AssetFactory} for assets that are part of the 
web application context.
  *
- * @see ContextResource
+ * @see org.apache.tapestry5.internal.services.ContextResource
  */
 public class ContextAssetFactory implements AssetFactory
 {
@@ -33,16 +36,28 @@
 
     private final RequestPathOptimizer optimizer;
 
-    public ContextAssetFactory(Request request, Context context, 
RequestPathOptimizer optimizer)
+    private final String pathPrefix;
+
+    private final Resource rootResource;
+
+    public ContextAssetFactory(Request request, Context context, 
RequestPathOptimizer optimizer,
+
+                               @Inject 
@Symbol(SymbolConstants.APPLICATION_VERSION)
+                               String applicationVersion)
     {
         this.request = request;
         this.context = context;
         this.optimizer = optimizer;
+
+        pathPrefix = RequestConstants.ASSET_PATH_PREFIX + 
RequestConstants.APP_FOLDER
+                + applicationVersion + "/";
+
+        rootResource = new ContextResource(context, "/");
     }
 
     public Asset createAsset(final Resource resource)
     {
-        final String contextPath = request.getContextPath() + "/" + 
resource.getPath();
+        final String contextPath = request.getContextPath() + pathPrefix + 
resource.getPath();
 
         return new Asset()
         {
@@ -57,7 +72,7 @@
             }
 
             /**
-             * Returns the client URL, which is essiential to allow informal 
parameters of type
+             * Returns the client URL, which is essential to allow informal 
parameters of type
              * Asset to generate a proper value.
              */
             @Override
@@ -69,11 +84,10 @@
     }
 
     /**
-     * Returns the root {...@link ContextResource}.
+     * Returns the root {...@link 
org.apache.tapestry5.internal.services.ContextResource}.
      */
     public Resource getRootResource()
     {
-        return new ContextResource(context, "/");
+        return rootResource;
     }
-
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestConstants.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestConstants.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestConstants.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestConstants.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -26,4 +26,11 @@
     public static final String ASSET_PATH_PREFIX = "/assets/";
 
 
+    /**
+     * Virtual folder name for assets that are actually stored in the context, 
but are exposed (much like classpath
+     * assets) to gain far-future expires headers and automatic content 
compression.
+     *
+     * @since 5.1.0.0
+     */
+    public static final String APP_FOLDER = "app/";
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
 Wed Jan  7 22:43:59 2009
@@ -863,9 +863,12 @@
     }
 
     @Marker(ContextProvider.class)
-    public AssetFactory buildContextAssetFactory(ApplicationGlobals globals, 
RequestPathOptimizer optimizer)
+    public AssetFactory buildContextAssetFactory(ApplicationGlobals globals, 
RequestPathOptimizer optimizer,
+
+                                                 @Inject 
@Symbol(SymbolConstants.APPLICATION_VERSION)
+                                                 String applicationVersion)
     {
-        return new ContextAssetFactory(request, globals.getContext(), 
optimizer);
+        return new ContextAssetFactory(request, globals.getContext(), 
optimizer, applicationVersion);
     }
 
     /**
@@ -1904,6 +1907,8 @@
         configuration.add(SymbolConstants.SCRIPTS_AT_TOP, "false");
 
         configuration.add(SymbolConstants.MIN_GZIP_SIZE, "100");
+
+        configuration.add(SymbolConstants.APPLICATION_VERSION, 
Long.toHexString(System.currentTimeMillis()));
     }
 
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/ExceptionReport.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/ExceptionReport.tml?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/ExceptionReport.tml
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/ExceptionReport.tml
 Wed Jan  7 22:43:59 2009
@@ -14,8 +14,10 @@
 
                     <h2>Tapestry Framework</h2>
                     <dl>
-                        <dt>Version</dt>
+                        <dt>Tapestry Version</dt>
                         <dd>${tapestryVersion}</dd>
+                        <dt>Application Version</dt>
+                        <dd>${applicationVersion}</dd>
                     </dl>
 
                     <h2>Request</h2>

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 Wed Jan  7 22:43:59 2009
@@ -19,13 +19,12 @@
 import org.apache.tapestry5.integration.app1.data.RegistrationData;
 import org.apache.tapestry5.integration.app1.pages.RenderErrorDemo;
 import org.apache.tapestry5.internal.TapestryInternalUtils;
-import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
 import org.apache.tapestry5.test.AbstractIntegrationTestSuite;
 import org.testng.annotations.Test;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 
@@ -49,27 +48,38 @@
 
         // Test for https://issues.apache.org/jira/browse/TAPESTRY-1935
 
-        assertSourcePresent("<link href=\"/css/app.css\" rel=\"stylesheet\" 
type=\"text/css\">");
+        // assertSourcePresent("<link href=\"/css/app.css\" rel=\"stylesheet\" 
type=\"text/css\">");
+
+        // The URL
+
+        // assertAttribute("//i...@id='icon']/@src", 
"/images/tapestry_banner.gif");
 
-        assertAttribute("//i...@id='icon']/@src", 
"/images/tapestry_banner.gif");
 
         // 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 to be verified. Note that the path below represents some 
aliasing
         // of the raw classpath resource path.
 
-        assertAttribute("//i...@id='button']/@src", 
"/assets/app1/pages/nested/tapestry-button.png");
+        // assertAttribute("//i...@id='button']/@src", 
"/assets/app1/pages/nested/tapestry-button.png");
 
         // Read the byte stream for the asset and compare to the real copy.
 
-        URL url = new URL("http", "localhost", JETTY_PORT, 
"/assets/app1/pages/nested/tapestry-button.png");
+        compareDownloadedAsset(getAttribute("//i...@id='icon']/@src"),
+                               "src/test/app1/images/tapestry_banner.gif");
+        compareDownloadedAsset(getAttribute("//i...@id='button']/@src"),
+                               
"src/test/resources/org/apache/tapestry5/integration/app1/pages/nested/tapestry-button.png");
+    }
+
+    private void compareDownloadedAsset(String assetURL, String localPath) 
throws Exception
+    {
+        URL url = new URL("http", "localhost", JETTY_PORT, assetURL);
 
         byte[] downloaded = readContent(url);
 
-        Resource classpathResource = new ClasspathResource(
-                
"org/apache/tapestry5/integration/app1/pages/nested/tapestry-button.png");
+        File local = new File(
+                localPath);
 
-        byte[] actual = readContent(classpathResource.toURL());
+        byte[] actual = readContent(local.toURL());
 
         assertEquals(downloaded, actual);
     }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AssetDispatcherTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AssetDispatcherTest.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AssetDispatcherTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/AssetDispatcherTest.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009 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.
@@ -44,7 +44,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(null, null, null);
+        Dispatcher d = new AssetDispatcher(null, null, null, "1.2.3", null);
 
         assertFalse(d.dispatch(request, null));
 
@@ -72,7 +72,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -101,7 +101,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -132,7 +132,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -165,7 +165,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -196,7 +196,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -227,7 +227,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -257,7 +257,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 
@@ -288,7 +288,7 @@
 
         replay();
 
-        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache);
+        Dispatcher d = new AssetDispatcher(streamer, aliasManager, cache, 
"1.2.3", null);
 
         assertTrue(d.dispatch(request, response));
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java?rev=732624&r1=732623&r2=732624&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
 Wed Jan  7 22:43:59 2009
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2009 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.
@@ -33,7 +33,7 @@
 
         replay();
 
-        AssetFactory factory = new ContextAssetFactory(request, context, null);
+        AssetFactory factory = new ContextAssetFactory(request, context, null, 
"1.2.3");
 
         assertEquals(factory.getRootResource().toString(), "context:/");
 
@@ -51,12 +51,12 @@
 
         train_getContextPath(request, "/context");
 
-        train_optimizePath(optimizer, "/context/foo/Bar.txt", "/opt/path1");
-        train_optimizePath(optimizer, "/context/foo/Bar.txt", "/opt/path2");
+        train_optimizePath(optimizer, "/context/assets/app/4.5.6/foo/Bar.txt", 
"/opt/path1");
+        train_optimizePath(optimizer, "/context/assets/app/4.5.6/foo/Bar.txt", 
"/opt/path2");
 
         replay();
 
-        AssetFactory factory = new ContextAssetFactory(request, context, 
optimizer);
+        AssetFactory factory = new ContextAssetFactory(request, context, 
optimizer, "4.5.6");
 
         Asset asset = factory.createAsset(r);
 
@@ -70,5 +70,4 @@
 
         verify();
     }
-
 }


Reply via email to