tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r694726 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
Date Fri, 12 Sep 2008 16:14:32 GMT
Author: hlship
Date: Fri Sep 12 09:14:32 2008
New Revision: 694726

URL: http://svn.apache.org/viewvc?rev=694726&view=rev
Log:
TAPESTRY-2664: RenderSupport.addScript(String) does not add the core JavaScript dependencies

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java?rev=694726&r1=694725&r2=694726&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
Fri Sep 12 09:14:32 2008
@@ -19,14 +19,12 @@
 import org.apache.tapestry5.FieldFocusPriority;
 import org.apache.tapestry5.RenderSupport;
 import org.apache.tapestry5.ioc.internal.util.Defense;
-import static org.apache.tapestry5.ioc.internal.util.Defense.notNull;
 import org.apache.tapestry5.ioc.internal.util.IdAllocator;
 import org.apache.tapestry5.ioc.services.SymbolSource;
 import org.apache.tapestry5.json.JSONArray;
 import org.apache.tapestry5.json.JSONObject;
 import org.apache.tapestry5.services.AssetSource;
 
-import static java.lang.String.format;
 import java.util.Arrays;
 import java.util.List;
 
@@ -102,7 +100,7 @@
 
         for (Asset asset : scriptAssets)
         {
-            notNull(asset, "scriptAsset");
+            Defense.notNull(asset, "scriptAsset");
 
             linker.addScriptLink(asset.toClientURL());
         }
@@ -137,18 +135,18 @@
 
     public void addScript(String script)
     {
+        Defense.notBlank(script, "script");
+
+        addCore();
+
         linker.addScript(script);
     }
 
     public void addScript(String format, Object... arguments)
     {
-        notNull(format, "format");
+        Defense.notNull(format, "format");
 
-        addCore();
-
-        String script = format(format, arguments);
-
-        linker.addScript(script);
+        addScript(String.format(format, arguments));
     }
 
     public void addInit(String functionName, JSONArray parameterList)
@@ -225,7 +223,7 @@
 
     public void addStylesheetLink(Asset stylesheet, String media)
     {
-        notNull(stylesheet, "stylesheet");
+        Defense.notNull(stylesheet, "stylesheet");
 
         linker.addStylesheetLink(stylesheet.toClientURL(), media);
     }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java?rev=694726&r1=694725&r2=694726&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
Fri Sep 12 09:14:32 2008
@@ -26,10 +26,6 @@
 {
     private static final String CORE_ASSET_PATH_UNEXPANDED = "${core}";
 
-    private static final String CORE_ASSET_PATH = "/org/apache/tapestry5/core/core.png";
-
-    private static final String CORE_ASSET_URL = "/assets/core/core.png";
-
     private static final String ASSET_URL = "/assets/foo/bar.pdf";
 
     @Test
@@ -71,17 +67,12 @@
     {
         getMocksControl().checkOrder(true);
 
-        Asset coreAsset = mockAsset();
         DocumentLinker linker = mockDocumentLinker();
         Asset asset = mockAsset();
         AssetSource assetSource = mockAssetSource();
         SymbolSource symbolSource = mockSymbolSource();
 
-        train_expandSymbols(symbolSource, CORE_ASSET_PATH_UNEXPANDED, CORE_ASSET_PATH);
-        train_getAsset(assetSource, null, CORE_ASSET_PATH, null, coreAsset);
-
-        train_toClientURL(coreAsset, CORE_ASSET_URL);
-        linker.addScriptLink(CORE_ASSET_URL);
+        train_addClasspathAsset(linker, symbolSource, assetSource, CORE_ASSET_PATH_UNEXPANDED);
 
         train_toClientURL(asset, ASSET_URL);
         linker.addScriptLink(ASSET_URL);
@@ -96,16 +87,39 @@
         verify();
     }
 
+    private void train_addClasspathAsset(DocumentLinker linker, SymbolSource symbolSource,
AssetSource assetSource,
+                                         String scriptPath)
+    {
+        String expanded = "expanded:" + scriptPath;
+        String url = "/" + scriptPath;
+
+        Asset asset = mockAsset();
+
+        train_expandSymbols(symbolSource, scriptPath, expanded);
+
+        train_getAsset(assetSource, null, expanded, null, asset);
+
+        train_toClientURL(asset, url);
+
+        linker.addScriptLink(url);
+    }
+
     @Test
     public void add_script()
     {
+        String coreScript = "corescript.js";
+
         DocumentLinker linker = mockDocumentLinker();
+        SymbolSource symbolSource = mockSymbolSource();
+        AssetSource assetSource = mockAssetSource();
+
+        train_addClasspathAsset(linker, symbolSource, assetSource, coreScript);
 
         linker.addScript("Tapestry.Foo(\"bar\");");
 
         replay();
 
-        RenderSupport support = new RenderSupportImpl(linker, null, null);
+        RenderSupport support = new RenderSupportImpl(linker, symbolSource, assetSource,
coreScript);
 
         support.addScript("Tapestry.Foo(\"%s\");", "bar");
 
@@ -117,7 +131,12 @@
     @Test
     public void add_script_no_formatting()
     {
+        String coreScript = "corescript.js";
         DocumentLinker linker = mockDocumentLinker();
+        SymbolSource symbolSource = mockSymbolSource();
+        AssetSource assetSource = mockAssetSource();
+
+        train_addClasspathAsset(linker, symbolSource, assetSource, coreScript);
 
         String script = "foo('%');";
 
@@ -125,7 +144,7 @@
 
         replay();
 
-        RenderSupport support = new RenderSupportImpl(linker, null, null);
+        RenderSupport support = new RenderSupportImpl(linker, symbolSource, assetSource,
coreScript);
 
         support.addScript(script);
 



Mime
View raw message