SeamTest problems to get long running conversations and redirect
testvogel Nov 10, 2010 6:14 AMHi,
I'm trying to write some tests for my Seam Application. The Problem ist, that i never get a conversation id. My conversation id in all test cases is always null
.
Here is my code:
String cid = new FacesRequest("/pages/home.seam") { Tab targetTab; int tabCount; @Override protected void updateModelValues() { assert !isSessionInvalid(); assert getValue("#{identity.loggedIn}").equals(true); assert getValue("#{TemporarySettings.currentTab.closable}").equals(false); List<Tab> openTabs = (List<Tab>) getValue("#{TemporarySettings.tabs}"); tabCount = openTabs.size(); Iterator<Tab> iter = openTabs.iterator(); assert null != openTabs; assert tabCount > 1; assert openTabs.get(0).getName().equals("home.tabtitle"); while (iter.hasNext()) { if ((targetTab = iter.next()).getName().equals("joblist.tabtitle")) break; } } @Override protected void invokeApplication() { ITemporarySettings temporarySettingsBean = (ITemporarySettings) Contexts.getSessionContext().get( "TemporarySettings"); temporarySettingsBean.setCurrentTabAndRedirect(targetTab, "/pages/joblist/joblist.xhtml"); } }.run(); cid = new FacesRequest("/pages/joblist/joblist.xhtml") { @Override protected void renderResponse() { ITemporarySettings temporarySettingsBean = (ITemporarySettings) Contexts.getSessionContext().get( "TemporarySettings"); Tab currentTab = (Tab) temporarySettingsBean.getCurrentTab(); assert currentTab.getName().equals("joblist.tabtitle"); assert getValue("#{TemporarySettings.currentTab.closable}").equals(false); System.out.println(getConversationId()); } }.run();
The important part is the invokeApplication() method
ITemporarySettings temporarySettingsBean = (ITemporarySettings) Contexts.getSessionContext().get( "TemporarySettings"); temporarySettingsBean.setCurrentTabAndRedirect(targetTab, "/pages/joblist/joblist.xhtml");
The setCurrentTabAndRedirect Method should start a new long running Conversation and redirect to the new view /pages/joblist/joblist.xml
(It worked. I already tested it manually).
The second FacesRequest tests if the redirect was sucdcessfull and the Conversation became created. I need a second FacesRequest because of the redirect (renderResponse() won't be called in the first FacesRequest).
The problem is that
System.out.println(getConversationId());
always return null.
The second problem is that i dont wanna call the second FacesRequest with the expected ViewId. I wanna test if the redirection was completed successfully, but if i dont call the FacesRequest with the ViewId the ViewId is null.
I've started working with SeamTest 1 week ago, so please excuse me is there an elementary mistake in my tests.
greets,
testvogel
(sorry for my bad english)