It is possible to have the FacesMessages class implements an interface because
I want to make unit test on my bean with EasyMock (http://www.easymock.org/)
library and this library can only mock an interface.
Code to test:
| @Name("action")
| @Interceptors(SeamInterceptor.class)
| public class Action implements IAction {
| @In(create = true)
| private FacesMessages facesMessages;
|
| public void addErrorMessage(String aMessageKey) {
| this.facesMessages.add(FacesMessage.SEVERITY_INFO, "${" + aMessageKey +
"}");
| }
|
| protected void setFacesMessages(FacesMessage aFacesMessages) {
| this.facesMessages = aFacesMessages;
| }
|
Test code.
| public class ActionUnitTest extends TestCase {
|
| private Action classUnderTest;
| private FacesMessages mockFacesMessages;
|
| public void testAddErrorMessage() {
| // Setup
| expect(this.mockFacesMessages.add("${test.key}"));
| replay(this.mockFacesMessages);
|
| // Execute test
| this.classUnderTest.addErrorMessage("test.key");
|
| // Verify
| verify(this.mockFacesMessages);
| }
|
| protected void setUp() throws Exception {
| this.mockFacesMessages = createMock(FacesMessages.class); // EXCEPTION
Cause an exception because the class is not an interface
| this.classUnderTest = new Action();
| this.classUnderTest.setFacesMessages(this.mockEntityManager);
| }
| }
|
Thanks,
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929175#3929175
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929175
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user