Author: andyhot
Date: Fri Apr 20 13:00:37 2007
New Revision: 530901

URL: http://svn.apache.org/viewvc?view=rev&rev=530901
Log:
TAPESTRY-1412 + a chance to add a few more tests

Modified:
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Script.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/ScriptTest.java

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Script.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Script.java?view=diff&rev=530901&r1=530900&r2=530901
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Script.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Script.java
 Fri Apr 20 13:00:37 2007
@@ -19,6 +19,7 @@
 import java.util.Map;
 
 import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Location;
 import org.apache.hivemind.Resource;
 import org.apache.tapestry.AbstractComponent;
 import org.apache.tapestry.IAsset;
@@ -137,8 +138,14 @@
         }
         catch (RuntimeException ex)
         {
+            Location location = null;
+            if (getBinding("script")!=null)
+                location = getBinding("script").getLocation();
+            else if (getBinding("scriptAsset")!=null)
+                location = getBinding("scriptAsset").getLocation();
+            
             throw new ApplicationRuntimeException(ex.getMessage(), this,
-                    getBinding("script").getLocation(), ex);
+                    location, ex);
         }
 
     }

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/ScriptTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/ScriptTest.java?view=diff&rev=530901&r1=530900&r2=530901
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/ScriptTest.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/html/ScriptTest.java
 Fri Apr 20 13:00:37 2007
@@ -264,6 +264,80 @@
         verify();
     }
     
+    public void test_NoParam_Exception() 
+    {
+       IScriptSource source = newScriptSource();
+        
+        PageRenderSupport support = newPageRenderSupport();
+        IRequestCycle cycle = newCycle(false, false);
+        IMarkupWriter writer = newWriter();
+        IRender body = newRender();
+        
+        IComponent container = newComponent();
+
+        String scriptPath = "MyScript.script";
+        
+        IAsset scriptAsset = newAsset();
+        
+        Script component = newInstance(Script.class, new Object[]
+        { "specification", new ComponentSpecification(), "container", 
container, "scriptSource",
+                source});
+        
+        trainGetPageRenderSupport(cycle, support);
+        
+        replay();
+        
+        component.addBody(body);
+        
+        try {
+               component.renderComponent(writer, cycle);
+        } catch (ApplicationRuntimeException ex) {
+               assertExceptionSubstring(ex, "neither parameter was set");
+        }
+        
+        verify();
+    }    
+    
+    public void test_IAsset_NotFound_Exception() 
+    {
+        IScriptSource source = newScriptSource();
+        IScript script = newScript();
+        
+        PageRenderSupport support = newPageRenderSupport();
+        
+        IRequestCycle cycle = newCycle(false, null);
+        
+        trainGetPageRenderSupport(cycle, support);
+        
+        IMarkupWriter writer = newWriter();
+        Resource scriptLocation = newResource();
+        IRender body = newRender();
+        
+        IComponent container = newComponent();
+        
+        IAsset scriptAsset = newAsset();
+        
+        expect(scriptAsset.getResourceLocation()).andReturn(scriptLocation);
+        
+        Script component = newInstance(Script.class, new Object[]
+        { "specification", new ComponentSpecification(), "container", 
container, "scriptSource",
+                source, "scriptAsset", scriptAsset });
+        
+        expect(source.getScript(scriptLocation)).andThrow(new 
RuntimeException());
+        
+        replay();
+        
+        component.addBody(body);
+        
+        try {
+               component.renderComponent(writer, cycle);
+                unreachable();
+        } catch (ApplicationRuntimeException ex) {
+        }        
+        
+        verify();
+    }      
+    
     public void test_IAsset_Param_Render()
     {
         IScriptSource source = newScriptSource();


Reply via email to