JBoss Portal SVN: r9557 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 10:13:40 -0500 (Tue, 22 Jan 2008)
New Revision: 9557
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
JSR286 refs to JSR168
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:42:30 UTC (rev 9556)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 15:13:40 UTC (rev 9557)
@@ -466,11 +466,11 @@
"portlet itself, the parameters must be the string parameters encoded in the URL (added when creating the " +
"PortletURL) and the string parameters sent by the client to the portlet as part of the client request.", JSR168_48),
JSR286_68(new TCK(68), "PLT.11.1.1", "The parameters the request object returns must be \"x-www-formurlencoded\" " +
- "decoded."),
+ "decoded.", JSR168_49),
JSR286_69(new TCK(69), "PLT.11.1.1", "The value returned from the getParameter method must be the first value in " +
- "the array of String objects returned by getParameterValues"),
+ "the array of String objects returned by getParameterValues", JSR168_55),
JSR286_70(new TCK(70), "PLT.11.1.1", "If there is a single parameter value associated with a parameter name the " +
- "method must return is an array of size one containing the parameter value."),
+ "method must return is an array of size one containing the parameter value.", JSR168_56),
JSR286_71(new TCK(71), "PLT.11.1.1", "The getParameterMap method must return an unmodifiable Map object."),
JSR286_72(new TCK(72), "PLT.11.1.1", "If the request does not have any parameters, the getParameterMap must return " +
"an empty Map object"),
@@ -509,7 +509,7 @@
"getParameter methods on the PortletRequest or separated as maps of private parameters via the " +
"getPrivateParameterMap method and public parameters via the getPublicParameterMap method."),
JSR286_87(new TCK(87), "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
- "to the portlets receiving the request.."),
+ "to the portlets receiving the request.", JSR168_57),
JSR286_88(new TCK(88), "PLT.11.1.4.1", "The portlet can access a map with user information attributes via the " +
"request attribute PortletRequest.USER_INFO."),
JSR286_89(new TCK(89), "PLT.11.1.4.2", "The PortletRequest.CCPP_PROFILE request attribute must return a " +
@@ -520,12 +520,13 @@
"EventRequest, RENDER_PHASE if the current request is of type RenderRequest, and RESOURCE_SERVING_PHASE if the " +
"current request is of type ResourceRequest."),
JSR286_91(new TCK(91), "PLT.11.1.6", "If the portlet application is rooted at the base of the web server URL " +
- "namespace (also known as \"default\" context), this path must be an empty string."),
+ "namespace (also known as \"default\" context), this path must be an empty string.", JSR168_58),
JSR286_92(new TCK(92), "PLT.11.1.6", "Otherwise, it must be the path the portlet application is rooted to, the " +
- "path must start with a '/' and it must not end with a '/' character."),
- JSR286_93(new TCK(93), "PLT.11.1.7", "If the user is not authenticated the getAuthType method must return null. "),
+ "path must start with a '/' and it must not end with a '/' character.", JSR168_59),
+ JSR286_93(new TCK(93), "PLT.11.1.7", "If the user is not authenticated the getAuthType method must return null. ",
+ JSR168_60),
JSR286_94(new TCK(94), "PLT.11.1.8", "The first element of the enumeration must be the same content type returned " +
- "by the getResponseContentType method."),
+ "by the getResponseContentType method.", JSR168_61),
JSR286_95(new TCK(95), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are exposed " +
"via an ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: The content " +
"type must only includes the MIME type, not the character set."),
@@ -538,7 +539,7 @@
JSR286_98(new TCK(98), "PLT.11.2.1", "Only one of the two methods, getPortletInputStream or getReader, can be " +
"used during an action request. If the input stream is obtained, a call to the getReader must throw an " +
"IllegalStateException. Similarly, if the reader is obtained, a call to the getPortletInputStream must throw " +
- "an IllegalStateException."),
+ "an IllegalStateException.", JSR168_63),
JSR286_99(new TCK(99), "PLT.11.2.1", "If the user request HTTP POST data is of type " +
"application/x-www-form-urlencoded, this data has been already processed by the portal/portlet-container and " +
"is available as request parameters. The getPortletInputStream and getReader methods must throw an " +
18 years, 3 months
JBoss Portal SVN: r9556 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 09:42:30 -0500 (Tue, 22 Jan 2008)
New Revision: 9556
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
wrong naming
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:41:48 UTC (rev 9555)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:42:30 UTC (rev 9556)
@@ -462,84 +462,84 @@
// PLT.11 Portlet Requests
- JSR_286_67(new TCK(67), "PLT.11.1.1", "If a portlet receives a request from a client request targeted to the " +
+ JSR286_67(new TCK(67), "PLT.11.1.1", "If a portlet receives a request from a client request targeted to the " +
"portlet itself, the parameters must be the string parameters encoded in the URL (added when creating the " +
- "PortletURL) and the string parameters sent by the client to the portlet as part of the client request."),
- JSR_286_68(new TCK(68), "PLT.11.1.1", "The parameters the request object returns must be \"x-www-formurlencoded\" " +
+ "PortletURL) and the string parameters sent by the client to the portlet as part of the client request.", JSR168_48),
+ JSR286_68(new TCK(68), "PLT.11.1.1", "The parameters the request object returns must be \"x-www-formurlencoded\" " +
"decoded."),
- JSR_286_69(new TCK(69), "PLT.11.1.1", "The value returned from the getParameter method must be the first value in " +
+ JSR286_69(new TCK(69), "PLT.11.1.1", "The value returned from the getParameter method must be the first value in " +
"the array of String objects returned by getParameterValues"),
- JSR_286_70(new TCK(70), "PLT.11.1.1", "If there is a single parameter value associated with a parameter name the " +
+ JSR286_70(new TCK(70), "PLT.11.1.1", "If there is a single parameter value associated with a parameter name the " +
"method must return is an array of size one containing the parameter value."),
- JSR_286_71(new TCK(71), "PLT.11.1.1", "The getParameterMap method must return an unmodifiable Map object."),
- JSR_286_72(new TCK(72), "PLT.11.1.1", "If the request does not have any parameters, the getParameterMap must return " +
+ JSR286_71(new TCK(71), "PLT.11.1.1", "The getParameterMap method must return an unmodifiable Map object."),
+ JSR286_72(new TCK(72), "PLT.11.1.1", "If the request does not have any parameters, the getParameterMap must return " +
"an empty Map object"),
- JSR_286_73(new TCK(73), "PLT.11.1.1", "Parameters set on the portlet URL and the post body are aggregated into the " +
+ JSR286_73(new TCK(73), "PLT.11.1.1", "Parameters set on the portlet URL and the post body are aggregated into the " +
"request parameter set. Portlet URL parameters are presented before post body data."),
- JSR_286_74(new TCK(74), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
+ JSR286_74(new TCK(74), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
"or event request to subsequent render requests of the portlet."),
- JSR_286_75(new TCK(75), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
+ JSR286_75(new TCK(75), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
"to subsequent event requests of the portlet."),
- JSR_286_76(new TCK(76), "PLT.11.1.1.2", "The set render parameters must be provided to the processEvent and render " +
+ JSR286_76(new TCK(76), "PLT.11.1.1.2", "The set render parameters must be provided to the processEvent and render " +
"calls of at least the current client request."),
- JSR_286_77(new TCK(77), "PLT.11.1.1.3", "If a portlet receives a render request following an action or event " +
+ JSR286_77(new TCK(77), "PLT.11.1.1.3", "If a portlet receives a render request following an action or event " +
"request as part of the same client request, the parameters received with render request must be the render " +
"parameters set during the action or event request."),
- JSR_286_78(new TCK(78), "PLT.11.1.1.3", "If a portlet receives a render request that is the result of invoking " +
+ JSR286_78(new TCK(78), "PLT.11.1.1.3", "If a portlet receives a render request that is the result of invoking " +
"a render URL targeting this portlet the render parameters received with the render request must be the " +
"parameters set on the render URL if these were not changed by the portlet as a result of an container event " +
"received for this render URL."),
- JSR_286_79(new TCK(79), "PLT.11.1.1.3", "Commonly, portals provide controls to change the portlet mode and the " +
+ JSR286_79(new TCK(79), "PLT.11.1.1.3", "Commonly, portals provide controls to change the portlet mode and the " +
"window state of portlets. The URLs these controls use are generated by the portal. Client requests triggered " +
"by those URLs must be treated as render URLs and the existing render parameters must be preserved."),
- JSR_286_80(new TCK(80), "PLT.11.1.1.3", "A portlet must not see any parameter targeted to other portlets."),
- JSR_286_81(new TCK(81), "PLT.11.1.2", "The supportedpublic-render-parameter element must reference the identifier " +
+ JSR286_80(new TCK(80), "PLT.11.1.1.3", "A portlet must not see any parameter targeted to other portlets."),
+ JSR286_81(new TCK(81), "PLT.11.1.2", "The supportedpublic-render-parameter element must reference the identifier " +
"of a public render parameter defined in the portlet application section in a public-render-parameter element"),
- JSR_286_82(new TCK(82), "PLT.11.1.2", "The portlet container must only send those public render parameters to a " +
+ JSR286_82(new TCK(82), "PLT.11.1.2", "The portlet container must only send those public render parameters to a " +
"portlet which the portlet has defined support for using supported-public-render-parameter element in the " +
"portlet.xml."),
- JSR_286_83(new TCK(83), "PLT.11.1.2", "The portlet container must only share those render parameters of a portlet " +
+ JSR286_83(new TCK(83), "PLT.11.1.2", "The portlet container must only share those render parameters of a portlet " +
"which the portlet has declared as supported public render parameters using supported-public-render-parameter " +
"element in the portlet.xml"),
- JSR_286_84(new TCK(84), "PLT.11.1.2", "If the portlet was the target of a render URL and this render URL has set " +
+ JSR286_84(new TCK(84), "PLT.11.1.2", "If the portlet was the target of a render URL and this render URL has set " +
"a specific public render parameter the portlet must receive at least this render parameter"),
- JSR_286_85(new TCK(85), "PLT.11.1.2", "If a action or resource parameter has the same name as a public render " +
+ JSR286_85(new TCK(85), "PLT.11.1.2", "If a action or resource parameter has the same name as a public render " +
"parameter the public render parameter values must be the last entries in the parameter value array."),
- JSR_286_86(new TCK(86), "PLT.11.1.2", "Portlets can access a merged set of public and private parameters via the " +
+ JSR286_86(new TCK(86), "PLT.11.1.2", "Portlets can access a merged set of public and private parameters via the " +
"getParameter methods on the PortletRequest or separated as maps of private parameters via the " +
"getPrivateParameterMap method and public parameters via the getPublicParameterMap method."),
- JSR_286_87(new TCK(87), "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
+ JSR286_87(new TCK(87), "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
"to the portlets receiving the request.."),
- JSR_286_88(new TCK(88), "PLT.11.1.4.1", "The portlet can access a map with user information attributes via the " +
+ JSR286_88(new TCK(88), "PLT.11.1.4.1", "The portlet can access a map with user information attributes via the " +
"request attribute PortletRequest.USER_INFO."),
- JSR_286_89(new TCK(89), "PLT.11.1.4.2", "The PortletRequest.CCPP_PROFILE request attribute must return a " +
+ JSR286_89(new TCK(89), "PLT.11.1.4.2", "The PortletRequest.CCPP_PROFILE request attribute must return a " +
"javax.ccpp.Profile based on the current portlet request."),
- JSR_286_90(new TCK(90), "PLT.11.1.4.4", "The LIFECYCLE_PHASE request attribute of the PortletRequest interface " +
+ JSR286_90(new TCK(90), "PLT.11.1.4.4", "The LIFECYCLE_PHASE request attribute of the PortletRequest interface " +
"allows a portlet to determine the current lifecycle phase of this request. This attribute value must be " +
"ACTION_PHASE if the current request is of type ActionRequest, EVENT_PHASE if the current request is of type " +
"EventRequest, RENDER_PHASE if the current request is of type RenderRequest, and RESOURCE_SERVING_PHASE if the " +
"current request is of type ResourceRequest."),
- JSR_286_91(new TCK(91), "PLT.11.1.6", "If the portlet application is rooted at the base of the web server URL " +
+ JSR286_91(new TCK(91), "PLT.11.1.6", "If the portlet application is rooted at the base of the web server URL " +
"namespace (also known as \"default\" context), this path must be an empty string."),
- JSR_286_92(new TCK(92), "PLT.11.1.6", "Otherwise, it must be the path the portlet application is rooted to, the " +
+ JSR286_92(new TCK(92), "PLT.11.1.6", "Otherwise, it must be the path the portlet application is rooted to, the " +
"path must start with a '/' and it must not end with a '/' character."),
- JSR_286_93(new TCK(93), "PLT.11.1.7", "If the user is not authenticated the getAuthType method must return null. "),
- JSR_286_94(new TCK(94), "PLT.11.1.8", "The first element of the enumeration must be the same content type returned " +
+ JSR286_93(new TCK(93), "PLT.11.1.7", "If the user is not authenticated the getAuthType method must return null. "),
+ JSR286_94(new TCK(94), "PLT.11.1.8", "The first element of the enumeration must be the same content type returned " +
"by the getResponseContentType method."),
- JSR_286_95(new TCK(95), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are exposed " +
+ JSR286_95(new TCK(95), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are exposed " +
"via an ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: The content " +
"type must only includes the MIME type, not the character set."),
- JSR_286_96(new TCK(96), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are " +
+ JSR286_96(new TCK(96), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are " +
"exposed via an ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: " +
"The getResponseContentTypes method must return only the content types supported by the current portlet mode " +
"of the portlet."),
- JSR_286_97(new TCK(97), "PLT.11.1.12", "The portlet window ID retrieved with the getWindowID method must be the " +
+ JSR286_97(new TCK(97), "PLT.11.1.12", "The portlet window ID retrieved with the getWindowID method must be the " +
"same as the one that is used by the portlet container for scoping the portlet-scope session attributes."),
- JSR_286_98(new TCK(98), "PLT.11.2.1", "Only one of the two methods, getPortletInputStream or getReader, can be " +
+ JSR286_98(new TCK(98), "PLT.11.2.1", "Only one of the two methods, getPortletInputStream or getReader, can be " +
"used during an action request. If the input stream is obtained, a call to the getReader must throw an " +
"IllegalStateException. Similarly, if the reader is obtained, a call to the getPortletInputStream must throw " +
"an IllegalStateException."),
- JSR_286_99(new TCK(99), "PLT.11.2.1", "If the user request HTTP POST data is of type " +
+ JSR286_99(new TCK(99), "PLT.11.2.1", "If the user request HTTP POST data is of type " +
"application/x-www-form-urlencoded, this data has been already processed by the portal/portlet-container and " +
"is available as request parameters. The getPortletInputStream and getReader methods must throw an " +
"IllegalStateException if called."),
18 years, 3 months
JBoss Portal SVN: r9555 - branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-01-22 09:41:48 -0500 (Tue, 22 Jan 2008)
New Revision: 9555
Modified:
branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
Log:
Fix CCE
Modified: branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java 2008-01-22 14:24:35 UTC (rev 9554)
+++ branches/JBoss_Portal_Branch_2_6/widget/src/main/org/jboss/portal/widget/netvibes/NetvibesWidgetPortlet.java 2008-01-22 14:41:48 UTC (rev 9555)
@@ -162,10 +162,10 @@
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
String uri = req.getParameter("uri");
- NetvibesWidget widget = (NetvibesWidget) provider.getWidget(uri);
- if ( defaultHeight > 0)
+ Widget widget = (Widget) provider.getWidget(uri);
+ if ( widget instanceof NetvibesWidget && defaultHeight > 0)
{
- widget.setDefaultHeight(defaultHeight);
+ ((NetvibesWidget)widget).setDefaultHeight(defaultHeight);
}
if (widget != null)
{
18 years, 3 months
JBoss Portal SVN: r9554 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 09:24:35 -0500 (Tue, 22 Jan 2008)
New Revision: 9554
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
update section information
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:10:48 UTC (rev 9553)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:24:35 UTC (rev 9554)
@@ -460,85 +460,89 @@
"supported locales found in the portlet definition in the deployment descriptor with the supported-locale " +
"element or an empty enumeration if no supported locales are defined for the current portlet definition."),
- // PLT.11
+ // PLT.11 Portlet Requests
- JSR_286_67(new TCK(67), "If a portlet receives a request from a client request targeted to the portlet itself, the" +
- " parameters must be the string parameters encoded in the URL (added when creating the PortletURL) and the " +
- "string parameters sent by the client to the portlet as part of the client request."),
- JSR_286_68(new TCK(68), "The parameters the request object returns must be \"x-www-formurlencoded\" decoded."),
- JSR_286_69(new TCK(69), "The value returned from the getParameter method must be the first value in the array " +
- "of String objects returned by getParameterValues"),
- JSR_286_70(new TCK(70), "If there is a single parameter value associated with a parameter name the method must" +
- " return is an array of size one containing the parameter value."),
- JSR_286_71(new TCK(71), "The getParameterMap method must return an unmodifiable Map object."),
- JSR_286_72(new TCK(72), "If the request does not have any parameters, the getParameterMap must return an empty" +
- " Map object"),
- JSR_286_73(new TCK(73), "Parameters set on the portlet URL and the post body are aggregated into the request " +
- "parameter set. Portlet URL parameters are presented before post body data."),
- JSR_286_74(new TCK(74), "The portlet-container must not propagate parameters received in an action or event " +
- "request to subsequent render requests of the portlet."),
- JSR_286_75(new TCK(75), "The portlet-container must not propagate parameters received in an action to subsequent " +
- "event requests of the portlet."),
- JSR_286_76(new TCK(76), "The set render parameters must be provided to the processEvent and render calls of at " +
- "least the current client request."),
- JSR_286_77(new TCK(77), "If a portlet receives a render request following an action or event request as part of " +
- "the same client request, the parameters received with render request must be the render parameters set during " +
- "the action or event request."),
- JSR_286_78(new TCK(78), "If a portlet receives a render request that is the result of invoking a render URL " +
- "targeting this portlet the render parameters received with the render request must be the parameters set on " +
- "the render URL if these were not changed by the portlet as a result of an container event received for this " +
- "render URL."),
- JSR_286_79(new TCK(79), "Commonly, portals provide controls to change the portlet mode and the window state of " +
- "portlets. The URLs these controls use are generated by the portal. Client requests triggered by those URLs " +
- "must be treated as render URLs and the existing render parameters must be preserved."),
- JSR_286_80(new TCK(80), "A portlet must not see any parameter targeted to other portlets."),
- JSR_286_81(new TCK(81), "The supportedpublic-render-parameter element must reference the identifier of a public " +
- "render parameter defined in the portlet application section in a public-render-parameter element"),
- JSR_286_82(new TCK(82), "The portlet container must only send those public render parameters to a portlet which " +
- "the portlet has defined support for using supported-public-render-parameter element in the portlet.xml."),
- JSR_286_83(new TCK(83), "The portlet container must only share those render parameters of a portlet which the " +
- "portlet has declared as supported public render parameters using supported-public-render-parameter element in " +
- "the portlet.xml"),
- JSR_286_84(new TCK(84), "If the portlet was the target of a render URL and this render URL has set a specific " +
- "public render parameter the portlet must receive at least this render parameter"),
- JSR_286_85(new TCK(85), "If a action or resource parameter has the same name as a public render parameter the " +
- "public render parameter values must be the last entries in the parameter value array."),
- JSR_286_86(new TCK(86), "Portlets can access a merged set of public and private parameters via the getParameter " +
- "methods on the PortletRequest or separated as maps of private parameters via the getPrivateParameterMap method " +
- "and public parameters via the getPublicParameterMap method."),
- JSR_286_87(new TCK(87), "Extra parameters used by the portal/portlet-container must be invisible to the portlets " +
- "receiving the request.."),
- JSR_286_88(new TCK(88), "The portlet can access a map with user information attributes via the request attribute " +
- "PortletRequest.USER_INFO."),
- JSR_286_89(new TCK(89), "The PortletRequest.CCPP_PROFILE request attribute must return a javax.ccpp.Profile based " +
- "on the current portlet request."),
- JSR_286_90(new TCK(90), "The LIFECYCLE_PHASE request attribute of the PortletRequest interface allows a portlet to " +
- "determine the current lifecycle phase of this request. This attribute value must be ACTION_PHASE if the " +
- "current request is of type ActionRequest, EVENT_PHASE if the current request is of type EventRequest, " +
- "RENDER_PHASE if the current request is of type RenderRequest, and RESOURCE_SERVING_PHASE if the current " +
- "request is of type ResourceRequest."),
- JSR_286_91(new TCK(91), "If the portlet application is rooted at the base of the web server URL namespace " +
- "(also known as \"default\" context), this path must be an empty string."),
- JSR_286_92(new TCK(92), "Otherwise, it must be the path the portlet application is rooted to, the path must " +
- "start with a '/' and it must not end with a '/' character."),
- JSR_286_93(new TCK(93), "If the user is not authenticated the getAuthType method must return null. "),
- JSR_286_94(new TCK(94), "The first element of the enumeration must be the same content type returned by the " +
- "getResponseContentType method."),
- JSR_286_95(new TCK(95), "If the getResponseContentType or getResponseContentTypes methods are exposed via an " +
- "ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: The content " +
+ JSR_286_67(new TCK(67), "PLT.11.1.1", "If a portlet receives a request from a client request targeted to the " +
+ "portlet itself, the parameters must be the string parameters encoded in the URL (added when creating the " +
+ "PortletURL) and the string parameters sent by the client to the portlet as part of the client request."),
+ JSR_286_68(new TCK(68), "PLT.11.1.1", "The parameters the request object returns must be \"x-www-formurlencoded\" " +
+ "decoded."),
+ JSR_286_69(new TCK(69), "PLT.11.1.1", "The value returned from the getParameter method must be the first value in " +
+ "the array of String objects returned by getParameterValues"),
+ JSR_286_70(new TCK(70), "PLT.11.1.1", "If there is a single parameter value associated with a parameter name the " +
+ "method must return is an array of size one containing the parameter value."),
+ JSR_286_71(new TCK(71), "PLT.11.1.1", "The getParameterMap method must return an unmodifiable Map object."),
+ JSR_286_72(new TCK(72), "PLT.11.1.1", "If the request does not have any parameters, the getParameterMap must return " +
+ "an empty Map object"),
+ JSR_286_73(new TCK(73), "PLT.11.1.1", "Parameters set on the portlet URL and the post body are aggregated into the " +
+ "request parameter set. Portlet URL parameters are presented before post body data."),
+ JSR_286_74(new TCK(74), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
+ "or event request to subsequent render requests of the portlet."),
+ JSR_286_75(new TCK(75), "PLT.11.1.1.2", "The portlet-container must not propagate parameters received in an action " +
+ "to subsequent event requests of the portlet."),
+ JSR_286_76(new TCK(76), "PLT.11.1.1.2", "The set render parameters must be provided to the processEvent and render " +
+ "calls of at least the current client request."),
+ JSR_286_77(new TCK(77), "PLT.11.1.1.3", "If a portlet receives a render request following an action or event " +
+ "request as part of the same client request, the parameters received with render request must be the render " +
+ "parameters set during the action or event request."),
+ JSR_286_78(new TCK(78), "PLT.11.1.1.3", "If a portlet receives a render request that is the result of invoking " +
+ "a render URL targeting this portlet the render parameters received with the render request must be the " +
+ "parameters set on the render URL if these were not changed by the portlet as a result of an container event " +
+ "received for this render URL."),
+ JSR_286_79(new TCK(79), "PLT.11.1.1.3", "Commonly, portals provide controls to change the portlet mode and the " +
+ "window state of portlets. The URLs these controls use are generated by the portal. Client requests triggered " +
+ "by those URLs must be treated as render URLs and the existing render parameters must be preserved."),
+ JSR_286_80(new TCK(80), "PLT.11.1.1.3", "A portlet must not see any parameter targeted to other portlets."),
+ JSR_286_81(new TCK(81), "PLT.11.1.2", "The supportedpublic-render-parameter element must reference the identifier " +
+ "of a public render parameter defined in the portlet application section in a public-render-parameter element"),
+ JSR_286_82(new TCK(82), "PLT.11.1.2", "The portlet container must only send those public render parameters to a " +
+ "portlet which the portlet has defined support for using supported-public-render-parameter element in the " +
+ "portlet.xml."),
+ JSR_286_83(new TCK(83), "PLT.11.1.2", "The portlet container must only share those render parameters of a portlet " +
+ "which the portlet has declared as supported public render parameters using supported-public-render-parameter " +
+ "element in the portlet.xml"),
+ JSR_286_84(new TCK(84), "PLT.11.1.2", "If the portlet was the target of a render URL and this render URL has set " +
+ "a specific public render parameter the portlet must receive at least this render parameter"),
+ JSR_286_85(new TCK(85), "PLT.11.1.2", "If a action or resource parameter has the same name as a public render " +
+ "parameter the public render parameter values must be the last entries in the parameter value array."),
+ JSR_286_86(new TCK(86), "PLT.11.1.2", "Portlets can access a merged set of public and private parameters via the " +
+ "getParameter methods on the PortletRequest or separated as maps of private parameters via the " +
+ "getPrivateParameterMap method and public parameters via the getPublicParameterMap method."),
+ JSR_286_87(new TCK(87), "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
+ "to the portlets receiving the request.."),
+ JSR_286_88(new TCK(88), "PLT.11.1.4.1", "The portlet can access a map with user information attributes via the " +
+ "request attribute PortletRequest.USER_INFO."),
+ JSR_286_89(new TCK(89), "PLT.11.1.4.2", "The PortletRequest.CCPP_PROFILE request attribute must return a " +
+ "javax.ccpp.Profile based on the current portlet request."),
+ JSR_286_90(new TCK(90), "PLT.11.1.4.4", "The LIFECYCLE_PHASE request attribute of the PortletRequest interface " +
+ "allows a portlet to determine the current lifecycle phase of this request. This attribute value must be " +
+ "ACTION_PHASE if the current request is of type ActionRequest, EVENT_PHASE if the current request is of type " +
+ "EventRequest, RENDER_PHASE if the current request is of type RenderRequest, and RESOURCE_SERVING_PHASE if the " +
+ "current request is of type ResourceRequest."),
+ JSR_286_91(new TCK(91), "PLT.11.1.6", "If the portlet application is rooted at the base of the web server URL " +
+ "namespace (also known as \"default\" context), this path must be an empty string."),
+ JSR_286_92(new TCK(92), "PLT.11.1.6", "Otherwise, it must be the path the portlet application is rooted to, the " +
+ "path must start with a '/' and it must not end with a '/' character."),
+ JSR_286_93(new TCK(93), "PLT.11.1.7", "If the user is not authenticated the getAuthType method must return null. "),
+ JSR_286_94(new TCK(94), "PLT.11.1.8", "The first element of the enumeration must be the same content type returned " +
+ "by the getResponseContentType method."),
+ JSR_286_95(new TCK(95), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are exposed " +
+ "via an ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: The content " +
"type must only includes the MIME type, not the character set."),
- JSR_286_96(new TCK(96), "If the getResponseContentType or getResponseContentTypes methods are exposed via an " +
- "ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: " +
+ JSR_286_96(new TCK(96), "PLT.11.1.8", "If the getResponseContentType or getResponseContentTypes methods are " +
+ "exposed via an ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: " +
"The getResponseContentTypes method must return only the content types supported by the current portlet mode " +
"of the portlet."),
- JSR_286_97(new TCK(97), "The portlet window ID retrieved with the getWindowID method must be the same as the one " +
- "that is used by the portlet container for scoping the portlet-scope session attributes."),
- JSR_286_98(new TCK(98), "Only one of the two methods, getPortletInputStream or getReader, can be used during an " +
- "action request. If the input stream is obtained, a call to the getReader must throw an IllegalStateException. " +
- "Similarly, if the reader is obtained, a call to the getPortletInputStream must throw an IllegalStateException."),
- JSR_286_99(new TCK(99), "If the user request HTTP POST data is of type application/x-www-form-urlencoded, this " +
- "data has been already processed by the portal/portlet-container and is available as request parameters. The " +
- "getPortletInputStream and getReader methods must throw an IllegalStateException if called."),
+ JSR_286_97(new TCK(97), "PLT.11.1.12", "The portlet window ID retrieved with the getWindowID method must be the " +
+ "same as the one that is used by the portlet container for scoping the portlet-scope session attributes."),
+ JSR_286_98(new TCK(98), "PLT.11.2.1", "Only one of the two methods, getPortletInputStream or getReader, can be " +
+ "used during an action request. If the input stream is obtained, a call to the getReader must throw an " +
+ "IllegalStateException. Similarly, if the reader is obtained, a call to the getPortletInputStream must throw " +
+ "an IllegalStateException."),
+ JSR_286_99(new TCK(99), "PLT.11.2.1", "If the user request HTTP POST data is of type " +
+ "application/x-www-form-urlencoded, this data has been already processed by the portal/portlet-container and " +
+ "is available as request parameters. The getPortletInputStream and getReader methods must throw an " +
+ "IllegalStateException if called."),
// PLT.12 Portlet Responses
@@ -753,6 +757,9 @@
/** . */
private Status status;
+ /** . */
+ private Assertion assertion;
+
Assertion(Ref ref, String description)
{
this(ref, description, new Active());
@@ -763,6 +770,11 @@
this(ref, description, section, new Active());
}
+ Assertion(Ref ref, String section, String description, Assertion assertion)
+ {
+ this(ref, description, section, new Active(), assertion);
+ }
+
Assertion(Ref ref, String description, Status status)
{
this.ref = ref;
@@ -779,8 +791,17 @@
this.status = status;
}
+ Assertion(Ref ref, String section, String description, Status status, Assertion assertion)
+ {
+ this.ref = ref;
+ this.description = description;
+ this.section = section;
+ this.status = status;
+ this.assertion = assertion;
+ }
+
public Ref getRef()
{
return ref;
@@ -800,4 +821,9 @@
{
return section;
}
+
+ public Assertion getAssertion()
+ {
+ return assertion;
+ }
}
18 years, 3 months
JBoss Portal SVN: r9553 - in modules/portlet/trunk/portlet: src/test/java/org/jboss/portal/unit and 1 other directory.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 09:10:48 -0500 (Tue, 22 Jan 2008)
New Revision: 9553
Modified:
modules/portlet/trunk/portlet/pom.xml
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
JSR 286 PLT.11 assertions
Modified: modules/portlet/trunk/portlet/pom.xml
===================================================================
--- modules/portlet/trunk/portlet/pom.xml 2008-01-22 13:31:02 UTC (rev 9552)
+++ modules/portlet/trunk/portlet/pom.xml 2008-01-22 14:10:48 UTC (rev 9553)
@@ -82,6 +82,13 @@
</execution>
</executions>
<configuration>
+
+ <!--Uncomment if needed-->
+ <!--<jpda>false</jpda>-->
+ <!--<jpdaPort>9000</jpdaPort>-->
+ <!--<jpdaSuspend>true</jpdaSuspend>-->
+ <!--<failOnError>false</failOnError>-->
+ <!--<assertions>true</assertions>-->
<testsuites>
<testsuite>
<config>local-jboss-unit.xml</config>
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 13:31:02 UTC (rev 9552)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-22 14:10:48 UTC (rev 9553)
@@ -460,6 +460,86 @@
"supported locales found in the portlet definition in the deployment descriptor with the supported-locale " +
"element or an empty enumeration if no supported locales are defined for the current portlet definition."),
+ // PLT.11
+
+ JSR_286_67(new TCK(67), "If a portlet receives a request from a client request targeted to the portlet itself, the" +
+ " parameters must be the string parameters encoded in the URL (added when creating the PortletURL) and the " +
+ "string parameters sent by the client to the portlet as part of the client request."),
+ JSR_286_68(new TCK(68), "The parameters the request object returns must be \"x-www-formurlencoded\" decoded."),
+ JSR_286_69(new TCK(69), "The value returned from the getParameter method must be the first value in the array " +
+ "of String objects returned by getParameterValues"),
+ JSR_286_70(new TCK(70), "If there is a single parameter value associated with a parameter name the method must" +
+ " return is an array of size one containing the parameter value."),
+ JSR_286_71(new TCK(71), "The getParameterMap method must return an unmodifiable Map object."),
+ JSR_286_72(new TCK(72), "If the request does not have any parameters, the getParameterMap must return an empty" +
+ " Map object"),
+ JSR_286_73(new TCK(73), "Parameters set on the portlet URL and the post body are aggregated into the request " +
+ "parameter set. Portlet URL parameters are presented before post body data."),
+ JSR_286_74(new TCK(74), "The portlet-container must not propagate parameters received in an action or event " +
+ "request to subsequent render requests of the portlet."),
+ JSR_286_75(new TCK(75), "The portlet-container must not propagate parameters received in an action to subsequent " +
+ "event requests of the portlet."),
+ JSR_286_76(new TCK(76), "The set render parameters must be provided to the processEvent and render calls of at " +
+ "least the current client request."),
+ JSR_286_77(new TCK(77), "If a portlet receives a render request following an action or event request as part of " +
+ "the same client request, the parameters received with render request must be the render parameters set during " +
+ "the action or event request."),
+ JSR_286_78(new TCK(78), "If a portlet receives a render request that is the result of invoking a render URL " +
+ "targeting this portlet the render parameters received with the render request must be the parameters set on " +
+ "the render URL if these were not changed by the portlet as a result of an container event received for this " +
+ "render URL."),
+ JSR_286_79(new TCK(79), "Commonly, portals provide controls to change the portlet mode and the window state of " +
+ "portlets. The URLs these controls use are generated by the portal. Client requests triggered by those URLs " +
+ "must be treated as render URLs and the existing render parameters must be preserved."),
+ JSR_286_80(new TCK(80), "A portlet must not see any parameter targeted to other portlets."),
+ JSR_286_81(new TCK(81), "The supportedpublic-render-parameter element must reference the identifier of a public " +
+ "render parameter defined in the portlet application section in a public-render-parameter element"),
+ JSR_286_82(new TCK(82), "The portlet container must only send those public render parameters to a portlet which " +
+ "the portlet has defined support for using supported-public-render-parameter element in the portlet.xml."),
+ JSR_286_83(new TCK(83), "The portlet container must only share those render parameters of a portlet which the " +
+ "portlet has declared as supported public render parameters using supported-public-render-parameter element in " +
+ "the portlet.xml"),
+ JSR_286_84(new TCK(84), "If the portlet was the target of a render URL and this render URL has set a specific " +
+ "public render parameter the portlet must receive at least this render parameter"),
+ JSR_286_85(new TCK(85), "If a action or resource parameter has the same name as a public render parameter the " +
+ "public render parameter values must be the last entries in the parameter value array."),
+ JSR_286_86(new TCK(86), "Portlets can access a merged set of public and private parameters via the getParameter " +
+ "methods on the PortletRequest or separated as maps of private parameters via the getPrivateParameterMap method " +
+ "and public parameters via the getPublicParameterMap method."),
+ JSR_286_87(new TCK(87), "Extra parameters used by the portal/portlet-container must be invisible to the portlets " +
+ "receiving the request.."),
+ JSR_286_88(new TCK(88), "The portlet can access a map with user information attributes via the request attribute " +
+ "PortletRequest.USER_INFO."),
+ JSR_286_89(new TCK(89), "The PortletRequest.CCPP_PROFILE request attribute must return a javax.ccpp.Profile based " +
+ "on the current portlet request."),
+ JSR_286_90(new TCK(90), "The LIFECYCLE_PHASE request attribute of the PortletRequest interface allows a portlet to " +
+ "determine the current lifecycle phase of this request. This attribute value must be ACTION_PHASE if the " +
+ "current request is of type ActionRequest, EVENT_PHASE if the current request is of type EventRequest, " +
+ "RENDER_PHASE if the current request is of type RenderRequest, and RESOURCE_SERVING_PHASE if the current " +
+ "request is of type ResourceRequest."),
+ JSR_286_91(new TCK(91), "If the portlet application is rooted at the base of the web server URL namespace " +
+ "(also known as \"default\" context), this path must be an empty string."),
+ JSR_286_92(new TCK(92), "Otherwise, it must be the path the portlet application is rooted to, the path must " +
+ "start with a '/' and it must not end with a '/' character."),
+ JSR_286_93(new TCK(93), "If the user is not authenticated the getAuthType method must return null. "),
+ JSR_286_94(new TCK(94), "The first element of the enumeration must be the same content type returned by the " +
+ "getResponseContentType method."),
+ JSR_286_95(new TCK(95), "If the getResponseContentType or getResponseContentTypes methods are exposed via an " +
+ "ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: The content " +
+ "type must only includes the MIME type, not the character set."),
+ JSR_286_96(new TCK(96), "If the getResponseContentType or getResponseContentTypes methods are exposed via an " +
+ "ActionRequest, EventRequest, or RenderRequest the following additional restrictions apply: " +
+ "The getResponseContentTypes method must return only the content types supported by the current portlet mode " +
+ "of the portlet."),
+ JSR_286_97(new TCK(97), "The portlet window ID retrieved with the getWindowID method must be the same as the one " +
+ "that is used by the portlet container for scoping the portlet-scope session attributes."),
+ JSR_286_98(new TCK(98), "Only one of the two methods, getPortletInputStream or getReader, can be used during an " +
+ "action request. If the input stream is obtained, a call to the getReader must throw an IllegalStateException. " +
+ "Similarly, if the reader is obtained, a call to the getPortletInputStream must throw an IllegalStateException."),
+ JSR_286_99(new TCK(99), "If the user request HTTP POST data is of type application/x-www-form-urlencoded, this " +
+ "data has been already processed by the portal/portlet-container and is available as request parameters. The " +
+ "getPortletInputStream and getReader methods must throw an IllegalStateException if called."),
+
// PLT.12 Portlet Responses
JSR286_103(new TCK(103), "Using the setRenderParameter and setRenderParameters methods portlets may set " +
18 years, 3 months
JBoss Portal SVN: r9552 - in modules/portlet/trunk/portlet/src: test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 08:31:02 -0500 (Tue, 22 Jan 2008)
New Revision: 9552
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterTestCase.java
Log:
- update implementation of PortletURL for action url to take in account spec clarifications
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-22 13:31:02 UTC (rev 9552)
@@ -62,17 +62,17 @@
/** @throws IllegalArgumentException if the name is null */
public void setParameter(String name, String value)
{
- url.parameters.setParameterValue(name, value);
+ url.setParameter(name, value);
}
public void setParameter(String name, String[] values)
{
- url.parameters.setParameterValues(name, values);
+ url.setParameter(name, values);
}
public void setParameters(Map<String, String[]> parameters)
{
- url.parameters.setMap(parameters);
+ url.setParameters(parameters);
}
public void setSecure(boolean secure) throws PortletSecurityException
@@ -114,12 +114,11 @@
protected static abstract class InternalContainerURL implements org.jboss.portal.portlet.ContainerURL
{
- /** . */
- protected final PortletParameterMap parameters;
+ protected abstract void setParameter(String name, String value);
- protected InternalContainerURL(PortletParameterMap parameters)
- {
- this.parameters = parameters;
- }
+ protected abstract void setParameter(String name, String[] values);
+
+ protected abstract void setParameters(Map<String, String[]> parameters);
+
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-22 13:31:02 UTC (rev 9552)
@@ -37,6 +37,7 @@
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
import java.util.Map;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -48,7 +49,7 @@
public static PortletURLImpl createActionURL(PortletInvocation invocation, PortletRequestImpl preq)
{
StateString navigationalState = invocation.getContext().getNavigationalState();
- InternalActionURL url = new InternalActionURL(new PortletParameterMap(preq.navigationInfo), navigationalState);
+ InternalActionURL url = new InternalActionURL(navigationalState);
return new PortletURLImpl(invocation, preq, url);
}
@@ -111,7 +112,7 @@
public void removePublicRenderParameter(String name)
{
- url.parameters.removePublicParameterValue(name);
+ url.removePublicRenderParameter(name);
}
private static abstract class InternalPortletURL extends InternalContainerURL implements org.jboss.portal.portlet.PortletURL
@@ -123,11 +124,6 @@
/** . */
protected PortletMode portletMode;
- protected InternalPortletURL(PortletParameterMap parameters)
- {
- super(parameters);
- }
-
public Mode getMode()
{
if (portletMode != null)
@@ -146,10 +142,7 @@
return null;
}
- public Map<String, String[]> getPublicNavigationalStateChanges()
- {
- return parameters.getPublicMapSnapshot();
- }
+ protected abstract void removePublicRenderParameter(String name);
}
private static class InternalActionURL extends InternalPortletURL implements ActionURL
@@ -158,36 +151,88 @@
/** . */
private final StateString navigationalState;
- private InternalActionURL(PortletParameterMap parameters, StateString navigationalState)
+ /** . */
+ private final ParametersStateString interactionState;
+
+ private InternalActionURL(StateString navigationalState)
{
- super(parameters);
-
- //
this.navigationalState = navigationalState;
+ this.interactionState = ParametersStateString.create();
}
public StateString getInteractionState()
{
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ return interactionState;
}
public StateString getNavigationalState()
{
return navigationalState;
}
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
+ {
+ return Collections.emptyMap();
+ }
+
+ protected void setParameter(String name, String value)
+ {
+ interactionState.setValue(name, value);
+ }
+
+ protected void setParameter(String name, String[] values)
+ {
+ interactionState.setValues(name, values);
+ }
+
+ protected void setParameters(Map<String, String[]> parameters)
+ {
+ interactionState.replace(parameters);
+ }
+
+ protected void removePublicRenderParameter(String name)
+ {
+ }
}
private static class InternalRenderURL extends InternalPortletURL implements RenderURL
{
+ private final PortletParameterMap parameters;
+
private InternalRenderURL(PortletParameterMap parameters)
{
- super(parameters);
+ this.parameters = parameters;
}
public StateString getNavigationalState()
{
return ParametersStateString.create(parameters.getPrivateMapSnapshot());
}
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
+ {
+ return parameters.getPublicMapSnapshot();
+ }
+
+ protected void setParameter(String name, String value)
+ {
+ parameters.setParameterValue(name, value);
+ }
+
+ protected void setParameter(String name, String[] values)
+ {
+ parameters.setParameterValues(name, values);
+ }
+
+ protected void setParameters(Map<String, String[]> parameterMap)
+ {
+ parameters.setMap(parameterMap);
+ }
+
+ protected void removePublicRenderParameter(String name)
+ {
+ parameters.removePublicParameterValue(name);
+ }
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-22 13:31:02 UTC (rev 9552)
@@ -134,8 +134,7 @@
public static ResourceURLImpl createResourceURL(PortletInvocation invocation, PortletRequestImpl preq)
{
- InternalResourceURL url = new InternalResourceURL(new PortletParameterMap(preq.navigationInfo));
- return new ResourceURLImpl(invocation, preq, url);
+ return new ResourceURLImpl(invocation, preq, new InternalResourceURL());
}
private static class InternalResourceURL extends InternalContainerURL implements org.jboss.portal.portlet.ResourceURL
@@ -150,14 +149,32 @@
/** . */
private Cacheability cacheability;
- private InternalResourceURL(PortletParameterMap parameters)
+ /** . */
+ private ParametersStateString parameters;
+
+ private InternalResourceURL()
{
- super(parameters);
+ this.parameters = ParametersStateString.create();
}
+ protected void setParameter(String name, String value)
+ {
+ parameters.setValue(name, value);
+ }
+
+ protected void setParameter(String name, String[] values)
+ {
+ parameters.setValues(name, values);
+ }
+
+ protected void setParameters(Map<String, String[]> parameterMap)
+ {
+ parameters.replace(parameterMap);
+ }
+
public StateString getResourceState()
{
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ return parameters;
}
public String getId()
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterTestCase.java 2008-01-22 12:30:44 UTC (rev 9551)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/PublicRenderParameterTestCase.java 2008-01-22 13:31:02 UTC (rev 9552)
@@ -36,7 +36,9 @@
import static org.jboss.unit.api.Assert.*;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.Failure;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
@@ -106,14 +108,8 @@
protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
{
assertEquals(2, renderCount);
- try
- {
- assertEquals("bar", request.getParameterMap().get("foo"));
- }
- catch (AssertionError e)
- {
- e.printStackTrace();
- }
+ String[] strings = request.getParameterMap().get("foo");
+ assertEquals(new String[]{"bar","foo"}, strings);
response.removePublicRenderParameter("foo");
renderCount = 0;
}
@@ -134,7 +130,8 @@
String foo = request.getParameter("foo");
assertEquals(null, foo);
renderCount++;
- return ++renderCount == 2 ? new EndTestResponse() : null;
+ assertEquals(2, renderCount);
+ return new EndTestResponse();
}
});
}
18 years, 3 months
JBoss Portal SVN: r9551 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168 and 13 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-22 07:30:44 -0500 (Tue, 22 Jan 2008)
New Revision: 9551
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceServingTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- added support for resource serving testing
- fixed a couple of bugs in resource serving preliminary impl
- added an initial test case for resource serving
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -30,6 +30,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
@@ -58,6 +59,11 @@
// Invoke
return invocation.invokeNext();
}
+ else if (invocation instanceof ResourceInvocation)
+ {
+ // Invoke
+ return invocation.invokeNext();
+ }
else if (invocation instanceof RenderInvocation)
{
// Invoke
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -363,9 +363,13 @@
{
return invokeEvent((EventInvocation)invocation);
}
+ else if (invocation instanceof ResourceInvocation)
+ {
+ return invokeResource((ResourceInvocation)invocation);
+ }
else
{
- throw new InvocationException("Unexpected invocation " + invocation);
+ throw new InvocationException("Unexpected invocation " + invocation);
}
}
catch (NoClassDefFoundError e)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -176,7 +176,7 @@
public ResourceURL createResourceURL()
{
- throw new NotYetImplemented();
+ return ResourceURLImpl.createResourceURL(invocation, preq);
}
public CacheControl getCacheControl()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -79,7 +79,7 @@
//
if (invocation instanceof ResourceInvocation)
{
- url.constraint = ((ResourceInvocation)invocation).getContext().getCacheability();
+ url.parentCacheability = ((ResourceInvocation)invocation).getContext().getCacheability();
}
}
@@ -93,15 +93,9 @@
public String getCacheability()
{
- Cacheability cacheability = url.cacheability;
+ Cacheability cacheability = url.getCacheability();
//
- if (cacheability == null)
- {
- cacheability = url.constraint != null ? url.constraint : Cacheability.PAGE;
- }
-
- //
return typetoJSR168.get(cacheability);
}
@@ -112,13 +106,13 @@
//
if (cacheability != null)
{
- if (url.constraint == null)
+ if (url.parentCacheability == null)
{
url.cacheability = cacheability;
}
else
{
- switch (url.constraint)
+ switch (url.parentCacheability)
{
case FULL:
if (cacheability != Cacheability.FULL)
@@ -151,7 +145,7 @@
private String id;
/** The cacheability constraining the url cacheability. */
- private Cacheability constraint;
+ private Cacheability parentCacheability;
/** . */
private Cacheability cacheability;
@@ -173,7 +167,21 @@
public Cacheability getCacheability()
{
- return cacheability;
+ if (cacheability != null)
+ {
+ return cacheability;
+ }
+ else
+ {
+ if (parentCacheability != null)
+ {
+ return parentCacheability;
+ }
+ else
+ {
+ return Cacheability.PAGE;
+ }
+ }
}
}
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP1.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -57,6 +57,8 @@
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME, JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint RESOURCE_JOIN_POINT = new JoinPoint(NAME, JoinPointType.PORTLET_RESOURCE);
+
/** Resets helper variables */
public void reset()
{
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceServingTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceServingTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/resourceserving/ResourceServingTestCase.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.resourceserving;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceURL;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.PrintWriter;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase({Assertion.JSR168_1000})
+public class ResourceServingTestCase
+{
+
+ private String blah;
+
+ public ResourceServingTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ blah = response.createRenderURL().toString();
+
+ ResourceURL resourceURL = response.createResourceURL();
+ resourceURL.setResourceID("blah");
+ resourceURL.setParameter("foo", "bar");
+ String s = resourceURL.toString();
+ return new InvokeGetResponse(s);
+ }
+ });
+ seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("blah", request.getResourceID());
+ assertEquals("bar", request.getParameter("foo"));
+ assertEquals(ResourceURL.PAGE, request.getCacheability());
+
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("foo");
+ writer.close();
+
+ return new InvokeGetResponse(blah);
+ }
+ });
+ seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+
+ byte[] bytes = (byte[])context.getPayload().get("http.response.body");
+ System.out.println("bytes.length = " + bytes.length);
+
+ for (Map.Entry<String, Serializable> entry : context.getPayload().entrySet())
+ {
+
+
+ System.out.println("entry.getKey() = " + entry.getKey());
+ System.out.println("entry.getValue() = " + entry.getValue());
+ }
+
+ return new EndTestResponse();
+ }
+ });
+ }
+
+// entry.getKey() = http.response.body
+// entry.getValue() = [B@bdcd96
+// entry.getKey() = http.response.headers
+// entry.getValue() = Server: Apache-Coyote/1.1
+// Content-Length: 0
+// Date: Tue,22 Jan 2008 01:23:43 GMT
+//
+
+
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/JoinPointType.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -32,6 +32,7 @@
PORTLET_ACTION("portlet.action"),
PORTLET_EVENT("portlet.event"),
PORTLET_RENDER("portlet.render"),
+ PORTLET_RESOURCE("portlet.resource"),
SERVLET_SERVICE("servlet.service");
/** . */
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -32,6 +32,7 @@
import java.net.MalformedURLException;
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -102,4 +103,10 @@
}
return requestContext.getParametrization().get(parameterName);
}
+
+ public Map<String, Serializable> getPayload()
+ {
+ return requestContext.getPayload();
+ }
+
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/actions/PortletResourceTestAction.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.unit.actions;
+
+import org.jboss.portal.unit.TestAction;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.Failure;
+
+import javax.portlet.Portlet;
+import javax.portlet.PortletException;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 7954 $
+ */
+public abstract class PortletResourceTestAction extends TestAction
+{
+
+ public DriverResponse execute(Portlet servlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ try
+ {
+ return run(servlet, request, response, context);
+ }
+ catch (Exception e)
+ {
+ if (e instanceof PortletException)
+ {
+ throw (PortletException)e;
+ }
+ if (e instanceof IOException)
+ {
+ throw (IOException)e;
+ }
+ return new FailureResponse(Failure.createAssertionFailure(e));
+ }
+ catch (AssertionError t)
+ {
+ return new FailureResponse(Failure.createFailure(t));
+ }
+ }
+
+ protected abstract DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException;
+}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/base/AbstractUniversalTestPortlet.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -28,6 +28,7 @@
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.unit.TestAction;
import org.jboss.portal.unit.PortletTestContext;
import org.jboss.portal.test.framework.server.NodeId;
@@ -49,6 +50,9 @@
import javax.portlet.EventPortlet;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
+import javax.portlet.ResourceServingPortlet;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
import java.io.IOException;
/**
@@ -57,7 +61,7 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.com">Boleslaw Dawidowicz</a>
* @version $Revision: 7954 $
*/
-public abstract class AbstractUniversalTestPortlet implements Portlet, EventPortlet
+public abstract class AbstractUniversalTestPortlet implements Portlet, EventPortlet, ResourceServingPortlet
{
public static String getPortletName()
@@ -84,6 +88,9 @@
/** Joinpoint for action phase. */
private final JoinPoint actionJoinPoint = JoinPoint.createJoinPoint(getClass(), JoinPointType.PORTLET_ACTION);
+ /** Joinpoint for resource serving. */
+ private final JoinPoint resourceJoinPoint = JoinPoint.createJoinPoint(getClass(), JoinPointType.PORTLET_RESOURCE);
+
/** To keep PortletConfig for some tests*-. */
private PortletConfig config;
@@ -266,6 +273,45 @@
}
}
+ public void serveResource(ResourceRequest req, ResourceResponse resp) throws PortletException, IOException
+ {
+ PortletTestContext ctx = PortletTestDriver.getPortletTestContext();
+
+ //
+ log.debug("JoinPoint '" + resourceJoinPoint + " invoked for '"
+ + ctx.getTestName() + "' testId and '" +
+ +ctx.getRequestCount() + "' request count");
+
+ // Get the action
+ TestAction action = null;
+ PortletTestCase portletTestCase = getSequence(ctx.getTestName());
+ if (portletTestCase != null)
+ {
+ action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), resourceJoinPoint);
+
+ }
+
+ //
+ if (action == null)
+ {
+ ctx.setResponse(new FailureResponse(Failure.createAssertionFailure("No action for " + ctx.getRequestCount() + " " + NodeId.locate() + " " + resourceJoinPoint)));
+ }
+ else if (action instanceof PortletResourceTestAction == false)
+ {
+ ctx.setResponse(new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() + " " + NodeId.locate() + " " + resourceJoinPoint + " is not an instance of " + PortletResourceTestAction.class.getName() + " but is " + action.getClass().getName())));
+ }
+ else
+ {
+ log.debug("Found action for joinpoint " + resourceJoinPoint + " : " + action);
+
+ // Get the result that must exist since it is the only joinpoint invoked during this request
+ DriverResponse response = ((PortletResourceTestAction)action).execute(this, req, resp, ctx);
+
+ //
+ ctx.setResponse(response);
+ }
+ }
+
public void destroy()
{
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-22 12:30:44 UTC (rev 9551)
@@ -42,6 +42,7 @@
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
@@ -50,16 +51,19 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletOutputStream;
import javax.xml.namespace.QName;
import java.io.UnsupportedEncodingException;
import java.io.PrintWriter;
import java.io.IOException;
+import java.io.Writer;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -472,6 +476,57 @@
else if (containerRequest instanceof PortletResourceRequest)
{
PortletInvocationResponse response = handle(context, containerRequest);
+
+ //
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+
+ if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = fragment.getContentType();
+ if (contentType != null)
+ {
+ resp.setContentType(contentType);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = resp.getOutputStream();
+ out.write(fragment.getBytes().toByteArray());
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ writer.write(fragment.getChars().toString());
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ }
+ }
+ else
+ {
+ // todo
+ }
}
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-22 12:30:44 UTC (rev 9551)
@@ -230,6 +230,7 @@
<package-jsr286-tck-test test="eventnonamespace"/>
<package-jsr286-tck-test test="stateawareresponse"/>
<package-jsr286-tck-test test="portletrequests"/>
+ <package-jsr286-tck-test test="resourceserving"/>
<package-jsr286-api-test test="event"/>
Copied: modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml (from rev 9546, modules/portlet/trunk/test/src/test/resources/jsr286/tck/stateawareresponse-war/WEB-INF/portlet.xml)
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/portlet.xml 2008-01-22 12:30:44 UTC (rev 9551)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ </portlet>
+
+</portlet-app>
Copied: modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/web.xml (from rev 9546, modules/portlet/trunk/test/src/test/resources/jsr286/tck/stateawareresponse-war/WEB-INF/web.xml)
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/resourceserving-war/WEB-INF/web.xml 2008-01-22 12:30:44 UTC (rev 9551)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+ <listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 12:13:44 UTC (rev 9550)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-22 12:30:44 UTC (rev 9551)
@@ -173,6 +173,10 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr286-tck-portletrequests.war"/>
</generic>
+ <generic>
+ <class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId" value="test-jsr286-tck-resourceserving.war"/>
+ </generic>
<!--Spec API Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9550 - modules/portlet/trunk/test/src/test.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 07:13:44 -0500 (Tue, 22 Jan 2008)
New Revision: 9550
Modified:
modules/portlet/trunk/test/src/test/build.xml
Log:
update for jboss-unit changes
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-01-22 11:39:19 UTC (rev 9549)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-01-22 12:13:44 UTC (rev 9550)
@@ -586,9 +586,9 @@
<taskdef name="jboss-unit" classname="org.jboss.unit.tooling.ant.JBossUnitTask" classpath="${plugin_classpath}"/>
- <jboss-unit>
+ <jboss-unit jpda="false" jpdaPort="9000" jpdaSuspend="true" failOnError="false">
- <tests config="${target}/test-classes/test/remote-jboss-unit.xml" jpda="false">
+ <tests config="${target}/test-classes/test/remote-jboss-unit.xml">
<property name="archivePath" value="${test.temp.lib}"/>
<property name="serverName" value="${test.server.name}"/>
</tests>
18 years, 3 months
JBoss Portal SVN: r9549 - in modules/test/trunk: tooling/core/src/main/java/org/jboss/unit/tooling and 7 other directories.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-22 06:39:19 -0500 (Tue, 22 Jan 2008)
New Revision: 9549
Added:
modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/TestFailedException.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/FailureManagerListener.java
Modified:
modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java
modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/TestsType.java
modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/JavaBuilder.java
modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/ToolingConstants.java
modules/test/trunk/tooling/examples/maven2/pom.xml
modules/test/trunk/tooling/examples/maven2/src/test/java/org/jboss/test/unit/tooling/TestSimple.java
modules/test/trunk/tooling/maven2/pom.xml
modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/TestSuiteExecutor.java
modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java
modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/report/impl/writer/PrintListener.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/Main.java
modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/MainBuilder.java
Log:
- extend configuration using commandline arguments
Modified: modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java
===================================================================
--- modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/JBossUnitTask.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -41,6 +41,7 @@
*/
public class JBossUnitTask extends Task
{
+ public static final String MAVEN_SKIP_TEST = "maven.skip.test";
List<TestsType> testsTypes = new LinkedList();
@@ -48,6 +49,18 @@
private Path path;
+ private boolean jpda;
+
+ private String jpdaPort = "9000";
+
+ private boolean jpdaSuspend = true;
+
+ private boolean useJUL = true;
+
+ private boolean assertions = true;
+
+ private boolean failOnError = false;
+
private Set<Environment.Variable> sysproperties = new HashSet<Environment.Variable>();
private Set<ParameterType> parameters = new HashSet<ParameterType>();
@@ -59,6 +72,7 @@
public void addConfiguredTests(TestsType tests)
{
tests.setProject(getProject());
+ tests.setParent(this);
testsTypes.add(tests);
}
@@ -81,6 +95,19 @@
public void execute() throws BuildException
{
+
+ String testSkip = (String)getProject().getProperties().get(MAVEN_SKIP_TEST);
+
+ // Skip tests
+ if (testSkip != null && testSkip.equalsIgnoreCase("true"))
+ {
+ //TODO: make it logging
+
+ System.out.println("Skipping test execution: " + MAVEN_SKIP_TEST + " set to true");
+
+ return;
+ }
+
for (TestsType testsType : testsTypes)
{
@@ -132,5 +159,63 @@
this.reports = reports;
}
-
+ public boolean isJpda()
+ {
+ return jpda;
+ }
+
+ public void setJpda(boolean jpda)
+ {
+ this.jpda = jpda;
+ }
+
+ public String getJpdaPort()
+ {
+ return jpdaPort;
+ }
+
+ public void setJpdaPort(String jpdaPort)
+ {
+ this.jpdaPort = jpdaPort;
+ }
+
+ public boolean isJpdaSuspend()
+ {
+ return jpdaSuspend;
+ }
+
+ public void setJpdaSuspend(boolean jpdaSuspend)
+ {
+ this.jpdaSuspend = jpdaSuspend;
+ }
+
+ public boolean isUseJUL()
+ {
+ return useJUL;
+ }
+
+ public void setUseJUL(boolean useJUL)
+ {
+ this.useJUL = useJUL;
+ }
+
+ public boolean isAssertions()
+ {
+ return assertions;
+ }
+
+ public void setAssertions(boolean assertions)
+ {
+ this.assertions = assertions;
+ }
+
+ public boolean isFailOnError()
+ {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError)
+ {
+ this.failOnError = failOnError;
+ }
}
Modified: modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/TestsType.java
===================================================================
--- modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/TestsType.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/ant/src/main/java/org/jboss/unit/tooling/ant/TestsType.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -29,6 +29,7 @@
import org.apache.tools.ant.types.Path;
import org.jboss.unit.tooling.JavaBuilder;
import org.jboss.unit.tooling.TaskExecutingThread;
+import org.jboss.unit.tooling.TestFailedException;
import org.jboss.unit.tooling.ant.configuration.ExcludeType;
import org.jboss.unit.tooling.ant.configuration.IncludeType;
import org.jboss.unit.tooling.ant.configuration.ParameterType;
@@ -64,16 +65,14 @@
private String suiteName;
- private boolean jpda;
-
private List<PropertyType> properties = new ArrayList<PropertyType>();
private Set<Environment.Variable> sysproperties = new HashSet<Environment.Variable>();
private Set<ParameterType> parameters = new HashSet<ParameterType>();
+ private JBossUnitTask jbossUnitTask;
-
public TestsType()
{
}
@@ -95,7 +94,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ throw new BuildException("Testsuite executed with test failures");
}
}
@@ -110,6 +109,9 @@
addArguments(javaBuilder);
+ // Update settings using environment variables
+ javaBuilder.applyVariables(getProject().getProperties());
+
javaTask = javaBuilder.buildJava();
// Apply task classpath
@@ -135,17 +137,33 @@
return javaTask;
}
-
+ /**
+ * Set all needed settings on JavaBuilder object based on passed configuration
+ * @param javaBuilder
+ */
private void addArguments(JavaBuilder javaBuilder)
{
javaBuilder.setConfig(config);
- if (isJpda())
- {
- javaBuilder.setJPDA(true);
- }
+ // JPDA
+ javaBuilder.setJPDA(jbossUnitTask.isJpda());
+ javaBuilder.setJPDAport(Integer.decode(jbossUnitTask.getJpdaPort()));
+ javaBuilder.setSuspend(jbossUnitTask.isJpdaSuspend());
+ // JUL
+ javaBuilder.setUseJUL(jbossUnitTask.isUseJUL());
+
+ // Assertions
+ javaBuilder.setAssertions(jbossUnitTask.isAssertions());
+
+ // Fork
+ javaBuilder.setFork(isFork());
+
+ // Fail on Error
+ javaBuilder.setFailOnError(jbossUnitTask.isFailOnError());
+
+
if (getSuiteName() != null)
{
javaBuilder.setSuiteName(getSuiteName());
@@ -309,7 +327,6 @@
this.fork = fork;
}
-
public Project getProject()
{
return project;
@@ -320,7 +337,6 @@
this.project = project;
}
-
public ReportsType getReports()
{
return reports;
@@ -341,13 +357,13 @@
this.suiteName = suiteName;
}
- public boolean isJpda()
+ public JBossUnitTask getParent()
{
- return jpda;
+ return jbossUnitTask;
}
- public void setJpda(boolean jpda)
+ public void setParent(JBossUnitTask jbossUnitTask)
{
- this.jpda = jpda;
+ this.jbossUnitTask = jbossUnitTask;
}
}
Modified: modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/JavaBuilder.java
===================================================================
--- modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/JavaBuilder.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/JavaBuilder.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -38,6 +38,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
+import java.util.Arrays;
import static org.jboss.unit.tooling.ToolingConstants.*;
@@ -48,6 +49,8 @@
public class JavaBuilder
{
+ private final static String JBOSS_UNIT_CLASSNAME = "org.jboss.unit.tooling.Main";
+
private Project antProject;
private String config;
@@ -64,8 +67,18 @@
private boolean jPDA = false;
+ private boolean suspend = true;
+
+ private int jPDAport = 9000;
+
+ private boolean useJUL = true;
+
private boolean fork = true;
+ private boolean assertions = true;
+
+ private boolean failOnError = false;
+
private String xmlReportDir;
private String htmlReportDir;
@@ -94,38 +107,54 @@
}
}
+
+
public Java buildJava()
{
Java java = (Java)antProject.createTask("java");
- java.setClassname("org.jboss.unit.tooling.Main");
+ java.setClassname(JBOSS_UNIT_CLASSNAME);
- // Set jboss logging to use JUL
- Environment.Variable pluginProperty = new Environment.Variable();
- pluginProperty.setKey("org.jboss.logging.Logger.pluginClass");
- pluginProperty.setValue("org.jboss.logging.jdk.JDK14LoggerPlugin");
- java.addSysproperty(pluginProperty);
+ if (isUseJUL())
+ {
+ // Set jboss logging to use JUL
+ Environment.Variable pluginProperty = new Environment.Variable();
+ pluginProperty.setKey("org.jboss.logging.Logger.pluginClass");
+ pluginProperty.setValue("org.jboss.logging.jdk.JDK14LoggerPlugin");
+ java.addSysproperty(pluginProperty);
- // Set JUL to configure using the logging.properties file found in the current dir
- Environment.Variable julProperty = new Environment.Variable();
- julProperty.setKey("java.util.logging.config.file");
- julProperty.setValue("logging.properties");
- java.addSysproperty(julProperty);
+ // Set JUL to configure using the logging.properties file found in the current dir
+ Environment.Variable julProperty = new Environment.Variable();
+ julProperty.setKey("java.util.logging.config.file");
+ julProperty.setValue("logging.properties");
+ java.addSysproperty(julProperty);
+ }
- // We enable by default all assertions : todo make it configurable perhaps (see JDK doc about assertions)
- Assertions assertions = new Assertions();
- assertions.setProject(antProject);
- assertions.addEnable(new Assertions.EnabledAssertion());
- java.addAssertions(assertions);
+ if (isAssertions())
+ {
+ // We enable by default all assertions : todo make it configurable perhaps (see JDK doc about assertions)
+ Assertions assertions = new Assertions();
+ assertions.setProject(antProject);
+ assertions.addEnable(new Assertions.EnabledAssertion());
+ java.addAssertions(assertions);
+ }
+
// Beginning of jpda option implementation, need to improve it
- if (jPDA)
+ // Now the only configurable is port and suspend mode
+ if (isJPDA())
{
Environment.Variable javaDotCompilerProperty = new Environment.Variable();
javaDotCompilerProperty.setKey("java.compiler");
javaDotCompilerProperty.setValue("NONE");
java.addSysproperty(javaDotCompilerProperty);
- java.setJvmargs("-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9000");
+ StringBuilder jvmArgs = new StringBuilder();
+
+ jvmArgs.append("-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y")
+ .append(",address=").append(jPDAport)
+ .append(",suspend=").append(suspend ? "y" : "n");
+
+ java.setJvmargs(jvmArgs.toString());
}
// Set fork
@@ -134,7 +163,16 @@
java.setFork(true);
}
+ // If the build should fail on error
+ if (isFailOnError()){
+ java.setFailonerror(isFailOnError());
+ java.createArg().setValue(OPT_FAIL_ON_ERROR);
+
+ }
+
+
+
java.createArg().setValue(OPT_CONFIG + "=" + config);
if (getSuiteName() != null)
@@ -249,8 +287,66 @@
return java;
}
+ /**
+ * Uodate options using variables stored in Map
+ * @param variables
+ */
+ public void applyVariables(Map variables)
+ {
+ String jpda = (String)variables.get(JBOSS_UNIT_JPDA);
+ String jpdaport = (String)variables.get(JBOSS_UNIT_JPDA_PORT);
+ String jpdasuspend = (String)variables.get(JBOSS_UNIT_JPDA_SUSPEND);
+ String jul = (String)System.getProperties().get(JBOSS_UNIT_LOGGING);
+ String assertions = (String)System.getProperties().get(JBOSS_UNIT_ASSERTIONS);
+ String failonerror = (String)System.getProperties().get(JBOSS_UNIT_FAIL_ON_ERROR);
+ String forcedIncludes = (String)System.getProperties().get(JBOSS_UNIT_TESTS);
+ // JPDA
+ if (jpda != null && jpda.length() != 0)
+ {
+ setJPDA(jpda.equalsIgnoreCase("true"));
+ }
+ if (jpdaport != null && jpdaport.length() != 0)
+ {
+ setJPDAport(Integer.decode(jpdaport));
+ }
+ if (jpdasuspend != null && jpdasuspend.length() != 0)
+ {
+ setSuspend(jpdasuspend.equalsIgnoreCase("true"));
+ }
+
+ // JUL
+ if (jul != null && jul.length() != 0)
+ {
+ if (jul.equalsIgnoreCase("JUL"))
+ {
+ setUseJUL(true);
+ }
+ }
+
+ // Assertions
+ if (assertions != null && assertions.length() != 0)
+ {
+ setAssertions(assertions.equalsIgnoreCase("true"));
+ }
+
+ // Fail on error
+ if (failonerror != null && failonerror.length() != 0)
+ {
+ setFailOnError(failonerror.equalsIgnoreCase("true"));
+ }
+
+ if (forcedIncludes != null && forcedIncludes.length() != 0)
+ {
+ Set<String> includes = new HashSet<String>();
+ String[] ids = forcedIncludes.split(",");
+ includes.addAll(Arrays.asList(ids));
+ setIncludeIDs(includes);
+ }
+ }
+
+
public String getConfig()
{
return config;
@@ -420,11 +516,61 @@
this.excludeKeywords = excludeKeywords;
}
+ public boolean isUseJUL()
+ {
+ return useJUL;
+ }
+
+ public void setUseJUL(boolean useJUL)
+ {
+ this.useJUL = useJUL;
+ }
+
public boolean isJPDA()
{
return jPDA;
}
+ public boolean isFailOnError()
+ {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError)
+ {
+ this.failOnError = failOnError;
+ }
+
+ public boolean isSuspend()
+ {
+ return suspend;
+ }
+
+ public void setSuspend(boolean suspend)
+ {
+ this.suspend = suspend;
+ }
+
+ public int getJPDAport()
+ {
+ return jPDAport;
+ }
+
+ public void setJPDAport(int jPDAport)
+ {
+ this.jPDAport = jPDAport;
+ }
+
+ public boolean isAssertions()
+ {
+ return assertions;
+ }
+
+ public void setAssertions(boolean assertions)
+ {
+ this.assertions = assertions;
+ }
+
public void setJPDA(boolean jPDA)
{
this.jPDA = jPDA;
@@ -454,6 +600,7 @@
}
+
public String getXmlReportDir()
{
return xmlReportDir;
@@ -701,6 +848,8 @@
}
}
+
+
private Map<String, List<String>> parseParameters(String parametersString)
{
@@ -744,7 +893,6 @@
return parsedParams;
-
}
private String generateArgument(Set<String> values, String argumentName)
Added: modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/TestFailedException.java
===================================================================
--- modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/TestFailedException.java (rev 0)
+++ modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/TestFailedException.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -0,0 +1,36 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class TestFailedException extends Exception
+{
+ public TestFailedException(String message)
+ {
+ super(message);
+ }
+
+}
Modified: modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/ToolingConstants.java
===================================================================
--- modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/ToolingConstants.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/core/src/main/java/org/jboss/unit/tooling/ToolingConstants.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -35,8 +35,24 @@
public static final String JBOSS_UNIT_PARAMETER = "jboss.unit.parameter";
- public static final String JBOSS_UNIT_PARAMETERS = "jboss.unit.parameters";
+ public static final String JBOSS_UNIT_PARAMETERS = "jboss.unit.parameters";
+ public static final String JBOSS_UNIT_TESTS = "jboss.unit.tests";
+
+ public static final String JBOSS_UNIT_LOGGING = "jboss.unit.logging";
+
+ public static final String JBOSS_UNIT_JPDA = "jboss.unit.jpda";
+
+ public static final String JBOSS_UNIT_JPDA_PORT = "jboss.unit.jpda.port";
+
+ public static final String JBOSS_UNIT_JPDA_SUSPEND = "jboss.unit.jpda.suspend";
+
+ public static final String JBOSS_UNIT_ASSERTIONS = "jboss.unit.assertions";
+
+ public static final String JBOSS_UNIT_FAIL_ON_ERROR = "jboss.unit.failonerror";
+
+ public static final String OPT_FAIL_ON_ERROR = "--failonerror";
+
public static final String OPT_ID = "--id";
public static final String OPT_IDS = "--ids";
Modified: modules/test/trunk/tooling/examples/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/examples/maven2/pom.xml 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/examples/maven2/pom.xml 2008-01-22 11:39:19 UTC (rev 9549)
@@ -11,6 +11,7 @@
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
@@ -38,6 +39,7 @@
<plugin>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<phase>test</phase>
@@ -47,6 +49,11 @@
</execution>
</executions>
<configuration>
+
+ <jpda>true</jpda>
+ <!--<jpdaPort>9000</jpdaPort>
+ <jpdaSuspend>true</jpdaSuspend>-->
+
<testsuites>
<testsuite>
<config>jboss-unit.xml</config>
@@ -107,4 +114,4 @@
<properties>
</properties>
-</project>
\ No newline at end of file
+</project>
Modified: modules/test/trunk/tooling/examples/maven2/src/test/java/org/jboss/test/unit/tooling/TestSimple.java
===================================================================
--- modules/test/trunk/tooling/examples/maven2/src/test/java/org/jboss/test/unit/tooling/TestSimple.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/examples/maven2/src/test/java/org/jboss/test/unit/tooling/TestSimple.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -41,6 +41,12 @@
@Test
public void testTwo()
{
+ Assert.assertFalse(true);
+ }
+
+ @Test
+ public void testThree()
+ {
Assert.assertFalse(false);
}
Modified: modules/test/trunk/tooling/maven2/pom.xml
===================================================================
--- modules/test/trunk/tooling/maven2/pom.xml 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/maven2/pom.xml 2008-01-22 11:39:19 UTC (rev 9549)
@@ -41,8 +41,8 @@
<artifactId>jboss-unit</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit-tooling-core</artifactId>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-tooling-core</artifactId>
</dependency>
</dependencies>
Modified: modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/TestSuiteExecutor.java
===================================================================
--- modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/TestSuiteExecutor.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/TestSuiteExecutor.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -22,15 +22,14 @@
package org.jboss.unit.tooling.maven2;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.jboss.unit.tooling.JavaBuilder;
import org.jboss.unit.tooling.TaskExecutingThread;
+import org.jboss.unit.tooling.TestFailedException;
import org.jboss.unit.tooling.maven2.configuration.CasesDescription;
import org.jboss.unit.tooling.maven2.configuration.Parameter;
import org.jboss.unit.tooling.maven2.configuration.Reports;
@@ -41,8 +40,6 @@
import java.io.FileReader;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
-import java.util.Set;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
@@ -52,55 +49,71 @@
{
private final MavenProject project;
- private final Reports reports;
-
private final Testsuite testsuite;
+ private final UnitMojo unitMojo;
+
private TestSuiteExecutor()
{
project = null;
- reports = null;
testsuite = null;
+ unitMojo = null;
}
- public TestSuiteExecutor(MavenProject project, Reports reports, Testsuite testsuite)
+ public TestSuiteExecutor(MavenProject project, Testsuite testsuite, UnitMojo unitMojo)
{
this.project = project;
- this.reports = reports;
this.testsuite = testsuite;
+ this.unitMojo = unitMojo;
}
- public void execute()
+ public void execute() throws Exception
{
+
+ // Prepare all settings for java invocation
+
Java javaTask = createJavaTask();
- System.out.println("Executing very first....");
+ System.out.println("Invoking java: " + javaTask.getCommandLine().toString());
- try
- {
- System.out.println("Invoking java: " + javaTask.getCommandLine().toString());
+ // This is really stupid workaround to the fact that maven eats whole output of invoked java task.
+ // Should be investigated and fixed in more proper way ...
- // This is really stupid workaround to the fact that maven eats whole output of invoked java task.
- // Should be investigated and fixed in more proper way ...
+ //javaTask.setFork(true);
- javaTask.setFork(true);
+ File log = null;
- File log = File.createTempFile("jboss-unit-" + System.currentTimeMillis(), "log");
+ javaTask.setAppend(true);
+ javaTask.setLogError(true);
+
+
+
+ try
+ {
+ log = File.createTempFile("jboss-unit-" + System.currentTimeMillis(), "log");
+
javaTask.setOutput(log);
javaTask.setError(log);
- javaTask.setAppend(true);
- javaTask.setLogError(true);
-
// Execution of jboss-unit
TaskExecutingThread executor = new TaskExecutingThread(javaTask);
executor.run();
+
+
+ }
+ catch (Exception e)
+ {
+ throw new TestFailedException("Testsuite executed with test failures");
+ }
+ finally
+ {
// Print the collected output
+
BufferedReader br = new BufferedReader(new FileReader(log));
String line = null;
while (( line = br.readLine()) != null){
@@ -110,12 +123,12 @@
// Cleanup
log.delete();
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
+ /**
+ * Creates ant Java object with all proper settings
+ * @return
+ */
private Java createJavaTask()
{
Java javaTask = null;
@@ -124,58 +137,23 @@
JavaBuilder javaBuilder = new JavaBuilder();
+ // Apply all settings for Java object creation
addArguments(javaBuilder);
+ // Update settings using environment variables
+ javaBuilder.applyVariables(System.getProperties());
+
+ // Create Java object
javaTask = javaBuilder.buildJava();
+ // Apply proper classpath taken from maven project
Path path = javaTask.createClasspath();
- // Apply task classpath
-
-// System.out.println("Creating classpath: ");
-
-// for (Artifact artifact : (Collection<Artifact>)project.getCompileArtifacts())
-// {
-// System.out.println("Compile Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId());
-// path.createPathElement().setLocation(artifact.getFile());
-// }
-//
-// for (Artifact artifact : (Collection<Artifact>)project.getTestArtifacts())
-// {
-//// System.out.println("Test Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId());
-// path.createPathElement().setLocation(artifact.getFile());
-// }
-//
-// for (Artifact artifact : (Collection<Artifact>)project.getRuntimeArtifacts())
-// {
-//// System.out.println("Runtime Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId());
-// path.createPathElement().setLocation(artifact.getFile());
-// }
-//
-// for (Artifact artifact : (Collection<Artifact>)project.getSystemArtifacts())
-// {
-//// System.out.println("System Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId());
-// path.createPathElement().setLocation(artifact.getFile());
-// }
-//
-// for (Artifact artifact : (Collection<Artifact>)project.getDependencyArtifacts())
-// {
-//// System.out.println("Dependency Artifact: " + artifact.getGroupId() + ":" + artifact.getArtifactId());
-// path.createPathElement().setLocation(artifact.getFile());
-// }
-//
-// for (Resource resource : (Collection<Resource>)project.getTestResources())
-// {
-//// System.out.println("Test Resource: " + resource.getDirectory());
-// path.createPathElement().setLocation(new File(resource.getDirectory()));
-// }
-
try
{
for (String element : (Collection<String>)project.getTestClasspathElements())
{
-// System.out.println("TestClasspathElement: " + element);
path.createPathElement().setLocation(new File(element));
}
}
@@ -197,10 +175,7 @@
{
javaBuilder.setConfig(testsuite.getConfig());
-// if (getSuiteName() != null)
-// {
-// javaBuilder.setSuiteName(getSuiteName());
-// }
+ Reports reports = testsuite.getReports();
if (reports != null && reports.getXml() != null)
{
@@ -212,18 +187,48 @@
javaBuilder.setHtmlReportDir(reports.getHtml());
}
- javaBuilder.setJPDA(testsuite.isJPDA());
+ // JPDA properties
- for (CasesDescription include : testsuite.getIncludes())
+
+ // JPDA
+ if (unitMojo.isJpda())
{
- //Check attributes consistency
+ javaBuilder.setJPDA(true);
+ }
-// if (include.getId() != null && (include.getIds() != null || include.getKeywords() != null))
-// {
-// throw new IllegalStateException("The use of <id> in <include> tag should be exclusive");
-// }
+ // JPDA port
+ if (unitMojo.getJpdaPort() != null)
+ {
+ javaBuilder.setJPDAport(Integer.decode(unitMojo.getJpdaPort()));
+ }
+ // JPDA suspend
+ javaBuilder.setSuspend(Boolean.parseBoolean(unitMojo.getJpdaSuspend()));
+ // JUL
+
+ javaBuilder.setUseJUL(unitMojo.isUseJUL());
+
+ // Assertions
+
+ javaBuilder.setAssertions(unitMojo.isAssertions());
+
+
+ // Fail on error
+
+
+ javaBuilder.setFailOnError(unitMojo.isFailOnError());
+
+
+ // Fork
+ javaBuilder.setFork(unitMojo.isFork());
+
+
+ // Check if IDs to execute are not forced from the command line
+
+ for (CasesDescription include : testsuite.getIncludes())
+ {
+
if (include.getIds() != null)
{
for (String id : include.getIds())
@@ -239,20 +244,11 @@
javaBuilder.addIncludeKeyword(keyword);
}
}
-// if (include.getId() != null)
-// {
-// javaBuilder.addIncludeID(include.getId());
-// }
}
for (CasesDescription exclude : testsuite.getExcludes())
{
-// if (exclude.getId() != null && (exclude.getIds() != null || exclude.getKeywords() != null))
-// {
-// throw new IllegalStateException("The use of <id> in <exclude> tag should be exclusive");
-// }
-
if (exclude.getIds() != null)
{
for (String id : exclude.getIds())
@@ -268,14 +264,10 @@
javaBuilder.addExcludeKeyword(keyword);
}
}
-// if (exclude.getId() != null)
-// {
-// javaBuilder.addIncludeID(exclude.getId());
-// }
}
- // Properties
+ // Properties
if (testsuite.getProperties().size() > 0)
{
@@ -284,7 +276,7 @@
javaBuilder.addProperty(propertyName.toString(),testsuite.getProperties().get(propertyName).toString());
}
- javaBuilder.updateFQNProperties(project.getProperties());
+ javaBuilder.updateFQNProperties(System.getProperties());
}
@@ -296,8 +288,7 @@
javaBuilder.addParameter(parameter.getName(), Arrays.asList(parameter.getValues()));
}
- javaBuilder.updateFQNParameters(project.getProperties());
+ javaBuilder.updateFQNParameters(System.getProperties());
-
}
}
Modified: modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java
===================================================================
--- modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/UnitMojo.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -22,7 +22,6 @@
package org.jboss.unit.tooling.maven2;
-import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -36,6 +35,9 @@
*/
public class UnitMojo extends AbstractMojo
{
+
+ public static final String MAVEN_SKIP_TEST = "maven.skip.test";
+
/**
* @parameter
*/
@@ -47,6 +49,41 @@
private Reports reports;
/**
+ * @parameter
+ */
+ private boolean jpda;
+
+ /**
+ * @parameter
+ */
+ private String jpdaPort;
+
+ /**
+ * @parameter
+ */
+ private String jpdaSuspend;
+
+ /** s
+ * @parameter
+ */
+ private boolean useJUL = true;
+
+ /**
+ * @parameter
+ */
+ private boolean fork = true;
+
+ /**
+ * @parameter
+ */
+ private boolean assertions = true;
+
+ /**
+ * @parameter
+ */
+ private boolean failOnError = false;
+
+ /**
* The Maven project object
*
* @parameter expression="${project}"
@@ -58,15 +95,97 @@
throws MojoExecutionException
{
+ String testSkip = (String)System.getProperties().get(MAVEN_SKIP_TEST);
+
+ // Skip tests
+ if (testSkip != null && testSkip.equalsIgnoreCase("true"))
+ {
+ //TODO: make it logging
+
+ System.out.println("Skipping test execution: " + MAVEN_SKIP_TEST + " set to true");
+
+ return;
+ }
+
//Invoke all configured testsuites
for (Testsuite testsuite : testsuites)
{
- TestSuiteExecutor executor = new TestSuiteExecutor(project, reports, testsuite);
- executor.execute();
+ // Propagate global reports settings if needed
+ if (testsuite.getReports() == null && reports != null)
+ {
+ testsuite.setReports(reports);
+ }
+
+ TestSuiteExecutor executor = new TestSuiteExecutor(project, testsuite, this);
+ try
+ {
+ executor.execute();
+ }
+ catch (Exception e)
+ {
+ throw new MojoExecutionException("Build failed",e);
+ }
}
}
+ public boolean isJpda()
+ {
+ return jpda;
+ }
+
+ public String getJpdaPort()
+ {
+ return jpdaPort;
+ }
+
+ public String getJpdaSuspend()
+ {
+ return jpdaSuspend;
+ }
+
+ public boolean isUseJUL()
+ {
+ return useJUL;
+ }
+
+ public void setUseJUL(boolean useJUL)
+ {
+ this.useJUL = useJUL;
+ }
+
+ public boolean isFork()
+ {
+ return fork;
+ }
+
+ public void setFork(boolean fork)
+ {
+ this.fork = fork;
+ }
+
+ public boolean isAssertions()
+ {
+ return assertions;
+ }
+
+ public void setAssertions(boolean assertions)
+ {
+ this.assertions = assertions;
+ }
+
+ public boolean isFailOnError()
+ {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError)
+ {
+ this.failOnError = failOnError;
+ }
+
+
+
}
Modified: modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java
===================================================================
--- modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/tooling/maven2/src/main/java/org/jboss/unit/tooling/maven2/configuration/Testsuite.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -59,7 +59,7 @@
/**
* @parameter
*/
- boolean jPDA = false;
+ private Reports reports;
public String getConfig()
{
@@ -91,8 +91,13 @@
return parameters;
}
- public boolean isJPDA()
+ public Reports getReports()
{
- return jPDA;
+ return reports;
}
+
+ public void setReports(Reports reports)
+ {
+ this.reports = reports;
+ }
}
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/report/impl/writer/PrintListener.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/report/impl/writer/PrintListener.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/report/impl/writer/PrintListener.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -156,17 +156,26 @@
SuiteStat stat = stack.removeLast();
StringBuffer sb = new StringBuffer("Testsuite: ");
+
sb.append(tmp);
sb.append(NEW_LINE);
- sb.append("Tests run: ");
- sb.append(stat.count);
- sb.append(", Failures: ");
- sb.append(stat.failures);
- sb.append(", Errors: ");
- sb.append(stat.errors);
- sb.append(", Time elapsed: ");
- sb.append(FORMAT.format((System.currentTimeMillis() - stat.timestamp) / 1000.0));
- sb.append(" sec");
+
+ if (stat.count > 0)
+ {
+ sb.append("Tests run: ");
+ sb.append(stat.count);
+ sb.append(", Failures: ");
+ sb.append(stat.failures);
+ sb.append(", Errors: ");
+ sb.append(stat.errors);
+ sb.append(", Time elapsed: ");
+ sb.append(FORMAT.format((System.currentTimeMillis() - stat.timestamp) / 1000.0));
+ sb.append(" sec");
+ }
+ else
+ {
+ sb.append("Testcase skipped...");
+ }
sb.append(NEW_LINE);
sb.append(NEW_LINE);
out.print(sb);
Added: modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/FailureManagerListener.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/FailureManagerListener.java (rev 0)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/FailureManagerListener.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -0,0 +1,81 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling;
+
+import org.jboss.unit.runner.TestResult;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.results.TestFailure;
+import org.jboss.unit.runner.event.EndTestCaseEvent;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+
+/**
+ * Event Listener that manages runner failures.
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class FailureManagerListener implements TestRunnerEventListener
+{
+ private boolean runnerFailure = false;
+
+ private boolean testCaseFailure = false;
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ if (event instanceof RunnerFailureEvent)
+ {
+ // Return with code -1
+ //System.exit(-1);
+ runnerFailure = true;
+ }
+ if (event instanceof EndTestCaseEvent)
+ {
+ EndTestCaseEvent endEvent = (EndTestCaseEvent)event;
+ TestResult result = endEvent.getTestResult();
+
+ if (result instanceof TestFailure)
+ {
+ // Return with code -1
+ //System.exit(-1);
+ testCaseFailure = true;
+ }
+ }
+ }
+
+ public void reset()
+ {
+ runnerFailure = false;
+ testCaseFailure = false;
+ }
+
+ public boolean isRunnerFailure()
+ {
+ return runnerFailure;
+ }
+
+ public boolean isTestCaseFailure()
+ {
+ return testCaseFailure;
+ }
+}
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/Main.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/Main.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/Main.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -56,14 +56,18 @@
private final TestRunnerEventBroadcaster broadcaster;
+ private final boolean failonerror;
+
public static final String JBOSS_UNIT_PROPERTIES = "jboss.unit.properties";
public static final String JBOSS_UNIT_PROPERTY = "jboss.unit.property";
public static final String JBOSS_UNIT_PARAMETER = "jboss.unit.parameter";
- public static final String JBOSS_UNIT_PARAMETERS = "jboss.unit.parameters";
+ public static final String JBOSS_UNIT_PARAMETERS = "jboss.unit.parameters";
+ public static final String OPT_FAIL_ON_ERROR = "--failonerror";
+
public static final String OPT_ID = "--id";
public static final String OPT_IDS = "--ids";
@@ -117,15 +121,17 @@
opts.add(OPT_XML_REPORT_DIR);
opts.add(OPT_HTML_REPORT_DIR);
opts.add(OPT_PROPERTY);
+ opts.add(OPT_FAIL_ON_ERROR);
options = Collections.unmodifiableSet(opts);
opts = new HashSet<String>();
opts.add(OPT_NO_CONSOLE);
+ opts.add(OPT_FAIL_ON_ERROR);
options_no_arg = Collections.unmodifiableSet(opts);
}
- public Main(TestRunner runner, MainTestFilter mainFilter, TestRunnerEventBroadcaster broadcaster, TestSuiteDef suiteDef, Map<String,String> properties, Map<String, String[]> parameters)
+ public Main(TestRunner runner, MainTestFilter mainFilter, TestRunnerEventBroadcaster broadcaster, TestSuiteDef suiteDef, Map<String,String> properties, Map<String, String[]> parameters, boolean failonerror)
{
if (runner == null)
{
@@ -163,6 +169,7 @@
this.properties = properties;
this.broadcaster = broadcaster;
this.parameters = parameters;
+ this.failonerror = failonerror;
}
public void execute() throws Exception
@@ -170,6 +177,8 @@
SystemOutputManager systemManager = new SystemOutputManager();
systemManager.start();
+ FailureManagerListener failureListener = new FailureManagerListener();
+
//
try
{
@@ -187,16 +196,30 @@
StringWriter sw = new StringWriter();
broadcaster.addListener(new PrintListener(sw));
+
+
+ // Track runner and test case failures;
+ broadcaster.addListener(failureListener);
+
TestRunnerContextSupport runnerContext = new TestRunnerContextSupport(properties, new ParametrizationSet(parameters), mainFilter, broadcaster);
runner.run(runnerContext);
sw.close();
System.out.println(sw.toString());
+
+
+
+
}
finally
{
systemManager.stop();
+
+ if (failonerror && (failureListener.isRunnerFailure() || failureListener.isTestCaseFailure()))
+ {
+ System.exit(-1);
+ }
}
}
@@ -208,11 +231,20 @@
for (String arg : args)
{
String[] params = arg.split("=",2);
- if (params.length < 2 && !options_no_arg.contains(params[0]))
+
+ if (!options_no_arg.contains(params[0]))
{
- throw new IllegalArgumentException("Argument '" + arg + "' doesn't follow the name=value pattern");
+ if (params.length < 2)
+ {
+ throw new IllegalArgumentException("Argument '" + arg + "' doesn't follow the name=value pattern");
+ }
+
+ arguments.put(params[0], params[1]);
}
- arguments.put(params[0], params[1]);
+ else
+ {
+ arguments.put(params[0], null);
+ }
}
if (!arguments.keySet().contains(OPT_CONFIG))
@@ -274,6 +306,11 @@
builder.setNoConsole(true);
}
+ if (argument.equals(OPT_FAIL_ON_ERROR))
+ {
+ builder.setFailonerror(true);
+ }
+
if (argument.equals(OPT_XML_REPORT_DIR))
{
builder.setXMLReportDir(arguments.get(OPT_XML_REPORT_DIR));
Modified: modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/MainBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/MainBuilder.java 2008-01-21 21:32:53 UTC (rev 9548)
+++ modules/test/trunk/unit/src/main/java/org/jboss/unit/tooling/MainBuilder.java 2008-01-22 11:39:19 UTC (rev 9549)
@@ -73,6 +73,8 @@
private boolean noConsole = false;
+ private boolean failonerror = false;
+
private String xmlReportDir;
private String htmlReportDir;
@@ -469,6 +471,16 @@
this.noConsole = noConsole;
}
+ public boolean isFailonerror()
+ {
+ return failonerror;
+ }
+
+ public void setFailonerror(boolean failonerror)
+ {
+ this.failonerror = failonerror;
+ }
+
public void setXMLReportDir(String xmlReportDir)
{
this.xmlReportDir = xmlReportDir;
@@ -551,7 +563,7 @@
filter.addExcludeFilter(new ExcludeTestFilter(excludeKeywords, excludeNames, excludeNamePatterns));
}
- return new Main(runner, filter, broadcaster, suite, properties, getParameters());
+ return new Main(runner, filter, broadcaster, suite, properties, getParameters(), isFailonerror());
}
public static File checkCreateOutputDirectory(String dir) throws Exception
18 years, 3 months
JBoss Portal SVN: r9548 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet and 11 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-21 16:32:53 -0500 (Mon, 21 Jan 2008)
New Revision: 9548
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java
Log:
start to implement resource serving
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum Cacheability
+{
+
+ FULL, PORTLET, PAGE
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ContainerURL
+{
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -31,25 +31,26 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5448 $
*/
-public interface PortletURL
+public interface PortletURL extends ContainerURL
{
/**
- * The mode that may be null.
+ * Returns the mode that may be null.
*
* @return the mode
*/
Mode getMode();
/**
- * The window state that may be null.
+ * Returns the window state that may be null.
*
* @return the window state
*/
WindowState getWindowState();
/**
- *
- * @return
+ * Returns the public navigational state changes.
+ *
+ * @return the public navigational state changes
*/
Map<String, String[]> getPublicNavigationalStateChanges();
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ResourceURL extends ContainerURL
+{
+
+ String getId();
+
+ /**
+ * Return the resource state.
+ *
+ * @return the resource state
+ */
+ StateString getResourceState();
+
+ /**
+ * Returs the resource cacheability.
+ *
+ * @return the resource cacheability
+ */
+ Cacheability getCacheability();
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -48,7 +48,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
{
- if ((invocation.getPortletContext()).getMode() == null)
+ if ((invocation.getContext()).getMode() == null)
{
throw new InvocationException("No mode has been provided");
}
@@ -67,7 +67,7 @@
protected Set<Mode> getModes(PortletInvocation invocation)
{
// Get content type
- ContentInfo si = invocation.getPortletContext().getMarkupInfo();
+ ContentInfo si = invocation.getContext().getMarkupInfo();
String contentType = si.getContentType().toString();
// Get the modes for this content type
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -41,7 +41,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
{
- if (invocation.getPortletContext().getWindowState() == null)
+ if (invocation.getContext().getWindowState() == null)
{
throw new InvocationException("No window state has been provided");
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -68,24 +68,6 @@
this(new ParameterMap());
}
- public void encode(PortletURL portletURL) throws IllegalArgumentException
- {
- if (portletURL instanceof RenderURL)
- {
- RenderURL renderURL = (RenderURL)portletURL;
- encodeRender(renderURL.getNavigationalState(), renderURL.getMode(), renderURL.getWindowState());
- }
- else if (portletURL instanceof ActionURL)
- {
- ActionURL actionURL = (ActionURL)portletURL;
- encodeAction(actionURL.getNavigationalState(), actionURL.getInteractionState(), actionURL.getMode(), actionURL.getWindowState());
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
-
public void encodeAction(
StateString navigationalState,
StateString interactionState,
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -25,12 +25,15 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
/**
@@ -68,4 +71,14 @@
{
return new RenderResponseImpl(invocation, renderRequest);
}
+
+ public ResourceRequestImpl createResourceRequest(ResourceInvocation invocation)
+ {
+ return new ResourceRequestImpl(invocation);
+ }
+
+ public ResourceResponseImpl createResourceResponse(ResourceInvocation invocation, ResourceRequestImpl renderRequest)
+ {
+ return new ResourceResponseImpl(invocation, renderRequest);
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
@@ -44,6 +46,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.SecurityErrorResponse;
@@ -57,6 +60,7 @@
import javax.portlet.PreferencesValidator;
import javax.portlet.UnavailableException;
import javax.portlet.EventPortlet;
+import javax.portlet.ResourceServingPortlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Set;
@@ -401,16 +405,16 @@
protected PortletInvocationResponse invokeAction(ActionInvocation invocation) throws IOException, PortletException
{
PortletAPIFactory factory = application.getPortletAPIFactory();
- ActionRequestImpl areq = factory.createActionRequest(invocation);
- ActionResponseImpl aresp = factory.createActionResponse(invocation, areq);
+ ActionRequestImpl req = factory.createActionRequest(invocation);
+ ActionResponseImpl resp = factory.createActionResponse(invocation, req);
HttpServletRequest dreq = invocation.getDispatchedRequest();
try
{
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, areq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, aresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- portlet.processAction(areq, aresp);
+ portlet.processAction(req, resp);
}
finally
{
@@ -420,22 +424,22 @@
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
- return aresp.getResponse();
+ return resp.getResponse();
}
protected PortletInvocationResponse invokeRender(RenderInvocation invocation) throws IOException, PortletException
{
PortletAPIFactory factory = application.getPortletAPIFactory();
- RenderRequestImpl rreq = factory.createRenderRequest(invocation);
- RenderResponseImpl rresp = factory.createRenderResponse(invocation, rreq);
+ RenderRequestImpl req = factory.createRenderRequest(invocation);
+ RenderResponseImpl resp = factory.createRenderResponse(invocation, req);
HttpServletRequest dreq = invocation.getDispatchedRequest();
try
{
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, rreq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, rresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
- portlet.render(rreq, rresp);
+ portlet.render(req, resp);
}
finally
{
@@ -444,12 +448,12 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
- return rresp.getResult();
+ return resp.getResponse();
}
protected PortletInvocationResponse invokeEvent(EventInvocation invocation) throws IOException, PortletException
{
- // Todo something clever
+ // Todo something clever if CCE occues
EventPortlet eventPortlet = (EventPortlet)portlet;
//
@@ -474,4 +478,34 @@
}
return eresp.getResponse();
}
+
+ protected PortletInvocationResponse invokeResource(ResourceInvocation invocation) throws IOException, PortletException
+ {
+ // Todo something clever if CCE occues
+ ResourceServingPortlet eventPortlet = (ResourceServingPortlet)portlet;
+
+ //
+ PortletAPIFactory factory = application.getPortletAPIFactory();
+ ResourceRequestImpl req = factory.createResourceRequest(invocation);
+ ResourceResponseImpl resp = factory.createResourceResponse(invocation, req);
+ HttpServletRequest dreq = invocation.getDispatchedRequest();
+ try
+ {
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
+ eventPortlet.serveResource(req, resp);
+ }
+ finally
+ {
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
+ }
+
+ //
+ return resp.getResponse();
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,14 +23,16 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.spi.ActionContext;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.info.NavigationInfo;
import java.util.Iterator;
-import java.util.Map;
/**
* The main responsibility of this class is to combine the different parameter sources (private navigational state,
@@ -42,8 +44,89 @@
public class PortletRequestParameterMap
{
- private static final ParameterMap.AccessMode COPY_MODE = ParameterMap.AccessMode.get(true, true);
+ /** . */
+ protected static final ParameterMap.AccessMode COPY_MODE = ParameterMap.AccessMode.get(true, true);
+ /**
+ * Factory method that will chose the right builder according to the context argument type.
+ */
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo, PortletInvocationContext context)
+ {
+ if (context instanceof EventContext)
+ {
+ return create(navigationInfo, (EventContext)context);
+ }
+ else if (context instanceof ActionContext)
+ {
+ return create(navigationInfo, (ActionContext)context);
+ }
+ else if (context instanceof RenderContext)
+ {
+ return create(navigationInfo, (RenderContext)context);
+ }
+ else
+ {
+ return ResourceRequestParameterMap.create(navigationInfo, (ResourceInvocationContext)context);
+ }
+ }
+
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo, EventContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo, context.getPublicNavigationalState());
+
+ // Get render parameters
+ ParameterMap privateParameters = safeBuildParameters(context.getNavigationalState());
+
+ // Build combined map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters, publicParameters);
+ }
+
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo, RenderContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo, context.getPublicNavigationalState());
+
+ // Get render parameters
+ ParameterMap privateParameters = safeBuildParameters(context.getNavigationalState());
+
+ // Build combined map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters, publicParameters);
+ }
+
+ /**
+ * - interaction parameter : always
+ * - form parameter : if it is a POST with the content type set to application/...
+ * - public render parameter : optionally sent by the consumer
+
+ * - getParameterMap() : the interaction parameter + form parameters if any + public render parameter
+ * - getPrivateParameterMap() : the interaction parameter + form parameter
+ * - getPublicParameterMap() : public render parameter
+ */
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo, ActionContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo, context.getPublicNavigationalState());
+
+ // The private parameters
+ ParameterMap privateParameters = safeBuildParameters(context.getInteractionState());
+
+ // Combine form if we have one
+ privateParameters = safeCombine(privateParameters, context.getForm());
+
+ // Combine to get shared map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters, publicParameters);
+ }
+
/** . */
protected final ParameterMap parameters;
@@ -53,16 +136,51 @@
/** . */
protected final ParameterMap publicParameters;
- public PortletRequestParameterMap(NavigationInfo navigationInfo, PortletInvocationContext context)
+ protected PortletRequestParameterMap(
+ ParameterMap parameters,
+ ParameterMap privateParameters,
+ ParameterMap publicParameters)
{
- // Build public parameters
- ParameterMap publicParameters = null;
+ if (privateParameters != null)
+ {
+ privateParameters = privateParameters.as(COPY_MODE);
+ }
+ if (publicParameters != null)
+ {
+ publicParameters = publicParameters.as(COPY_MODE);
+ }
+ if (parameters != null)
+ {
+ parameters = parameters.as(COPY_MODE);
+ }
//
- if (context.getPublicNavigationalState() != null)
+ this.parameters = parameters;
+ this.privateParameters = privateParameters;
+ this.publicParameters = publicParameters;
+ }
+
+ public ParameterMap getParameters()
+ {
+ return parameters;
+ }
+
+ public ParameterMap getPrivateParameters()
+ {
+ return privateParameters;
+ }
+
+ public ParameterMap getPublicParameters()
+ {
+ return publicParameters;
+ }
+
+ protected static ParameterMap safeBuildPublicParameters(NavigationInfo navigationInfo, ParameterMap publicNavigationalParameters)
+ {
+ if (publicNavigationalParameters != null)
{
// Clone the public navigational state with the copy mode
- publicParameters = ParameterMap.clone(context.getPublicNavigationalState());
+ ParameterMap publicParameters = ParameterMap.clone(publicNavigationalParameters);
// Remove any parameter that would have been sent by the producer by mistake
for (Iterator<String> i = publicParameters.keySet().iterator(); i.hasNext();)
@@ -73,153 +191,53 @@
i.remove();
}
}
+
+ //
+ return publicParameters;
}
+ else
+ {
+ return null;
+ }
+ }
- //
- if (context instanceof ActionContext)
+ protected static ParameterMap safeBuildParameters(StateString stateString)
+ {
+ if (stateString != null)
{
- ActionContext actionContext = (ActionContext)context;
+ return ParametersStateString.create(stateString).getParameters();
+ }
+ else
+ {
+ return null;
+ }
+ }
- // The private parameters
- ParameterMap privateParameters = null;
-
- // Get the possibly null interaction state
- StateString interactionState = actionContext.getInteractionState();
- if (interactionState != null)
+ protected static ParameterMap safeCombine(ParameterMap privateParameters, ParameterMap publicParameters)
+ {
+ if (publicParameters != null)
+ {
+ if (privateParameters != null)
{
- privateParameters = ParametersStateString.create(interactionState).getParameters();
+ ParameterMap parameters = ParameterMap.clone(privateParameters);
+ parameters.append(publicParameters);
+ return parameters;
}
-
- // Combine form if we have one
- ParameterMap form = actionContext.getForm();
- if (form != null)
- {
- if (privateParameters == null)
- {
- privateParameters = form;
- }
- else
- {
- privateParameters.append(form);
- }
- }
-
- //
- ParameterMap parameters;
- if (publicParameters != null)
- {
- if (privateParameters != null)
- {
- parameters = ParameterMap.clone(privateParameters);
- parameters.append(publicParameters);
- }
- else
- {
- parameters = publicParameters;
- }
- }
else
{
- if (privateParameters != null)
- {
- parameters = privateParameters;
- }
- else
- {
- parameters = null;
- }
+ return publicParameters;
}
-
- // Use with access mode that will prevent external updates to the map
- if (privateParameters != null)
- {
- privateParameters = privateParameters.as(COPY_MODE);
- }
- if (publicParameters != null)
- {
- publicParameters = publicParameters.as(COPY_MODE);
- }
- if (parameters != null)
- {
- parameters = parameters.as(COPY_MODE);
- }
-
- //
- this.privateParameters = privateParameters;
- this.publicParameters = publicParameters;
- this.parameters = parameters;
}
else
{
- // Get the possibly null navigational state
- StateString navigationalState = context.getNavigationalState();
-
- //
- ParameterMap privateParameters = null;
- if (navigationalState != null)
+ if (privateParameters != null)
{
- privateParameters = ParametersStateString.create(navigationalState).getParameters();
+ return privateParameters;
}
-
- // Build combined map
- ParameterMap parameters;
- if (publicParameters != null)
- {
- if (privateParameters != null)
- {
- parameters = ParameterMap.clone(privateParameters);
- parameters.append(publicParameters);
- }
- else
- {
- parameters = publicParameters;
- }
- }
else
{
- if (privateParameters != null)
- {
- parameters = privateParameters;
- }
- else
- {
- parameters = null;
- }
+ return null;
}
-
- // Use with access mode that will prevent external updates to the map
- if (privateParameters != null)
- {
- privateParameters = privateParameters.as(COPY_MODE);
- }
- if (publicParameters != null)
- {
- publicParameters = publicParameters.as(COPY_MODE);
- }
- if (parameters != null)
- {
- parameters = parameters.as(COPY_MODE);
- }
-
- //
- this.privateParameters = privateParameters;
- this.publicParameters = publicParameters;
- this.parameters = parameters;
}
}
-
- public ParameterMap getParameters()
- {
- return parameters;
- }
-
- public ParameterMap getPrivateParameters()
- {
- return privateParameters;
- }
-
- public ParameterMap getPublicParameters()
- {
- return publicParameters;
- }
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceRequestParameterMap extends PortletRequestParameterMap
+{
+
+ /** . */
+ protected final ParameterMap privateRenderParameters;
+
+ protected ResourceRequestParameterMap(
+ ParameterMap parameters,
+ ParameterMap privateParameters,
+ ParameterMap publicParameters,
+ ParameterMap privateRenderParameters)
+ {
+ super(parameters, privateParameters, publicParameters);
+
+ //
+ if (privateRenderParameters != null)
+ {
+ privateRenderParameters = privateRenderParameters.as(COPY_MODE);
+ }
+
+ //
+ this.privateRenderParameters = privateRenderParameters;
+ }
+
+ public ParameterMap getPrivateRenderParameters()
+ {
+ return privateRenderParameters;
+ }
+
+ /**
+ * - resource parameter : always
+ * - form parameter : if it is a POST with the content type set to application/...
+ * - render parameter : depends on the cacheability of the request
+ * - public render parameter : optionally sent by the consumer
+
+ * - getParameterMap() : the resource parameter + form parameters if any + render parameter + public render parameter
+ * - getPrivateParameterMap() : the resource parameter + form parameter
+ * - getPublicParameterMap() : public render parameter
+ * - getPrivateRenderParameterMap() : render parameter
+ */
+ public static ResourceRequestParameterMap create(NavigationInfo navigationInfo, ResourceInvocationContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo, context.getPublicNavigationalState());
+
+ // Combine private render parameters if any
+ ParameterMap privateRenderParameters = safeBuildParameters(context.getNavigationalState());
+
+ // The private parameters
+ ParameterMap privateParameters = safeBuildParameters(context.getResourceState());
+
+ // Combine form if we have one
+ privateParameters = safeCombine(privateParameters, context.getForm());
+
+ // Combien with private render parameters
+ privateParameters = safeCombine(privateParameters, privateRenderParameters);
+
+ // Combine to get shared map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new ResourceRequestParameterMap(parameters, privateParameters, publicParameters, privateRenderParameters);
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,18 +23,11 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
-import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.BaseURL;
-import javax.portlet.WindowState;
-import javax.portlet.PortletMode;
import javax.portlet.PortletSecurityException;
import java.util.Map;
import java.io.Writer;
@@ -47,52 +40,20 @@
public abstract class BaseURLImpl implements BaseURL
{
- public enum Type
- {
- ACTION, RENDER
- }
+ /** . */
+ protected final PortletInvocation inv;
- public static PortletURLImpl createActionURL(PortletInvocation invocation, PortletRequestImpl preq)
- {
- return new PortletURLImpl(invocation, preq, Type.ACTION);
- }
-
- public static PortletURLImpl createRenderURL(PortletInvocation invocation, PortletRequestImpl preq)
- {
- return new PortletURLImpl(invocation, preq, Type.RENDER);
- }
-
/** . */
- protected PortletInvocation inv;
+ protected final PortletRequestImpl preq;
/** . */
- protected PortletRequestImpl preq;
+ protected final InternalContainerURL url;
/** . */
protected Boolean secure;
- /** . */
- protected InternalPortletURL url;
-
- protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type type)
+ protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq, InternalContainerURL url)
{
- PortletParameterMap parameterMap = new PortletParameterMap(preq.navigationInfo);
-
- //
- InternalPortletURL url;
- switch (type)
- {
- case ACTION:
- url = new InternalActionURL(parameterMap);
- break;
- case RENDER:
- url = new InternalRenderURL(parameterMap);
- break;
- default:
- throw new AssertionError();
- }
-
- //
this.inv = invocation;
this.preq = preq;
this.url = url;
@@ -146,82 +107,19 @@
public String toString()
{
- PortletInvocationContext responseContext = inv.getPortletContext();
+ PortletInvocationContext responseContext = inv.getContext();
return responseContext.renderURL(url, secure, null, true);
}
- protected abstract class InternalPortletURL implements org.jboss.portal.portlet.PortletURL
+ protected static abstract class InternalContainerURL implements org.jboss.portal.portlet.ContainerURL
{
/** . */
- protected WindowState windowState;
-
- /** . */
- protected PortletMode portletMode;
-
- /** . */
protected final PortletParameterMap parameters;
- protected InternalPortletURL(PortletParameterMap parameters)
+ protected InternalContainerURL(PortletParameterMap parameters)
{
this.parameters = parameters;
}
-
- public Mode getMode()
- {
- if (portletMode != null)
- {
- return Mode.create(portletMode.toString());
- }
- return null;
- }
-
- public org.jboss.portal.WindowState getWindowState()
- {
- if (windowState != null)
- {
- return org.jboss.portal.WindowState.create(windowState.toString());
- }
- return null;
- }
-
- public Map<String, String[]> getPublicNavigationalStateChanges()
- {
- return parameters.getPublicMapSnapshot();
- }
}
-
- protected class InternalActionURL extends InternalPortletURL implements ActionURL
- {
-
- private InternalActionURL(PortletParameterMap parameters)
- {
- super(parameters);
- }
-
- public StateString getInteractionState()
- {
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
- }
-
- /** The portlet container does not need to have the navigational state provided. */
- public StateString getNavigationalState()
- {
- return BaseURLImpl.this.inv.getPortletContext().getNavigationalState();
- }
- }
-
- protected class InternalRenderURL extends InternalPortletURL implements RenderURL
- {
-
- private InternalRenderURL(PortletParameterMap parameters)
- {
- super(parameters);
- }
-
- public StateString getNavigationalState()
- {
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
- }
- }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -47,7 +47,7 @@
{
if (event == null)
{
- event = new EventImpl((EventContext)invocation.getPortletContext());
+ event = new EventImpl((EventContext)invocation.getContext());
}
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -54,7 +54,7 @@
}
//
- PortletInvocationContext context = invocation.getPortletContext();
+ PortletInvocationContext context = invocation.getContext();
//
WantUpdate update = wantUpdate();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -25,19 +25,15 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ContentInfo;
import org.jboss.portal.common.NotYetImplemented;
-import org.w3c.dom.Element;
-import org.w3c.dom.DOMException;
import javax.portlet.MimeResponse;
import javax.portlet.PortletURL;
import javax.portlet.ResourceURL;
import javax.portlet.CacheControl;
import javax.activation.MimeTypeParseException;
-import javax.servlet.http.Cookie;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.OutputStream;
@@ -65,7 +61,7 @@
this.result = new FragmentResponse();
}
- public PortletInvocationResponse getResult()
+ public PortletInvocationResponse getResponse()
{
return result;
}
@@ -90,7 +86,7 @@
MediaType requestedMediaType = MediaType.parseMimeType(contentType);
// Get the response media type
- ContentInfo info = invocation.getPortletContext().getMarkupInfo();
+ ContentInfo info = invocation.getContext().getMarkupInfo();
MediaType responseMediaType = info.getContentType();
// Check if the requested media type is allowed as a subtype of the main response
@@ -122,17 +118,17 @@
public PortletURL createRenderURL()
{
- return BaseURLImpl.createRenderURL(invocation, preq);
+ return PortletURLImpl.createRenderURL(invocation, preq);
}
public PortletURL createActionURL()
{
- return BaseURLImpl.createActionURL(invocation, preq);
+ return PortletURLImpl.createActionURL(invocation, preq);
}
public String getCharacterEncoding()
{
- return invocation.getPortletContext().getMarkupInfo().getCharset();
+ return invocation.getContext().getMarkupInfo().getCharset();
}
public Locale getLocale()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -118,7 +118,7 @@
this.attributes = new PortletRequestAttributes(container, userContext);
this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator, mode);
this.navigationInfo = navigationInfo;
- this.requestParameterMap = new PortletRequestParameterMap(navigationInfo, invocation.getPortletContext());
+ this.requestParameterMap = PortletRequestParameterMap.create(navigationInfo, invocation.getContext());
}
// PLT.11.1.1
@@ -176,13 +176,13 @@
public WindowState getWindowState()
{
- String s = invocation.getPortletContext().getWindowState().toString();
+ String s = invocation.getContext().getWindowState().toString();
return PortletUtils.decodeWindowState(s);
}
public PortletMode getPortletMode()
{
- String s = invocation.getPortletContext().getMode().toString();
+ String s = invocation.getContext().getMode().toString();
return PortletUtils.decodePortletMode(s);
}
@@ -342,7 +342,7 @@
public String getResponseContentType()
{
- return invocation.getPortletContext().getMarkupInfo().getContentType().toString();
+ return invocation.getContext().getMarkupInfo().getContentType().toString();
}
public Enumeration<String> getResponseContentTypes()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.common.NotYetImplemented;
@@ -56,13 +57,15 @@
this.preq = preq;
}
+ public abstract PortletInvocationResponse getResponse();
+
public String encodeURL(String url)
{
if (url == null)
{
throw new IllegalArgumentException("URL must not be null");
}
- return invocation.getPortletContext().encodeResourceURL(url);
+ return invocation.getContext().encodeResourceURL(url);
}
public void addProperty(String key, String value) throws IllegalArgumentException
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -24,12 +24,19 @@
import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.Mode;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -38,11 +45,30 @@
public class PortletURLImpl extends BaseURLImpl implements PortletURL
{
- protected PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type type)
+ public static PortletURLImpl createActionURL(PortletInvocation invocation, PortletRequestImpl preq)
{
- super(invocation, preq, type);
+ StateString navigationalState = invocation.getContext().getNavigationalState();
+ InternalActionURL url = new InternalActionURL(new PortletParameterMap(preq.navigationInfo), navigationalState);
+ return new PortletURLImpl(invocation, preq, url);
}
+ public static PortletURLImpl createRenderURL(PortletInvocation invocation, PortletRequestImpl preq)
+ {
+ InternalRenderURL url = new InternalRenderURL(new PortletParameterMap(preq.navigationInfo));
+ return new PortletURLImpl(invocation, preq, url);
+ }
+
+ /** . */
+ private final InternalPortletURL url;
+
+ private PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq, InternalPortletURL url)
+ {
+ super(invocation, preq, url);
+
+ //
+ this.url = url;
+ }
+
public void setWindowState(WindowState windowState) throws WindowStateException
{
if (!preq.isWindowStateAllowed(windowState))
@@ -87,4 +113,81 @@
{
url.parameters.removePublicParameterValue(name);
}
+
+ private static abstract class InternalPortletURL extends InternalContainerURL implements org.jboss.portal.portlet.PortletURL
+ {
+
+ /** . */
+ protected WindowState windowState;
+
+ /** . */
+ protected PortletMode portletMode;
+
+ protected InternalPortletURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public Mode getMode()
+ {
+ if (portletMode != null)
+ {
+ return Mode.create(portletMode.toString());
+ }
+ return null;
+ }
+
+ public org.jboss.portal.WindowState getWindowState()
+ {
+ if (windowState != null)
+ {
+ return org.jboss.portal.WindowState.create(windowState.toString());
+ }
+ return null;
+ }
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
+ {
+ return parameters.getPublicMapSnapshot();
+ }
+ }
+
+ private static class InternalActionURL extends InternalPortletURL implements ActionURL
+ {
+
+ /** . */
+ private final StateString navigationalState;
+
+ private InternalActionURL(PortletParameterMap parameters, StateString navigationalState)
+ {
+ super(parameters);
+
+ //
+ this.navigationalState = navigationalState;
+ }
+
+ public StateString getInteractionState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+ }
+
+ private static class InternalRenderURL extends InternalPortletURL implements RenderURL
+ {
+
+ private InternalRenderURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public StateString getNavigationalState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+ }
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.impl.jsr168.ResourceRequestParameterMap;
+
+import javax.portlet.ResourceRequest;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceRequestImpl extends ClientDataRequestImpl implements ResourceRequest
+{
+
+ /** . */
+ private final ResourceInvocationContext resourceContext;
+
+ public ResourceRequestImpl(ResourceInvocation invocation)
+ {
+ super(invocation);
+
+ //
+ this.resourceContext = invocation.getContext();
+ }
+
+ public String getETag()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getResourceID()
+ {
+ return resourceContext.getResourceId();
+ }
+
+ public Map<String, String[]> getPrivateRenderParameterMap()
+ {
+ return ((ResourceRequestParameterMap)requestParameterMap).getPrivateRenderParameters();
+ }
+
+ public String getCacheability()
+ {
+ return ResourceURLImpl.toJSR168(resourceContext.getCacheability());
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+
+import javax.portlet.ResourceResponse;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
+{
+
+ public ResourceResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
+ {
+ super(invocation, preq);
+ }
+
+ public void setLocale(Locale locale)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCharacterEncoding(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContentLength(int i)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,179 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+
+import javax.portlet.ResourceURL;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceURLImpl extends BaseURLImpl implements ResourceURL
+{
+
+ /** . */
+ private static final Map<String, Cacheability> jsr168ToType = new HashMap<String, Cacheability>();
+
+ /** . */
+ private static final Map<Cacheability, String> typetoJSR168 = new HashMap<Cacheability, String>();
+
+ static
+ {
+ jsr168ToType.put(ResourceURL.FULL, Cacheability.FULL);
+ jsr168ToType.put(ResourceURL.PAGE, Cacheability.PAGE);
+ jsr168ToType.put(ResourceURL.PORTLET, Cacheability.PORTLET);
+
+ //
+ typetoJSR168.put(Cacheability.FULL, ResourceURL.FULL);
+ typetoJSR168.put(Cacheability.PAGE, ResourceURL.PAGE);
+ typetoJSR168.put(Cacheability.PORTLET, ResourceURL.PORTLET);
+ }
+
+ public static String toJSR168(Cacheability cacheability)
+ {
+ return typetoJSR168.get(cacheability);
+ }
+
+ /** . */
+ private final InternalResourceURL url;
+
+ private ResourceURLImpl(
+ PortletInvocation invocation,
+ PortletRequestImpl preq,
+ InternalResourceURL url)
+ {
+ super(invocation, preq, url);
+
+ //
+ this.url = url;
+
+ //
+ if (invocation instanceof ResourceInvocation)
+ {
+ url.constraint = ((ResourceInvocation)invocation).getContext().getCacheability();
+ }
+ }
+
+ public void setResourceID(String resourceID)
+ {
+ if (resourceID != null)
+ {
+ url.id = resourceID;
+ }
+ }
+
+ public String getCacheability()
+ {
+ Cacheability cacheability = url.cacheability;
+
+ //
+ if (cacheability == null)
+ {
+ cacheability = url.constraint != null ? url.constraint : Cacheability.PAGE;
+ }
+
+ //
+ return typetoJSR168.get(cacheability);
+ }
+
+ public void setCacheability(String s)
+ {
+ Cacheability cacheability = jsr168ToType.get(s);
+
+ //
+ if (cacheability != null)
+ {
+ if (url.constraint == null)
+ {
+ url.cacheability = cacheability;
+ }
+ else
+ {
+ switch (url.constraint)
+ {
+ case FULL:
+ if (cacheability != Cacheability.FULL)
+ {
+ throw new IllegalStateException();
+ }
+ break;
+ case PORTLET:
+ if (cacheability == Cacheability.PAGE)
+ {
+ throw new IllegalStateException();
+ }
+ break;
+ }
+ url.cacheability = cacheability;
+ }
+ }
+ }
+
+ public static ResourceURLImpl createResourceURL(PortletInvocation invocation, PortletRequestImpl preq)
+ {
+ InternalResourceURL url = new InternalResourceURL(new PortletParameterMap(preq.navigationInfo));
+ return new ResourceURLImpl(invocation, preq, url);
+ }
+
+ private static class InternalResourceURL extends InternalContainerURL implements org.jboss.portal.portlet.ResourceURL
+ {
+
+ /** . */
+ private String id;
+
+ /** The cacheability constraining the url cacheability. */
+ private Cacheability constraint;
+
+ /** . */
+ private Cacheability cacheability;
+
+ private InternalResourceURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public StateString getResourceState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Cacheability getCacheability()
+ {
+ return cacheability;
+ }
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -26,6 +26,7 @@
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
@@ -82,7 +83,7 @@
super(invocation, preq);
}
- public StateResponse getResponse()
+ public PortletInvocationResponse getResponse()
{
Decision decision = wantRedirect;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -25,12 +25,15 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
/**
* Factory for portlet API implementation.
@@ -63,4 +66,12 @@
/**
*/
RenderResponseImpl createRenderResponse(RenderInvocation invocation, RenderRequestImpl renderRequest);
+
+ /**
+ */
+ ResourceRequestImpl createResourceRequest(ResourceInvocation invocation);
+
+ /**
+ */
+ ResourceResponseImpl createResourceResponse(ResourceInvocation invocation, ResourceRequestImpl renderRequest);
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.taglib;
-import org.jboss.portal.portlet.impl.jsr168.api.BaseURLImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletURLImpl;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
@@ -191,11 +191,11 @@
// Create the URL
if ("action".equals(getTypeValue()))
{
- return BaseURLImpl.createActionURL(getInvocation(), preq);
+ return PortletURLImpl.createActionURL(getInvocation(), preq);
}
else if ("render".equals(getTypeValue()))
{
- return BaseURLImpl.createRenderURL(getInvocation(), preq);
+ return PortletURLImpl.createRenderURL(getInvocation(), preq);
}
else
{
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.spi;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractResourceContext extends AbstractPortletInvocationContext implements ResourceInvocationContext
+{
+
+ /** . */
+ private final String resourceId;
+
+ /** . */
+ private final Cacheability cacheability;
+
+ /** . */
+ private final StateString resourceState;
+
+ /** . */
+ private final ParameterMap form;
+
+ public AbstractResourceContext(
+ String resourceId,
+ Cacheability cacheability,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ ParameterMap publicNavigationalState,
+ StateString resourceState,
+ ParameterMap form,
+ MarkupInfo markupInfo)
+ {
+ super(mode, windowState, navigationalState, publicNavigationalState, markupInfo);
+
+ //
+ this.resourceId = resourceId;
+ this.cacheability = cacheability;
+ this.resourceState = resourceState;
+ this.form = form;
+ }
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ public Cacheability getCacheability()
+ {
+ return cacheability;
+ }
+
+ public StateString getResourceState()
+ {
+ return resourceState;
+ }
+
+ public ParameterMap getForm()
+ {
+ return form;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class ActionInvocation extends PortletInvocation
{
- public ActionInvocation(ActionContext ctx)
+
+ /** . */
+ private final ActionContext ctx;
+
+ public ActionInvocation(ActionContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public ActionContext getContext()
+ {
+ return ctx;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class EventInvocation extends PortletInvocation
{
+
+ /** . */
+ private final EventContext ctx;
+
public EventInvocation(EventContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public EventContext getContext()
+ {
+ return ctx;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -117,16 +117,11 @@
this.ctx = ctx;
}
- public InvocationContext getContext()
+ public PortletInvocationContext getContext()
{
return ctx;
}
- public PortletInvocationContext getPortletContext()
- {
- return ctx;
- }
-
public PortletContext getTarget()
{
return target;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class RenderInvocation extends PortletInvocation
{
- public RenderInvocation(RenderContext ctx)
+
+ /** . */
+ private final RenderContext ctx;
+
+ public RenderInvocation(RenderContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public RenderContext getContext()
+ {
+ return ctx;
+ }
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation;
+
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceInvocation extends PortletInvocation
+{
+
+ /** . */
+ private final ResourceInvocationContext ctx;
+
+ public ResourceInvocation(ResourceInvocationContext ctx) throws IllegalArgumentException
+ {
+ super(ctx);
+
+ //
+ this.ctx = ctx;
+ }
+
+ public ResourceInvocationContext getContext()
+ {
+ return ctx;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
/**
* Contract that defines what input/services the caller of a portlet container must provide.
@@ -84,14 +85,16 @@
String encodeResourceURL(String url) throws IllegalArgumentException;
/**
- * @param portletURL the portlet url
+ * Renders a container URL.
+ *
+ * @param containerURL the portlet url
* @param wantSecure if the url should be secure
* @param wantAuthenticated if the url should be authenticated
* @param relative if the url should be relative
- * @return the url
+ * @return the rendered url
*/
String renderURL(
- PortletURL portletURL,
+ ContainerURL containerURL,
Boolean wantSecure,
Boolean wantAuthenticated,
boolean relative);
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.spi;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ResourceInvocationContext extends PortletInvocationContext
+{
+
+ /**
+ * Returns the resource id. It may be a null value.
+ *
+ * @return the resource id
+ */
+ String getResourceId();
+
+ /**
+ * Returns the cacheability.
+ *
+ * @return the cacheability
+ */
+ Cacheability getCacheability();
+
+ /**
+ * Returns the resource state of the request.
+ *
+ * @return the resource state
+ */
+ StateString getResourceState();
+
+ /**
+ * Returns the form parameters of the request or null if no form could be decoded by the caller.
+ *
+ * @return the request form
+ */
+ ParameterMap getForm();
+
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -27,8 +27,8 @@
import org.jboss.portal.common.invocation.AbstractInvocationContext;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
/**
@@ -68,7 +68,7 @@
throw new UnsupportedOperationException();
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
throw new UnsupportedOperationException();
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -72,9 +72,9 @@
private static final Date date = new Date();
private static final QName name = new QName("foons", "foolocalname");
- private static final List<Serializable> payloads = new ArrayList<Serializable>();
+ /** . */
+ private final List<Serializable> payloads = new ArrayList<Serializable>();
- static
{
payloads.add(true);
payloads.add(1); // int
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -25,6 +25,8 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
import org.jboss.portal.portlet.info.ParameterInfo;
@@ -43,6 +45,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
@@ -107,32 +110,33 @@
return publicNavigationalState;
}
- private PortletInvocationResponse handle(PortletControllerContext context, Action action) throws PortletInvokerException, IOException
+ private PortletInvocationResponse handle(PortletControllerContext context, ContainerRequest containerRequest) throws PortletInvokerException, IOException
{
- if (action instanceof PortletRender)
+ Portlet portlet = context.getPortlet(containerRequest.portletId);
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState portalNS = context.getNavigationalState();
+ WindowNavigationalState windowNS = portalNS.getWindowNavigationalState(containerRequest.portletId);
+ PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS, portlet, req, resp);
+
+ //
+ if (containerRequest instanceof PortletRenderRequest)
{
- PortletRender portletRender = (PortletRender)action;
+ PortletRenderRequest portletRenderRequest = (PortletRenderRequest)containerRequest;
//
UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
- updateNavigationalState.setMode(action.mode);
- updateNavigationalState.setWindowState(action.windowState);
- updateNavigationalState.setNavigationalState(portletRender.navigationalParameters);
+ updateNavigationalState.setMode(portletRenderRequest.mode);
+ updateNavigationalState.setWindowState(portletRenderRequest.windowState);
+ updateNavigationalState.setNavigationalState(portletRenderRequest.navigationalState);
return updateNavigationalState;
}
- else
+ else if (containerRequest instanceof PortletActionRequest)
{
- PortletAction portletAction = (PortletAction)action;
+ PortletActionRequest portletActionRequest = (PortletActionRequest)containerRequest;
- Portlet portlet = context.getPortlet(action.portletId);
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState navState = context.getNavigationalState();
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
- WindowNavigationalState windowNS = navState.getWindowNavigationalState(action.portletId);
-
//
- Mode mode = action.mode;
+ Mode mode = portletActionRequest.mode;
if (mode == null && windowNS != null && windowNS.getMode() != null)
{
mode = windowNS.getMode();
@@ -143,7 +147,7 @@
}
//
- WindowState windowState = action.windowState;
+ WindowState windowState = portletActionRequest.windowState;
if (windowState == null && windowNS != null && windowNS.getWindowState() != null)
{
windowState = windowNS.getWindowState();
@@ -162,11 +166,11 @@
renderer,
mode,
windowState,
- portletAction.navigationalParameters,
+ portletActionRequest.navigationalState,
publicNS,
MARKUP_INFO,
- portletAction.interactionParameters,
- portletAction.bodyParameters != null ? ParameterMap.clone(portletAction.bodyParameters) : null);
+ portletActionRequest.interactionState,
+ portletActionRequest.bodyParameters != null ? ParameterMap.clone(portletActionRequest.bodyParameters) : null);
ActionInvocation actionInvocation = new ActionInvocation(actionContext);
//
@@ -189,6 +193,70 @@
return null;
}
}
+ else
+ {
+ PortletResourceRequest portletResourceRequest = (PortletResourceRequest)containerRequest;
+
+ //
+ Mode mode = Mode.VIEW;
+ if (mode == null && windowNS != null && windowNS.getMode() != null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ //
+ WindowState windowState = WindowState.NORMAL;
+ if (windowState == null && windowNS != null && windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+
+ //
+ ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(
+ portletResourceRequest.resourceId,
+ portletResourceRequest.resourceCacheability,
+ renderer,
+ mode,
+ windowState,
+ portletResourceRequest.navigationalState,
+ publicNS,
+ portletResourceRequest.resourceState,
+ portletResourceRequest.bodyParameters != null ? ParameterMap.clone(portletResourceRequest.bodyParameters) : null,
+ MARKUP_INFO);
+ ResourceInvocation resourceInvocation = new ResourceInvocation(resourceInvocationContext);
+
+ //
+ resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
+ resourceInvocation.setInstanceContext(instanceContext);
+ resourceInvocation.setUserContext(new AbstractUserContext(req));
+ resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ resourceInvocation.setPortalContext(new AbstractPortalContext());
+ resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ resourceInvocation.setRequestContext(new AbstractRequestContext(req));
+ resourceInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(resourceInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
+ }
}
private PortletInvocationResponse deliverEvent(
@@ -199,8 +267,8 @@
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
PortalNavigationalState navState = context.getNavigationalState();
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
WindowNavigationalState windowNS = navState.getWindowNavigationalState(portlet.getContext().getId());
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, windowNS, portlet, req, resp);
//
if (windowNS == null)
@@ -240,20 +308,35 @@
}
catch (PortletInvokerException e)
{
+ log.error("Error during event invocation", e);
+
+ //
return null;
}
}
- public void process(PortletControllerContext context, Action action) throws PortletInvokerException, IOException
+ public void process(PortletControllerContext context, ControllerRequest controllerRequest) throws PortletInvokerException, IOException
{
+ if (controllerRequest == null)
+ {
+ render(context);
+ }
+ else if (controllerRequest instanceof ContainerRequest)
+ {
+ process(context, (ContainerRequest)controllerRequest);
+ }
+ }
+
+ public void process(PortletControllerContext context, ContainerRequest containerRequest) throws PortletInvokerException, IOException
+ {
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState navState = context.getNavigationalState();
+ PortalNavigationalState portalNS = context.getNavigationalState();
//
- if (action != null)
+ if (containerRequest instanceof PortletRequest)
{
- PortletInvocationResponse response = handle(context, action);
+ PortletInvocationResponse response = handle(context, containerRequest);
//
if (response instanceof ErrorResponse)
@@ -280,7 +363,7 @@
// Update portlet NS
if (response instanceof UpdateNavigationalStateResponse)
{
- updateNavigationalState(context, action.portletId, (UpdateNavigationalStateResponse)response);
+ updateNavigationalState(context, containerRequest.portletId, (UpdateNavigationalStateResponse)response);
}
// Create event list and feed it with the events that may have been produced
@@ -359,10 +442,6 @@
System.out.println("Not yet handled " + response);
}
-
-
-
-
/*
if (response instanceof RenderResponse && redirectAfterAction)
{
@@ -386,8 +465,22 @@
response = new HTTPRedirectionResponse(location);
}
*/
+
+ //
+ render(context);
}
+ else if (containerRequest instanceof PortletResourceRequest)
+ {
+ PortletInvocationResponse response = handle(context, containerRequest);
+ }
+ }
+ private void render(PortletControllerContext context) throws IOException
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState portalNS = context.getNavigationalState();
+
//
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
@@ -399,15 +492,19 @@
for (Portlet portlet : context.getPortlets())
{
writer.print("<div><div>" + portlet.getContext() + "</div>");
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
//
+ WindowNavigationalState windowNS = portalNS.getWindowNavigationalState(portlet.getContext().getId());
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS, portlet, req, resp);
+
+ //
Mode mode = Mode.VIEW;
WindowState windowState = WindowState.NORMAL;
StateString portletNS = null;
//
- WindowNavigationalState windowNS = navState.getWindowNavigationalState(portlet.getContext().getId());
if (windowNS != null)
{
if (windowNS.getMode() != null)
@@ -462,6 +559,7 @@
}
writer.print("</body></html>");
+
}
private void updateNavigationalState(
@@ -529,75 +627,120 @@
}
}
- static class Action
+ static class ControllerRequest
{
+ }
+ static class ContainerRequest extends ControllerRequest
+ {
/** . */
final String portletId;
+ ContainerRequest(String portletId)
+ {
+ this.portletId = portletId;
+ }
+ }
+
+ static class PortletRequest extends ContainerRequest
+ {
+
/** . */
final Mode mode;
/** . */
final WindowState windowState;
- public Action(
- String portletId,
- Mode mode,
- WindowState windowState)
+ PortletRequest(String portletId, Mode mode, WindowState windowState)
{
- this.portletId = portletId;
+ super(portletId);
this.mode = mode;
this.windowState = windowState;
}
}
- static class PortletAction extends Action
+
+ static class PortletResourceRequest extends ContainerRequest
{
/** . */
- final StateString navigationalParameters;
+ final String resourceId;
/** . */
- final StateString interactionParameters;
+ final Cacheability resourceCacheability;
/** . */
- final Map<String, String[]> bodyParameters;
+ final StateString navigationalState;
- public PortletAction(
+ /** . */
+ final StateString resourceState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ PortletResourceRequest(
String portletId,
- StateString navigationalParameters,
- StateString interactionParameters,
- Map<String, String[]> bodyParameters,
+ String resourceId,
+ Cacheability resourceCacheability,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ StateString navigationalState
+ )
+ {
+ super(portletId);
+ this.resourceId = resourceId;
+ this.resourceCacheability = resourceCacheability;
+ this.navigationalState = navigationalState;
+ this.resourceState = resourceState;
+ this.bodyParameters = bodyParameters;
+ }
+ }
+
+ static class PortletActionRequest extends PortletRequest
+ {
+
+ /** . */
+ final StateString navigationalState;
+
+ /** . */
+ final StateString interactionState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ public PortletActionRequest(
+ String portletId,
+ StateString interactionState,
+ ParameterMap bodyParameters,
+ StateString navigationalState,
Mode mode,
WindowState windowState)
{
super(portletId, mode, windowState);
//
- this.navigationalParameters = navigationalParameters;
- this.interactionParameters = interactionParameters;
+ this.navigationalState = navigationalState;
+ this.interactionState = interactionState;
this.bodyParameters = bodyParameters;
}
}
- static class PortletRender extends Action
+ static class PortletRenderRequest extends PortletRequest
{
/** . */
- final StateString navigationalParameters;
+ final StateString navigationalState;
-
- public PortletRender(
+ public PortletRenderRequest(
String portletId,
- StateString navigationalParameters,
+ StateString navigationalState,
Mode mode,
WindowState windowState)
{
super(portletId, mode, windowState);
//
- this.navigationalParameters = navigationalParameters;
+ this.navigationalState = navigationalState;
}
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -32,6 +32,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.web.Body;
@@ -70,7 +71,7 @@
private final PortalNavigationalState navState;
/** . */
- private final PortletController.Action action;
+ private final PortletController.ControllerRequest request;
/** . */
private final PortletInvoker invoker;
@@ -81,16 +82,10 @@
ServletContext servletContext)
throws IllegalRequestException, IOException, ClassNotFoundException
{
-// if (navStateScope < NAV_SCOPE || navStateScope > SESSION_SCOPE)
-// {
-// throw new IllegalArgumentException();
-// }
-
- //
PortletInvoker invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
PortalNavigationalState navState;
- PortletController.Action action;
+ PortletController.ControllerRequest request;
// decode request
String pathInfo = req.getPathInfo();
@@ -100,17 +95,6 @@
WebRequest ri = new WebRequest(req);
-// if (navStateScope == NAV_SCOPE)
-// {
-// String ns = metaParameters.getValue("ns");
-// byte[] bytes = Tools.fromHexString(ns);
-// navState = PortalNavigationalState.create(bytes);
-// }
-// else
-// {
-// navState = (PortalNavigationalState)req.getSession().getAttribute("nav_state");
-// }
-
// Unmarshall portal navigational state
String context = req.getParameter("context");
byte[] bytes = Tools.fromHexString(context);
@@ -119,30 +103,13 @@
//
String type = req.getParameter("type");
- //
- Mode mode = null;
- if (req.getParameter("mode") != null)
- {
- mode = Mode.create(req.getParameter("mode"));
- }
//
- WindowState windowState = null;
- if (req.getParameter("windowstate") != null)
+ if ("resource".equals(type))
{
- windowState = WindowState.create(req.getParameter("windowstate"));
- }
+ StateString resourceState = ParametersStateString.create(req.getParameter("resourcestate"));
+ String resourceId = req.getParameter("id");
-
-
- if ("action".equals(type))
- {
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
//
String navigationalStateString = req.getParameter("navigationalstate");
StateString navigationalState = null;
@@ -152,42 +119,90 @@
}
//
- StateString interactionState = ParametersStateString.create(req.getParameter("interactionstate"));
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
//
- action = new PortletController.PortletAction(targetId, navigationalState, interactionState, formParameters, mode, windowState);
+ Cacheability resourceCacheability = Cacheability.valueOf(req.getParameter("cacheability"));
+
+ //
+ request = new PortletController.PortletResourceRequest(
+ targetId,
+ resourceId,
+ resourceCacheability,
+ resourceState,
+ formParameters,
+ navigationalState);
}
else
{
- StateString navigationalState = ParametersStateString.create(req.getParameter("navigationalstate"));
+ //
+ Mode mode = null;
+ if (req.getParameter("mode") != null)
+ {
+ mode = Mode.create(req.getParameter("mode"));
+ }
//
- action = new PortletController.PortletRender(targetId, navigationalState, mode, windowState);
+ WindowState windowState = null;
+ if (req.getParameter("windowstate") != null)
+ {
+ windowState = WindowState.create(req.getParameter("windowstate"));
+ }
+
+ //
+ if ("action".equals(type))
+ {
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ String navigationalStateString = req.getParameter("navigationalstate");
+ StateString navigationalState = null;
+ if (navigationalStateString != null)
+ {
+ navigationalState = ParametersStateString.create(navigationalStateString);
+ }
+
+ //
+ StateString interactionState = ParametersStateString.create(req.getParameter("interactionstate"));
+
+ //
+ request = new PortletController.PortletActionRequest(targetId, interactionState, formParameters, navigationalState, mode, windowState);
+ }
+ else
+ {
+ StateString navigationalState = ParametersStateString.create(req.getParameter("navigationalstate"));
+
+ //
+ request = new PortletController.PortletRenderRequest(targetId, navigationalState, mode, windowState);
+ }
}
}
else
{
navState = new PortalNavigationalState();
- action = null;
-
- //
-// if (navStateScope == SESSION_SCOPE)
-// {
-// req.getSession().setAttribute("nav_state", navState);
-// }
+ request = null;
}
+ //
this.navState = navState;
- this.action = action;
+ this.request = request;
this.req = req;
this.resp = resp;
this.servletContext = servletContext;
this.invoker = invoker;
}
- public PortletController.Action getRequest()
+ public PortletController.ControllerRequest getRequest()
{
- return action;
+ return request;
}
public PortalNavigationalState getNavigationalState()
@@ -212,8 +227,7 @@
public Portlet getPortlet(String portletId) throws PortletInvokerException
{
- PortletContext target = PortletContext.createPortletContext(action.portletId);
- return invoker.getPortlet(target);
+ return invoker.getPortlet(PortletContext.createPortletContext(portletId));
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ResourceURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
@@ -48,27 +50,32 @@
final Portlet portlet;
/** . */
+ final WindowNavigationalState windowNS;
+
+ /** . */
final HttpServletRequest clientReq;
/** . */
final HttpServletResponse clientResp;
/** . */
- final PortalNavigationalState navState;
+ final PortalNavigationalState portalNS;
public PortletURLRenderer(
- PortalNavigationalState navState,
+ PortalNavigationalState portalNS,
+ WindowNavigationalState windowNS,
Portlet portlet,
HttpServletRequest clientReq,
HttpServletResponse clientResp)
{
- this.navState = navState;
+ this.portalNS = portalNS;
+ this.windowNS = windowNS;
this.portlet = portlet;
this.clientReq = clientReq;
this.clientResp = clientResp;
}
- String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
CharBuffer buffer = new CharBuffer();
buffer.append(clientReq.getScheme());
@@ -84,12 +91,29 @@
Map<String, String> parameters = new HashMap<String, String>();
//
- parameters.put("type", portletURL instanceof RenderURL ? "render" : "action");
+ String type;
+ if (containerURL instanceof ActionURL)
+ {
+ type = "action";
+ }
+ else if (containerURL instanceof RenderURL)
+ {
+ type = "render";
+ }
+ else if (containerURL instanceof ResourceURL)
+ {
+ type = "resource";
+ }
+ else
+ {
+ throw new Error();
+ }
+ parameters.put("type", type);
//
try
{
- byte[] bytes = PortalNavigationalState.serialize(navState);
+ byte[] bytes = PortalNavigationalState.serialize(portalNS);
String ns = Tools.toHexString(bytes);
parameters.put("context", ns);
}
@@ -99,38 +123,75 @@
}
//
- if (portletURL.getMode() != null)
+ if (containerURL instanceof PortletURL)
{
- parameters.put("mode", portletURL.getMode().toString());
- }
+ PortletURL portletURL = (PortletURL)containerURL;
- //
- if (portletURL.getWindowState() != null)
- {
- parameters.put("windowstate", portletURL.getWindowState().toString());
- }
+ if (portletURL.getMode() != null)
+ {
+ parameters.put("mode", portletURL.getMode().toString());
+ }
- //
- if (portletURL instanceof RenderURL)
- {
- StateString navigationalState = ((RenderURL)portletURL).getNavigationalState();
+ //
+ if (portletURL.getWindowState() != null)
+ {
+ parameters.put("windowstate", portletURL.getWindowState().toString());
+ }
//
- parameters.put("navigationalstate", navigationalState.getStringValue());
+ if (containerURL instanceof ActionURL)
+ {
+ ActionURL actionURL = (ActionURL)containerURL;
+
+ //
+ StateString navigationalState = actionURL.getNavigationalState();
+ if (navigationalState != null)
+ {
+ parameters.put("navigationalstate", navigationalState.getStringValue());
+ }
+
+ //
+ StateString interactionState = actionURL.getInteractionState();
+ parameters.put("interactionstate", interactionState.getStringValue());
+ }
+ else
+ {
+ RenderURL renderURL = (RenderURL)containerURL;
+
+ //
+ StateString navigationalState = renderURL.getNavigationalState();
+ parameters.put("navigationalstate", navigationalState.getStringValue());
+ }
}
else
{
- StateString navigationalState = ((ActionURL)portletURL).getNavigationalState();
- StateString interactionState = ((ActionURL)portletURL).getInteractionState();
+ ResourceURL resourceURL = (ResourceURL)containerURL;
//
- if (navigationalState != null)
+ StateString resourceState = resourceURL.getResourceState();
+ parameters.put("resourcestate", resourceState.getStringValue());
+
+ //
+ String resourceId = resourceURL.getId();
+ if (resourceId != null)
{
- parameters.put("navigationalstate", navigationalState.getStringValue());
+ parameters.put("id", resourceId);
}
//
- parameters.put("interactionstate", interactionState.getStringValue());
+ parameters.put("cacheability", resourceURL.getCacheability().name());
+ switch (resourceURL.getCacheability())
+ {
+ case FULL:
+ // todo
+ break;
+ case PORTLET:
+ // todo
+ break;
+ case PAGE:
+ // todo
+ break;
+ }
}
//
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractResourceContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResourceTestContext extends AbstractResourceContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public ResourceTestContext(
+ String resourceId,
+ Cacheability resourceCacheability,
+ PortletURLRenderer urlRenderer,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ ParameterMap publicNavigationalState,
+ StateString resourceState,
+ ParameterMap form,
+ MarkupInfo markupInfo)
+ {
+ super(
+ resourceId,
+ resourceCacheability,
+ mode,
+ windowState,
+ navigationalState,
+ publicNavigationalState,
+ resourceState,
+ form,
+ markupInfo);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
import org.jboss.portal.Mode;
@@ -79,8 +79,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,9 +23,8 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
import org.jboss.portal.portlet.impl.spi.AbstractEventContext;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -82,8 +81,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
}
}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-21 15:44:23 UTC (rev 9547)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-21 21:32:53 UTC (rev 9548)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
import org.jboss.portal.Mode;
@@ -77,8 +77,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
}
}
18 years, 3 months