>From: Mohan Radhakrishnan <[EMAIL PROTECTED]> 
>
> 
> Hi, 
> I am trying to user the shale test framework to test model updates. 
> Now the code is like this but it doesn't work. Does anyone know how the code 
> should be ? 
> 

The shale test framework doesn't automatically invoke the JSF lifecycle. I 
don't think
there is much implementation for the mock lifecycle other than some objects 
that 
implement the interfaces.

Comments below....


> UIViewRoot root = facesContext.getViewRoot(); 
> assertNotNull(root); 
> UIComponent form1 = this.createForm("form1", root); 
> HtmlInputText component = createInputText("pin", form1); 
> ValueBinding valueBinding = facesContext.getApplication(). 
> createValueBinding( 
> "pin.currentPin"); 
> component.setValueBinding( "value", valueBinding ); 

This is done by the apply request values phase.  Shouldn't need to do it here.

> component.setSubmittedValue("blue"); 

> facesContext. 
> getExternalContext(). 
> getRequestMap(). 
> put( "pin", new Pin()); 
> facesContext. 
> getExternalContext(). 
> getRequestParameterMap(). 
> put( "form1:currentPin", "blue" ); 

If you wanted to simulate request values being decoded by the component 
you would need to simulate the apply request values phase.  This phase will 
push the request parameters into the "submittedValue" of the components.

root.processDecodes(facesContext);

Next you will need to run the process validations phase.  This phase will 
run converters and registered validators on the submittedValue.  
The component 's "value" attribute will be populated with the normalized
submitted value.

root.processValidators(facesContext);

The next phase is invoke application.  We have skipped all the event and phase
processing in this test so we don't need to process action and actionListener
method callbacks. 

root.processApplication(facesContext);


Next, the udate mode values phase will take the component's value and push 
it to the model by invoking the value expressions.  This phase will populate
the managed bean with the components value.

root.processUpdates(facesContext);



> Pin pin = ( Pin )facesContext. 
> getApplication(). 
> getVariableResolver(). 
> 
> resolveVariable(facesContext, "pin" ); 
> assertNotNull( pin.getCurrentPin() ); 
> 
> 
> Thanks, 
> Mohan 
> 

Gary


> -- 
> View this message in context: 
> http://www.nabble.com/Shale-test-framework---Update-model-bean-tf4607288.html#a1
>  
> 3155918 
> Sent from the Shale - User mailing list archive at Nabble.com. 
> 

Reply via email to