This content has been marked as final.
Show 1 reply
-
1. Re: Integration Testing Page Scoped Components
cretz Apr 24, 2009 9:21 PM (in response to cretz)I found a ghetto solution:
Say you have a classes like so:
@Name("componentA") @Scope(PAGE) public class ComponentA { @Create public void create() { //do something } }
@Name("componentB") @Scope(PAGE) public class ComponentB { @In ComponentA componentA; }
...just mock 'em w/ conversations like so:
@Name("componentA") @Scope(CONVERSATION) @Install(precedence = MOCK) public class ComponentAMock extends ComponentA { @Create @Begin public void create() { //do something } }
@Name("componentB") @Scope(CONVERSATION) @Install(precedence = MOCK) public class ComponentBMock extends ComponentB { }
Granted, this doesn't solve the page context persistence problem (which I am assuming is caused by the fact that the page context is recognized via JSF post back only). But at least you can test multiple interdependent page scoped components.
I also run this at the end of invokeAction on the last FacesRequest I need in the page scope:
((Manager)getInstance(Manager.class)).endConversation(false);
Still, if anyone can tell me how to persist the page context across FacesRequests, I'd appreciate it...