Spring Webflow无法在Test中启动

时间:2017-05-22 11:46:28

标签: java spring junit spring-webflow spring-test

我尝试为spring webflow编写一些测试。我尝试做一些基本测试:示例:启动流程,测试状态......但是测试中的流程无法启动。

public class FirstFlowTest extends AbstractXmlFlowExecutionTests {
    @Override
    protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) {
        return resourceFactory.createFileResource("src/main/resources/META-INF/webflow/first-flow.xml");
    }

    public void testStartFlow() {
        final MockExternalContext context = new MockExternalContext();
        final MutableAttributeMap input = new LocalAttributeMap();
        startFlow(input, context);
        assertFlowExecutionActive();
    }
}

我得到了这个例外:

junit.framework.AssertionFailedError: The flow execution is not active but it should be

at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.Assert.assertTrue(Assert.java:22)
at junit.framework.TestCase.assertTrue(TestCase.java:192)
at org.springframework.webflow.test.execution.AbstractFlowExecutionTests.assertFlowExecutionActive(AbstractFlowExecutionTests.java:298)
at de.telekom.vp.pk.tkportal.cae.webflow.FirstFlowTest.testStartFlow(LineCheckS9FlowTest.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

我怎样才能避免这种异常?

0 个答案:

没有答案