org.apache.myfaces.test.utils
Class HtmlCheckAttributesUtil

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

public class HtmlCheckAttributesUtil
extends 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 addBaseAttributes(javax.faces.component.UIComponent component, HtmlRenderedAttr[] attrs)
          This method adds all elements of attrs to the attributes map of component.
static void checkAttributeOccurrences(HtmlRenderedAttr attr, String actual)
          Checks if the occurrence of the rendered attribute in the html generated by the renderer is equal to the number of times expected.
static void checkRenderedAttributes(HtmlRenderedAttr[] attrs, String output)
          Iterates through all elements of attrs to check if they are only rendered once in output.
static void checkRenderedAttributes(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context, org.apache.myfaces.test.mock.MockResponseWriter writer, HtmlRenderedAttr[] attrs)
          This method adds all attributes from attrs into the component.
static String constructErrorMessage(HtmlRenderedAttr[] attrs, 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

addBaseAttributes

public static void addBaseAttributes(javax.faces.component.UIComponent component,
                                     HtmlRenderedAttr[] attrs)
This method adds all elements of attrs to the attributes map of component.

Parameters:
component - The component to add the attributes to.
attrs - The attributes to be added to the component.

checkRenderedAttributes

public static void checkRenderedAttributes(HtmlRenderedAttr[] attrs,
                                           String output)
                                    throws Exception
Iterates through all elements of attrs to check if they are only rendered once in output.

Parameters:
attrs - The attributes to be checked.
output - The html output of the component's renderer.
Throws:
Exception

checkRenderedAttributes

public static void checkRenderedAttributes(javax.faces.component.UIComponent component,
                                           javax.faces.context.FacesContext context,
                                           org.apache.myfaces.test.mock.MockResponseWriter writer,
                                           HtmlRenderedAttr[] attrs)
                                    throws 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:
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 String constructErrorMessage(HtmlRenderedAttr[] attrs,
                                           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.

checkAttributeOccurrences

public static void checkAttributeOccurrences(HtmlRenderedAttr attr,
                                             String actual)
Checks if the occurrence of the rendered attribute in the html generated by the renderer is equal to the number of times expected.

Parameters:
attr - The attribute to be tested.
actual - The html generated by the renderer.

generateBasicAttrs

public static HtmlRenderedAttr[] generateBasicAttrs()

generateAttrsNotRenderedForReadOnly

public static HtmlRenderedAttr[] generateAttrsNotRenderedForReadOnly()

generateBasicReadOnlyAttrs

public static HtmlRenderedAttr[] generateBasicReadOnlyAttrs()


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