Announcement Announcement Module
Collapse
No announcement yet.
Webflow testing - cannot get session attribute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Webflow testing - cannot get session attribute

    Hi,

    I have this line in my webflow configuration:

    Code:
    <evaluate expression="externalContext.nativeRequest.session.myObject" result="flowScope.myObject"/>
    This works fine in the web app.
    Now I am trying to write a test case with mocks. This is my code:

    Code:
    MockHttpSession session = new MockHttpSession();
    session.setAttribute("myObject", <some object here>);
    MockHttpServletRequest request = new MockHttpServletRequest();
     request.setSession(session);
        	
    MutableAttributeMap input = new LocalAttributeMap();
    MockExternalContext context = new MockExternalContext();
    context.setNativeRequest(request);    	
    startFlow(input, context);
    When the test goes into startFlow(), it throws an exception:

    Code:
    Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 38): Field or property 'myObject' cannot be found on object of type 'org.springframework.mock.web.MockHttpSession'
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:246)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:112)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:107)
    	at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:54)
    	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:81)
    	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98)
    	at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84)
    I don't understand why it can't find the object when it's assigned as an attribute to the HTTP session.
    Could anyone help me please?
    Thanks.
    Last edited by imchi; May 3rd, 2013, 01:49 PM.
Working...
X