-
1. Re: Seam how to set @RequestParameter variable in integration test
lsk6745 Dec 15, 2009 12:38 PM (in response to lsk6745)Got better insight after some searching. Solved by using
new FacesRequest() and overide applyRequestValues() + setParameter() -
2. Re: Seam how to set @RequestParameter variable in integration test
marcelolotif.araujo Jun 10, 2015 2:53 PM (in response to lsk6745)Thank you for this answer! I was searching on google like crazy and nothing solved my problem, this was the only thing that worked. For the record, here is a code snippet of the solution:
public class SomeClassTest {
@Test
public void testSomeMethod() throws Exception{
new FacesRequest(){
@Override
protected void applyRequestValues() {
setParameter("someRequestParameter", "1234");
}
@Override
protected void invokeApplication() throws Exception {
invokeMethod("#{someClass.someMethod()}");
Assert.assertTrue(true);
}
}.run();
}
}
@Name("someClass")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
@PerNestedConversation
public class SomeClass implements java.io.Serializable {
@RequestParameter
String someRequestParameter;
public void loadData() {
System.out.println("someRequestParameter: " + someRequestParameter);
}
}