FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
FacesLifecycle.beginRequest( externalContext );
Manager.instance().setCurrentConversationId("1");
FacesLifecycle.resumeConversation(externalContext);
ConversationalInterceptor ci = new ConversationalInterceptor();
ci.setComponent( new Component(Bar.class, appContext) );
assert !Manager.instance().isLongRunningConversation();
try
{
ci.aroundInvoke( new MockInvocationContext() {
@Override
public Method getMethod()
{
return InterceptorTest.getMethod("foo");
}
@Override
public Object proceed() throws Exception
{
assert false;
return null;
}
});
assert false;
}
catch (Exception e)
{
assert e instanceof NoConversationException;
}
assert !Manager.instance().isLongRunningConversation();
String result = (String) ci.aroundInvoke( new MockInvocationContext() {
@Override
public Method getMethod()
{
return InterceptorTest.getMethod("begin");
}
@Override
public Object proceed() throws Exception
{
return "begun";
}
});
Manager.instance().initializeTemporaryConversation();
Manager.instance().beginConversation();
//assert Manager.instance().isLongRunningConversation();
assert "begun".equals(result);
result = (String) ci.aroundInvoke( new MockInvocationContext() {
@Override
public Method getMethod()
{
return InterceptorTest.getMethod("foo");
}
@Override
public Object proceed() throws Exception
{
return "foo";
}
});
//assert Manager.instance().isLongRunningConversation();
assert "foo".equals(result);
result = (String) ci.aroundInvoke( new MockInvocationContext() {
@Override
public Method getMethod()
{
return InterceptorTest.getMethod("end");
}