Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 326521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:19:02+00:00 2026-05-12T09:19:02+00:00

I am working on a project using Spring Web Flow 2.0. I am trying

  • 0

I am working on a project using Spring Web Flow 2.0.

I am trying to unit test a flow that begins with a decision state. The decision state checks the value of an object that is on the conversationScope. I cannot figure out how to insert a value into the conversationScope for the unit test.

I have tried:

getConversationScope().put("someName", value);
MockExternalContext context = new MockExternalContext();
startFlow(context);

However, it seems that when I call startFlow(context) the value is cleared.

I also tried:

MockExternalContext context = new MockExternalContext();
setCurrentState("someDecisionState");
resumeFlow(context)

But the test fails with an error telling me that I cannot resume from a decision state, only from a view state.

Does anyone know how I can insert mock values on the conversationScope so that I may test these cases?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:19:02+00:00Added an answer on May 12, 2026 at 9:19 am

    It’s not obvious, but I came up with this:

    public void testFoo() {
        FlowExecution flowExecution = getFlowExecutionFactory().createFlowExecution(getFlowDefinition());
        updateFlowExecution(flowExecution);
        flowExecution.getConversationScope().put("fooBar", "goo");
        flowExecution.start(null, new MockExternalContext());        
        assertCurrentStateEquals("fooView");
    }
    

    I had to dig into the underlying AbstractXmlFlowExecutionTests.startFlow() to see how it was instantiating the FlowExecution, and copy and paste some of that into the unit test.

    Here’s the test web flow.

    <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns="http://www.springframework.org/schema/webflow"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/webflow
            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
    
        <action-state id="decideFoo">
            <evaluate expression="conversationScope.fooBar" />
            <transition on="goo" to="fooView" />
            <transition on="gar" to="barView" />
        </action-state>
    
        <view-state id="fooView" />
    
        <view-state id="barView" />
    
    </flow>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 194k
  • Answers 194k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's an attribute selector that will find all <img> elements… May 12, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer Looks like ditto is still the best for me. May 12, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer Objective-C is a dynamically-typed language and methods are resolved at… May 12, 2026 at 6:47 pm

Related Questions

I have used Spring before but I am no expert and only used it
I'm working on a web project that will (hopefully) be available in several languages
I am trying to develop a .NET Web Project using NHibernate and Spring.NET, but
We are in the process of re-evaluating our usage of JSF (brought in before

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.