2016-08-10 2 views
1

私は春のwebflowに慣れていません。webflowのユニットテストケースの書き込みを開始し、次のエラーが表示されます。テストケースを判定状態、動作状態のビュー状態、私はfar.Iので、任意の適切な基準は非常に多くの可能な方法を試してみましたし、概念を得るのに苦労することはあなたが私が私が春のwebflow junitでエラーが発生する

エラー

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [[email protected] targetAction = [[email protected] name = sourceSiteId, value = flowScope.regform.sid], attributes = map[[empty]]] in state 'ssoerrorredirect' of flow 'regEnroll-flow' -- action execution attributes were 'map[[empty]]' 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60) 
    at org.springframework.webflow.engine.ActionList.execute(ActionList.java:154) 
    at org.springframework.webflow.engine.State.enter(State.java:193) 
    at org.springframework.webflow.engine.Transition.execute(Transition.java:228) 
    at org.springframework.webflow.engine.DecisionState.doEnter(DecisionState.java:51) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Transition.execute(Transition.java:228) 
    at org.springframework.webflow.engine.DecisionState.doEnter(DecisionState.java:51) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Flow.start(Flow.java:527) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:368) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:223) 
    at org.springframework.webflow.test.execution.AbstractFlowExecutionTests.startFlow(AbstractFlowExecutionTests.java:121) 
    at com.shc.ecom.test.usr.TestRegEnroll.testStartFlow(TestRegEnroll.java:84) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:483) 
    at junit.framework.TestCase.runTest(TestCase.java:154) 
    at junit.framework.TestCase.runBare(TestCase.java:127) 
    at junit.framework.TestResult$1.protect(TestResult.java:106) 
    at junit.framework.TestResult.runProtected(TestResult.java:124) 
    at junit.framework.TestResult.run(TestResult.java:109) 
    at junit.framework.TestCase.run(TestCase.java:118) 
    at junit.framework.TestSuite.runTest(TestSuite.java:208) 
    at junit.framework.TestSuite.run(TestSuite.java:203) 
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
Caused by: org.springframework.binding.expression.EvaluationException: An ELException occurred getting the value for expression 'flowScope.regform.sid' on context [class org.springframework.webflow.engine.impl.RequestControlContextImpl] 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:92) 
    at org.springframework.webflow.action.SetAction.doExecute(SetAction.java:55) 
    at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) 
    at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) 
    ... 31 more 
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'sid' cannot be found on null 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:220) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) 
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) 
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) 
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84) 
    ... 35 more 

WebflowのXMLをやって何の間違いを理解する助けてくださいすることができます見つけることができませんでしたサブフロー>

<?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.4.xsd" 
    start-state="confirmsuccess"> 

    <var name="regform" class="com.test.ecoms.user.form.Regform" /> 
    <!-- <input-mapper> <input-attribute name="service" /> <input-attribute 
     name="regform" /> <input-attribute name="success" /> </input-mapper> <start-state 
     idref="confirmsuccess" /> --> 

    <input name="service" /> 
    <input name="regform" /> 
    <input name="success" /> 

    <decision-state id="confirmsuccess"> 
     <if test="flowScope.success!=null" then="serviceticketvalidation" 
      else="saveQueryParamInSession" /> 
    </decision-state> 
    <decision-state id="serviceticketvalidation"> 
     <if test="flowScope.success=='yes'" then="sywNumAction" else="ssoerrorredirect" /> 
    </decision-state> 


    <!-- <action-state id="enterCustInfo"> <action bean="regEnrollFormAction" 
     method="setupForm" > </action> <transition on="success" to="renderform"/> 
     </action-state> --> 

    <!-- save query parameter in session --> 
    <action-state id="saveQueryParamInSession"> 
     <evaluate expression="saveQueryParamInSession" /> 
     <transition on="success" to="renderform" /> 
    </action-state> 


    ...... 
</flow> 

テストケース

public class TestRegEnroll extends AbstractXmlFlowExecutionTests { 

    private SavingQueryParamInSessionAction savingQueryParamInSession; 
    private Event event; 
    RequestContext contextRequest; 


    protected void setUp() { 
     savingQueryParamInSession = EasyMock.createMock("savingQueryParamInSession", 
       SavingQueryParamInSessionAction.class); 
     event = EasyMock.createMock("event",Event.class); 
     contextRequest = EasyMock.createMock("request",RequestContext.class); 

    } 

    @Override 
    protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) { 
     return resourceFactory.createFileResource("src/main/webapp/WEB-INF/usr/flows/regEnroll-flow.xml"); 
    } 

    @Override 
    protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { 
     builderContext.registerBean("savingQueryParamInSession", savingQueryParamInSession); 


    } 

    public void testStartFlow() throws Exception { 


     MockExternalContext externalContext = new MockExternalContext(); 
     MockRequestContext context=new MockRequestContext(); 
     MutableAttributeMap input = new LocalAttributeMap(); 
     input.put("success", "renderform"); 
     input.put("flowScope.regform.sid", 3); 
     input.put("clienthost", "qa.ecom.sears.com:4380"); 


     EasyMock.expect(savingQueryParamInSession.doExecute(contextRequest)).andReturn(event); 
     EasyMock.replay(savingQueryParamInSession); 

     startFlow(input, externalContext); 
     assertCurrentStateEquals("renderform"); 


    } 

    public void testStartRenderFormFlow() throws Exception { 

    } 

    private Regform createRegistrationForm() { 
     Regform regform = new Regform(); 
     regform.setEmail("[email protected]"); 
     regform.setLname("mike"); 
     regform.setFname("sun"); 
     regform.setPassword("test11"); 
     regform.setSid("3"); 
     regform.setZip("60179"); 
     return regform; 
    } 

} 

