Author: hlship
Date: Thu Jul 21 18:21:45 2011
New Revision: 1149304
URL: http://svn.apache.org/viewvc?rev=1149304&view=rev
Log:
TAP5-1508: Adjust render phase exception test for slight changes to how checked
exceptions inside render phase methods are reported
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java?rev=1149304&r1=1149303&r2=1149304&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
Thu Jul 21 18:21:45 2011
@@ -14,31 +14,8 @@
package org.apache.tapestry5.internal.structure;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tapestry5.Binding;
-import org.apache.tapestry5.Block;
-import org.apache.tapestry5.BlockNotFoundException;
-import org.apache.tapestry5.ComponentEventCallback;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.Renderable;
-import org.apache.tapestry5.SymbolConstants;
-import org.apache.tapestry5.TapestryMarkers;
-import org.apache.tapestry5.annotations.AfterRender;
-import org.apache.tapestry5.annotations.AfterRenderBody;
-import org.apache.tapestry5.annotations.AfterRenderTemplate;
-import org.apache.tapestry5.annotations.BeforeRenderTemplate;
-import org.apache.tapestry5.annotations.BeginRender;
-import org.apache.tapestry5.annotations.CleanupRender;
-import org.apache.tapestry5.annotations.SetupRender;
+import org.apache.tapestry5.*;
+import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.internal.AbstractEventContext;
import org.apache.tapestry5.internal.InternalComponentResources;
@@ -61,16 +38,13 @@ import org.apache.tapestry5.ioc.util.Unk
import org.apache.tapestry5.model.ComponentModel;
import org.apache.tapestry5.model.ParameterModel;
import org.apache.tapestry5.runtime.Component;
-import org.apache.tapestry5.runtime.ComponentEvent;
-import org.apache.tapestry5.runtime.ComponentEventException;
-import org.apache.tapestry5.runtime.Event;
-import org.apache.tapestry5.runtime.PageLifecycleListener;
-import org.apache.tapestry5.runtime.RenderCommand;
-import org.apache.tapestry5.runtime.RenderQueue;
+import org.apache.tapestry5.runtime.*;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.pageload.ComponentResourceSelector;
import org.slf4j.Logger;
+import java.util.*;
+
/**
* Implements {@link RenderCommand} and represents a component within an
overall page. Much of a
* component page
@@ -81,7 +55,7 @@ import org.slf4j.Logger;
* lifecycle listener}. This could be done inside the constructors, but that
tends to complicate unit tests, so its done
* by {@link org.apache.tapestry5.internal.services.PageElementFactoryImpl}.
There's still a bit of refactoring in this
* class (and its many inner classes) that can improve overall efficiency.
- * <p>
+ * <p/>
* Modified for Tapestry 5.2 to adjust for the no-pooling approach (shared
instances with externalized mutable state).
*/
public class ComponentPageElementImpl extends BaseLocatable implements
ComponentPageElement, PageLifecycleListener
@@ -204,7 +178,9 @@ public class ComponentPageElementImpl ex
break;
}
}
- catch (RuntimeException ex)
+ // This used to be RuntimeException, but with TAP5-1508 changes to
RenderPhaseMethodWorker, we now
+ // let ordinary exceptions bubble up as well.
+ catch (Exception ex)
{
throw new TapestryException(ex.getMessage(), getLocation(),
ex);
}
@@ -576,28 +552,21 @@ public class ComponentPageElementImpl ex
/**
* Constructor for other components embedded within the root component or
at deeper levels of
* the hierarchy.
- *
- * @param page
- * ultimately containing this component
- * @param container
- * component immediately containing this component (may be null
for a root component)
- * @param id
- * unique (within the container) id for this component (may be
null for a root
- * component)
- * @param elementName
- * the name of the element which represents this component in
the template, or null
- * for
- * <comp> element or a page component
- * @param instantiator
- * used to create the new component instance and access the
component's model
- * @param location
- * location of the element (within a template), used as part of
exception reporting
- * @param elementResources
- * Provides access to common methods of various services
+ *
+ * @param page ultimately containing this component
+ * @param container component immediately containing this component
(may be null for a root component)
+ * @param id unique (within the container) id for this
component (may be null for a root
+ * component)
+ * @param elementName the name of the element which represents this
component in the template, or null
+ * for
+ * <comp> element or a page component
+ * @param instantiator used to create the new component instance and
access the component's model
+ * @param location location of the element (within a template),
used as part of exception reporting
+ * @param elementResources Provides access to common methods of various
services
*/
ComponentPageElementImpl(Page page, ComponentPageElement container, String
id, String nestedId, String completeId,
- String elementName, Instantiator instantiator, Location location,
- ComponentPageElementResources elementResources, Request request,
SymbolSource symbolSource)
+ String elementName, Instantiator instantiator,
Location location,
+ ComponentPageElementResources elementResources,
Request request, SymbolSource symbolSource)
{
super(location);
@@ -633,7 +602,7 @@ public class ComponentPageElementImpl ex
* Constructor for the root component of a page.
*/
public ComponentPageElementImpl(Page page, Instantiator instantiator,
- ComponentPageElementResources elementResources, Request request,
SymbolSource symbolSource)
+ ComponentPageElementResources
elementResources, Request request, SymbolSource symbolSource)
{
this(page, null, null, null, page.getName(), null, instantiator, null,
elementResources, request, symbolSource);
}
@@ -690,7 +659,7 @@ public class ComponentPageElementImpl ex
}
public ComponentPageElement newChild(String id, String nestedId, String
completeId, String elementName,
- Instantiator instantiator, Location location)
+ Instantiator instantiator, Location
location)
{
ComponentPageElementImpl child = new ComponentPageElementImpl(page,
this, id, nestedId, completeId,
elementName, instantiator, location, elementResources,
request, symbolSource);
@@ -754,8 +723,7 @@ public class ComponentPageElementImpl ex
if (mixinAfterOrderer == null)
mixinAfterOrderer = new Orderer<Component>(getLogger());
mixinAfterOrderer.add(mixinId, resources.getComponent(), order);
- }
- else
+ } else
{
if (mixinBeforeOrderer == null)
mixinBeforeOrderer = new Orderer<Component>(getLogger());
@@ -959,8 +927,11 @@ public class ComponentPageElementImpl ex
for (InternalComponentResources resources :
NamedSet.getValues(mixinIdToComponentResources))
{
- if
(resources.getComponentModel().getComponentClassName().equals(mixinClassName))
{ return resources
- .getComponent(); }
+ if
(resources.getComponentModel().getComponentClassName().equals(mixinClassName))
+ {
+ return resources
+ .getComponent();
+ }
}
return null;
@@ -1004,19 +975,17 @@ public class ComponentPageElementImpl ex
/**
* Invokes a callback on the component instances (the core component plus
any mixins).
- *
- * @param reverse
- * if true, the callbacks are in the reverse of the normal
order (this is associated
- * with AfterXXX
- * phases)
- * @param callback
- * the object to receive each component instance
+ *
+ * @param reverse if true, the callbacks are in the reverse of the normal
order (this is associated
+ * with AfterXXX
+ * phases)
+ * @param callback the object to receive each component instance
*/
private void invoke(boolean reverse, ComponentCallback callback)
{
try
{ // Optimization: In the most general case (just the one component,
no mixins)
- // invoke the callback on the component and be done ... no
iterators, no nothing.
+ // invoke the callback on the component and be done ... no
iterators, no nothing.
if (components == null)
{
@@ -1033,8 +1002,7 @@ public class ComponentPageElementImpl ex
if (callback.isEventAborted())
return;
}
- }
- catch (RuntimeException ex)
+ } catch (RuntimeException ex)
{
throw new TapestryException(ex.getMessage(), getLocation(), ex);
}
@@ -1106,7 +1074,7 @@ public class ComponentPageElementImpl ex
}
public boolean triggerContextEvent(final String eventType, final
EventContext context,
- final ComponentEventCallback callback)
+ final ComponentEventCallback callback)
{
assert InternalUtils.isNonBlank(eventType);
assert context != null;
@@ -1175,8 +1143,7 @@ public class ComponentPageElementImpl ex
if (event.isAborted())
return result;
- }
- catch (RuntimeException ex)
+ } catch (RuntimeException ex)
{
// An exception in an event handler method
// while we're trying to handle a previous exception!
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java?rev=1149304&r1=1149303&r2=1149304&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
Thu Jul 21 18:21:45 2011
@@ -205,7 +205,7 @@ public class CoreBehaviorsTests extends
openLinks("InstanceMixin");
final String[] dates =
- { "Jun 13, 1999", "Jul 15, 2001", "Dec 4, 2005" };
+ {"Jun 13, 1999", "Jul 15, 2001", "Dec 4, 2005"};
for (String date : dates)
{
@@ -476,7 +476,8 @@ public class CoreBehaviorsTests extends
assertText("css=li.param1", "param1: value1");
assertText("css=li.param2", "param2: 10");
- openLinkParameterTest();;
+ openLinkParameterTest();
+ ;
clickAndWait("link=Event Link With Parameters");
assertText("css=li.param1", "param1: value1");
assertText("css=li.param2", "param2: 10");
@@ -814,7 +815,10 @@ public class CoreBehaviorsTests extends
{
openLinks("Render Phase Method Exception Demo");
- assertTextPresent("Render queue error in
BeginRender[RenderPhaseMethodExceptionDemo]: java.sql.SQLException: Simulated
JDBC exception while rendering.");
+ // Part of TAP5-1508 changed how the exceptiopn gets reported.
+ assertTextPresent("Render queue error in
BeginRender[RenderPhaseMethodExceptionDemo]: Simulated JDBC exception while
rendering.",
+ "java.sql.SQLException");
+
}
/**
@@ -919,7 +923,7 @@ public class CoreBehaviorsTests extends
/**
* TAPESTRY-2078
- * <p>
+ * <p/>
* Update 4/29/11: Not sure this is necessary as exceptions seem to be
reported properly without the old heroics.
*/
@Test
@@ -1236,21 +1240,21 @@ public class CoreBehaviorsTests extends
/**
* asserts that the "echo value" mixins are properly functioning (ie
- *
+ *
* @BindParameter, and mixin ordering).
- * each integer value specifies the echo mixin number
(echovalue => 1,
- * echovalue2 => 2, echovalue3 => 3; 0 is the original
value)
- * from which the specified echo mixin is expected to
"receive" its value.
- * So if echo1From is 2, then the "original value"
- * printed by echo1 is expected to be the value set by
echo2. If a given
- * "from" is < 0, checking the corresponding mixin values
is disabled.
+ * each integer value specifies the echo mixin number (echovalue => 1,
+ * echovalue2 => 2, echovalue3 => 3; 0 is the original value)
+ * from which the specified echo mixin is expected to "receive" its value.
+ * So if echo1From is 2, then the "original value"
+ * printed by echo1 is expected to be the value set by echo2. If a given
+ * "from" is < 0, checking the corresponding mixin values is disabled.
*/
private void assertEchoMixins(String fieldName, String originalValue, int
echo1From, int echo2From, int echo3From,
- int fieldFrom, boolean isField)
+ int fieldFrom, boolean isField)
{
String[] vals =
- { originalValue, "temporaryvaluefromechovaluemixin", "3", "world" };
+ {originalValue, "temporaryvaluefromechovaluemixin", "3",
"world"};
String before = fieldName + "_before";
String after = fieldName + "_after";
if (echo1From > -1)
@@ -1458,7 +1462,9 @@ public class CoreBehaviorsTests extends
assertText("//h1", "Tapestry Integration Test Application");
}
- /** TAP5-815 */
+ /**
+ * TAP5-815
+ */
@Test
public void test_asset_protection()
{
@@ -1487,7 +1493,9 @@ public class CoreBehaviorsTests extends
assertTextPresent("This file should be available to clients.");
}
- /** TAP5-964 */
+ /**
+ * TAP5-964
+ */
@Test
public void failure_inside_default_object_renderer()
{
@@ -1498,7 +1506,9 @@ public class CoreBehaviorsTests extends
"Exception rendering description for object of type
org.apache.tapestry5.integration.app1.data.NullToString:
(java.lang.NullPointerException) NPE from NullToString");
}
- /** TAP5-966 */
+ /**
+ * TAP5-966
+ */
@Test
public void module_loading()
@@ -1508,7 +1518,9 @@ public class CoreBehaviorsTests extends
assertText("message", "TestOnly service message");
}
- /** TAP5-948 */
+ /**
+ * TAP5-948
+ */
@Test
public void page_reset_annotation()
{
@@ -1534,7 +1546,9 @@ public class CoreBehaviorsTests extends
assertText("current", "0");
}
- /** TAP5-948 */
+ /**
+ * TAP5-948
+ */
@Test
public void page_reset_annotation_on_bad_method()
{
@@ -1545,7 +1559,9 @@ public class CoreBehaviorsTests extends
"is invalid: methods with the @PageReset annotation must
return void, and have no parameters.");
}
- /** TAP5-1056 */
+ /**
+ * TAP5-1056
+ */
@Test
public void injection_of_application_message_catalog_into_service()
{
@@ -1554,7 +1570,9 @@ public class CoreBehaviorsTests extends
assertText("status", "Application Catalog Working");
}
- /** TAP5-1121 */
+ /**
+ * TAP5-1121
+ */
@Test
public void discard_after()
{
@@ -1587,7 +1605,9 @@ public class CoreBehaviorsTests extends
assertTextPresent("Value is: 'barney quux'");
}
- /** TAP5-1080 */
+ /**
+ * TAP5-1080
+ */
@Test
public void context_lost_on_secure_page_redirect()
{
@@ -1596,7 +1616,9 @@ public class CoreBehaviorsTests extends
assertText("context", "mycontext");
}
- /** TAP5-424 */
+ /**
+ * TAP5-424
+ */
@Test
public void multiple_resources_contributed_to_global_message_catalog()
{
@@ -1606,7 +1628,9 @@ public class CoreBehaviorsTests extends
assertText("id=override", "[app]");
}
- /** TAP5-1254 */
+ /**
+ * TAP5-1254
+ */
@Test
public void decorate_page_render_link()
{
@@ -1617,7 +1641,9 @@ public class CoreBehaviorsTests extends
assertTextPresent("Page Render Link Decorated: true");
}
- /** TAP5-1254 */
+ /**
+ * TAP5-1254
+ */
@Test
public void decorate_component_event_link()
{