})
public class RequestHeaderAccess
{
public RequestHeaderAccess(PortletTestCase seq)
{
seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
{
// Test the value is not there yet
Set propertyNames = Tools.toSet(request.getPropertyNames());
assertFalse(propertyNames.contains("myheader"));
assertNull(request.getProperty("myheader"));
assertFalse(request.getProperties("myheader").hasMoreElements());
// Invoke render with header
InvokeGetResponse render = new InvokeGetResponse(response.createRenderURL().toString());
render.addHeader("myheader", "render-value");
return render;
}
});
seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
{
// Test the header is here
Set propertyNames = Tools.toSet(request.getPropertyNames());
assertTrue(propertyNames.contains("myheader"));
assertEquals("render-value", request.getProperty("myheader"));
Enumeration values = request.getProperties("myheader");
assertTrue(values.hasMoreElements());
assertEquals("render-value", values.nextElement());
assertFalse(values.hasMoreElements());
// Invoke action with header
InvokeGetResponse action = new InvokeGetResponse(response.createActionURL().toString());
action.addHeader("myheader", "action-value");
return action;
}
});
seq.bindAction(2, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
{
protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
{
// Test the header is here
Set propertyNames = Tools.toSet(request.getPropertyNames());
assertTrue(propertyNames.contains("myheader"));
assertEquals("action-value", request.getProperty("myheader"));
Enumeration values = request.getProperties("myheader");
assertTrue(values.hasMoreElements());
assertEquals("action-value", values.nextElement());
assertFalse(values.hasMoreElements());
}
});
seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
{
return new EndTestResponse();
}