Seam Testing doubts
visumagic Nov 25, 2008 11:37 PMHi ALL,
I'm working on seam testing.. here is my samples.
`@Name("collegeHome")
public class CollegeHome{
@RequestParameter
Integer id;
@In(scope=PAGE,required=false)
College college;
//Adtion method
public void foo(){
System.out.println(id); //prints id
System.out.println(college); // problem: prints null
System.out.println(Contexts.getPageContext().get("#{college}"));
// will print object
}
}`
`
public CollegeTest extends SeamTest{
@Test
public void testFoo(){
new FacesRequest(){
@Override
protected void beforeRequest() {
setParameter("id", "2");
}
@Override
protected void updateModelValues() throws Exception {
College col=new College();
col.setId(2);
Contexts.getPageContext().set("#{college}",col);
System.out.println
(Contexts.getPageContext().get("#{college}"));
//will print value
}
protected void invokeApplication() {
//call action methods here
invokeMethod("#{collegeHome.foo}");
}
}
}
}`
Here I have simple test case , my intention here is to inject test data into page context in updateModelValues, and im referring to those in the collegeHome foo() action method.
Here I'm facing lot of problems .. primarily it's giving
`@In attribute requires non-null value: collegeHome.college`
if I chage @In (required=false) , it's not printing null value in foo method.
My doubt is ,
1) Is it possible to inject values to different scopes in testing lifecycle
2) is there any difference in component lifecycle in testing time and normal time
3) In which method injection is going to happen in testing lifecycle.
please bare my doubts.
thanks
raghu
I'm working on seam testing.. here is my samples.
`@Name("collegeHome")
public class CollegeHome{
@RequestParameter
Integer id;
@In(scope=PAGE,required=false)
College college;
//Adtion method
public void foo(){
System.out.println(id); //prints id
System.out.println(college); // problem: prints null
System.out.println(Contexts.getPageContext().get("#{college}"));
// will print object
}
}`
`
public CollegeTest extends SeamTest{
@Test
public void testFoo(){
new FacesRequest(){
@Override
protected void beforeRequest() {
setParameter("id", "2");
}
@Override
protected void updateModelValues() throws Exception {
College col=new College();
col.setId(2);
Contexts.getPageContext().set("#{college}",col);
System.out.println
(Contexts.getPageContext().get("#{college}"));
//will print value
}
protected void invokeApplication() {
//call action methods here
invokeMethod("#{collegeHome.foo}");
}
}
}
}`
Here I have simple test case , my intention here is to inject test data into page context in updateModelValues, and im referring to those in the collegeHome foo() action method.
Here I'm facing lot of problems .. primarily it's giving
`@In attribute requires non-null value: collegeHome.college`
if I chage @In (required=false) , it's not printing null value in foo method.
My doubt is ,
1) Is it possible to inject values to different scopes in testing lifecycle
2) is there any difference in component lifecycle in testing time and normal time
3) In which method injection is going to happen in testing lifecycle.
please bare my doubts.
thanks
raghu