org.apache.myfaces.test.utils
Class HtmlCheckAttributesUtil

java.lang.Object
  extended by org.apache.myfaces.test.utils.HtmlCheckAttributesUtil

public class HtmlCheckAttributesUtil
extends java.lang.Object

This is a utility class used in unit test cases to check if a component's attributes are rendered properly.


Constructor Summary
HtmlCheckAttributesUtil()
           
 
Method Summary
static void checkRenderedAttributes(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context, org.apache.shale.test.mock.MockResponseWriter writer, HtmlRenderedAttr[] attrs)
          This method adds all attributes from attrs into the component.
static java.lang.String constructErrorMessage(HtmlRenderedAttr[] attrs, java.lang.String actual)
          Constructs an error message string detailing which attributes were not rendered and which attributes were rendered more than once.
static HtmlRenderedAttr[] generateAttrsNotRenderedForReadOnly()
           
static HtmlRenderedAttr[] generateBasicAttrs()
           
static HtmlRenderedAttr[] generateBasicReadOnlyAttrs()
           
static boolean hasFailedAttrRender(HtmlRenderedAttr[] attrs)
          Checks the attrs array if it has elements which were rendered incorrectly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlCheckAttributesUtil

public HtmlCheckAttributesUtil()
Method Detail

checkRenderedAttributes

public static void checkRenderedAttributes(javax.faces.component.UIComponent component,
                                           javax.faces.context.FacesContext context,
                                           org.apache.shale.test.mock.MockResponseWriter writer,
                                           HtmlRenderedAttr[] attrs)
                                    throws java.lang.Exception
This method adds all attributes from attrs into the component. After adding the attributes, it calls the encodeAll() method of the component. The html generated from the component's renderer will be checked to see if the attributes have been rendered correctly.

Parameters:
component - The component whose attributes will be tested.
context -
writer - The ResponseWriter used by the renderer to output the html generated.
attrs - An array of attributes which will be tested.
Throws:
java.lang.Exception

hasFailedAttrRender

public static boolean hasFailedAttrRender(HtmlRenderedAttr[] attrs)
Checks the attrs array if it has elements which were rendered incorrectly.

Parameters:
attrs - The attributes to be checked.
Returns:
True if there are attributes not rendered correctly.

constructErrorMessage

public static java.lang.String constructErrorMessage(HtmlRenderedAttr[] attrs,
                                                     java.lang.String actual)
Constructs an error message string detailing which attributes were not rendered and which attributes were rendered more than once.

Parameters:
attrs - The attributes to be tested.
actual - The html generated by the renderer.
Returns:
The error message.

generateBasicAttrs

public static HtmlRenderedAttr[] generateBasicAttrs()

generateAttrsNotRenderedForReadOnly

public static HtmlRenderedAttr[] generateAttrsNotRenderedForReadOnly()

generateBasicReadOnlyAttrs

public static HtmlRenderedAttr[] generateBasicReadOnlyAttrs()


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.