2016-08-10 4 views
1

저는 webflow에 익숙하지 않고 webflow에 대한 writting unit 테스트 케이스를 시작하고 다음과 같은 오류가 발생합니다. 테스트 상태를 결정 상태, 작업 상태 뷰 상태 및 상태 정보와 혼합하여 작성하는 데 어려움을 겪고 있습니다. far.I 이렇게 많은 가능한 방법을 시도하고 개념을 얻기 위해 고군분투하는 당신이 날 내가spring 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); 

교체 입력 16,

input.put("regform", createRegistrationForm()); 
+0

덕분에 나는 또 다른 오류가 당신이 MockRequestContext – henrycharles

+0

날이에 대한 원인을 알고도 외부 상황에 대해 설명해주십시오 수 있습니다 주시기 바랍니다 수 있습니다 내가 위의 오류를 복사 한 동작 상태의 실행에 관련된오고 있다는 것을이 위에 표시된 마지막 오류는 "success"를 null로 지정하고 "succuess"에 "value"를 지정하면 끝 상태가됩니다. 메모를 만들려면 saveQueryParamSesssion이 이벤트 ("succes")를 반환합니다. – henrycharles

+0

@ rptmat55 1 개의 테스트 케이스를 성공적으로 실행했지만 다시 한 번 문제가 발생했습니다. http://stackoverflow.com/questions/39010531/할 수없는 범위에서 얻을 수있는 흐름 범위 변수 from1 상태 전환 다른 통계 – henrycharles