You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Sreedevi Aswath <sr...@gmail.com> on 2006/07/14 13:46:35 UTC

To mockup the component behaviour in the Unit test case

 Hi ,

    I am using myfaces and tomahawk for my application.
    I am writing unit test cases using shale framework.
    I am facing a problem trying to mock up the component behaviour.

    I have  a page with <t:datatable> and a edit commandbutton.
    <t:dataTable id="ptable" value="#{myManager.profiles}" var="profile"
binding="#{myBean.uiTable }" >

    There is a selectBooleanCheckbox against each row. When a row is
selected and clicked on the edit button
    in the corresponding edit action method, the info is retrieved this way.

    InfoBean bean = (InfoBean) FacesContext.getCurrentInstance
().getExternalContext().getSessionMap().put
    ("item",FacesContext.getCurrentInstance
().getExternalContext().getRequestMap().get("profile"));

    I need to write a unit test case for the edit action method using shale.
I am using the shale-test.jar that mocks up
    the JSF environment. I am creating a uitable component, in the test
method and setting up the value, var and binding. I am also
    creating a datamodel  instance and populating it with arraylist of
data.But I am not able to retrieve the value in the request
    context. How do I exactly mock  the behaviour of datatable exactly the
way it is running in the application server, the row is  selected
    and when clicked on the edit button should give me the value of the
uitable in the request context,   just as above?

    I would very much appreciate a response.

    Thanks,
     -Sreedevi