ModifyTestCase

public class TestRegEnrollFlow extends AbstractXmlFlowExecutionTests { 

    SavingQueryParamInSessionAction savingQueryParamInSessionAction = new SavingQueryParamInSessionAction(); 

    @Override 
    protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resourceFactory) { 
     return resourceFactory.createFileResource("src/main/webapp/WEB-INF/usr/flows/regEnroll-flow.xml"); 
    } 

    @Override 
    protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { 
     //I Have tried even mocking using Easy Mock 
     /*savingQueryParamInSession = EasyMock.createMock("savingQueryParamInSession", 
       SavingQueryParamInSessionAction.class); 
     event = EasyMock.createMock("event",Event.class); 
     contextRequest = EasyMock.createMock("request",RequestContext.class);*/ 
     builderContext.registerBean("savingQueryParamInSession", savingQueryParamInSessionAction); 

     builderContext.registerBean("sywNumSetupAction", new SywNumSetupAction()); 
     builderContext.registerBean("ssoGatewayService", new SSOGatewayServiceImpl()); 
     builderContext.registerBean("regEnrollFormAction", new RegEnrollFormAction()); 

    } 

    public void testAction() { 
     MockExternalContext ctx = new MockExternalContext(); 
     MutableAttributeMap input = new LocalAttributeMap(); 
     input.put("service", ""); 
     input.put("regForm", createRegistrationForm()); 
     //this is the line where we are changing the state flow 
     input.put("success", "success"); 
     startFlow(input, ctx); 

     assertFlowExecutionActive(); 
     assertCurrentStateEquals("renderform"); 
     Object regForm = getFlowAttribute("regForm"); 
     assertTrue(regForm instanceof Regform); 
     assertTrue(((Regform) regForm).getLname().equals("mike")); 
    } 

    private Regform createRegistrationForm() { 
     Regform regform = new Regform(); 
     regform.setEmail("[email protected]"); 
     regform.setLname("mike"); 
     regform.setFname("sun"); 
     regform.setPassword("test11"); 
     regform.setSid("3"); 
     regform.setZip("60179"); 
     return regform; 
    } 

} 

エラー

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [[email protected] targetAction = [[email protected] expression = saveQueryParamInSession, resultExpression = [null]], attributes = map[[empty]]] in state 'saveQueryParamInSession' of flow 'regEnroll-flow' -- action execution attributes were 'map[[empty]]' 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60) 
    at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Transition.execute(Transition.java:228) 
    at org.springframework.webflow.engine.DecisionState.doEnter(DecisionState.java:51) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Flow.start(Flow.java:527) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:368) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:223) 
    at org.springframework.webflow.test.execution.AbstractFlowExecutionTests.startFlow(AbstractFlowExecutionTests.java:121) 
    at com.shc.ecom.test.usr.TestRegEnrollFlow.testAction(TestRegEnrollFlow.java:52) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:483) 
    at junit.framework.TestCase.runTest(TestCase.java:154) 
    at junit.framework.TestCase.runBare(TestCase.java:127) 
    at junit.framework.TestResult$1.protect(TestResult.java:106) 
    at junit.framework.TestResult.runProtected(TestResult.java:124) 
    at junit.framework.TestResult.run(TestResult.java:109) 
    at junit.framework.TestCase.run(TestCase.java:118) 
    at junit.framework.TestSuite.runTest(TestSuite.java:208) 
    at junit.framework.TestSuite.run(TestSuite.java:203) 
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 
Caused by: org.springframework.binding.expression.PropertyNotFoundException: Property not found 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:87) 
    at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75) 
    at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) 
    at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) 
    ... 28 more 
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'saveQueryParamInSession' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl' - maybe not public? 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81) 
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) 
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84) 
    ... 32 more 

答えて

0

input.put("flowScope.regform.sid", 3); 

を置き換えます私は別のエラーが、私は上記のエラーをコピーしたアクション状態の実行に関連した来ているあなたは、私はこの原因を教えてくださいすることができますし、また、あなたがMockRequestContext

+0

感謝上記の最後のエラーは、 "success"をnullに割り当てて、 "succuess"に "value"を割り当てると終了状態になります。メモを作るにはsaveQueryParamSesssionがイベント( "succes")を返しています – henrycharles

+0

外部コンテキストについて説明してくださいすることができますがあることを持っている入力用件の

input.put("regform", createRegistrationForm()); 
henrycharles

+0

@ rptmat55私は正常に1つのテストケースを走らせましたが、もう一度私は1つの問題にこだわってしまいましたか?この投稿で見てくださいhttp://stackoverflow.com/questions/39010531 /不可能な取得可能なフロースコープ可変から1つの状態への移行から別の状態へ – henrycharles

関連する問題