Announcement Announcement Module
Collapse
No announcement yet.
Spring webflow test, when bean has parent attribute. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring webflow test, when bean has parent attribute.

    Hi Guys,
    i am having a hard time writing Spring Web Flow test. Any help will be much appreciated.
    Below is my test Files.

    ABC1.xml
    <bean id="accountName" parent="columnMetaData.text">
    <property name="property" value="selectable.accountName"/>
    <property name="title" value="Account Name"></property>
    <property name="sortProperty" value="accountName" />
    <property name="style"
    value="white-space: nowrap;"></property>
    </bean>

    File ABC2.xml
    <bean id="columnMetaData.text"
    class="com.common.grid.DataGridColumnMetaData">
    <property name="controlType">
    <util:constant
    static-field="com.common.grid.HtmlControlType.Text" />
    </property>
    <property name="total" value="false" />
    <property name="sorting" value="true" />
    <property name="cssClass" value="ofTxt"/>

    </bean>


    I am writing a webflow test and trying to register my bean as singleton. Code snippet is below.

    flowBeanFactory.registerSingleton("accountName", this.accountName);
    where account name is :

    private DataGridColumnMetaData accountName;
    @Before
    public void before() {
    this.accountName = EasyMock.createMock(DataGridColumnMetaData.class);
    }
    When i run test, i get an error message saying

    org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'columnMetaData.text' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:387)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:971)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :758)
    at org.springframework.beans.factory.support.Abstract BeanFactory.isFactoryBean(AbstractBeanFactory.java :755)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanNamesForType(DefaultList ableBeanFactory.java:266)
    at org.springframework.context.support.AbstractApplic ationContext.invokeBeanFactoryPostProcessors(Abstr actApplicationContext.java:505)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:362)
    at org.springframework.webflow.engine.builder.model.F lowModelFlowBuilder.createFlowApplicationContext(F lowModelFlowBuilder.java:351)
    at org.springframework.webflow.engine.builder.model.F lowModelFlowBuilder.initLocalFlowContext(FlowModel FlowBuilder.java:303)
    at org.springframework.webflow.engine.builder.model.F lowModelFlowBuilder.doInit(FlowModelFlowBuilder.ja va:148)
    at org.springframework.webflow.engine.builder.support .AbstractFlowBuilder.init(AbstractFlowBuilder.java :46)
    at org.springframework.webflow.engine.builder.FlowAss embler.assembleFlow(FlowAssembler.java:90)
    at org.springframework.webflow.test.execution.Abstrac tExternalizedFlowExecutionTests.buildFlow(Abstract ExternalizedFlowExecutionTests.java:174)
    at org.springframework.webflow.test.execution.Abstrac tExternalizedFlowExecutionTests.getFlowDefinition( AbstractExternalizedFlowExecutionTests.java:147)
    at org.springframework.webflow.test.execution.Abstrac tFlowExecutionTests.startFlow(AbstractFlowExecutio nTests.java:120)
    at org.springframework.webflow.test.execution.Abstrac tFlowExecutionTests.startFlow(AbstractFlowExecutio nTests.java:109)
    at com.fidelity.shares.web.shareholder.web.flow.Redem ptionDetailFlowTest.testStartFlow(RedemptionDetail FlowTest.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168 )
    at junit.framework.TestCase.runBare(TestCase.java:134 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:110)
    at junit.framework.TestResult.runProtected(TestResult .java:128)
    at junit.framework.TestResult.run(TestResult.java:113 )
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 32)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run( JUnit38ClassRunner.java:81)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)

    i have overridden getModelResources and register all files that have both my beans.
    code snippet is below.

    @Override
    protected FlowDefinitionResource[] getModelResources(
    final FlowDefinitionResourceFactory resourceFactory) {
    return new FlowDefinitionResource[] {
    resourceFactory
    .createFileResource("C:\\workspace\\src\\main\\res ources\\com\\ABC1.xml"),
    resourceFactory
    .createFileResource("C:\\workspace\\src\\main\\res ources\\com\\ABC2.xml") };
    }

    For the hack of it i also override configureFlowBuilderContext.

    @Override
    protected void configureFlowBuilderContext(
    final MockFlowBuilderContext builderContext) {
    builderContext.registerBean("columnMetaData.text", this.columnMetaData);
    }
    but no luck.

    it seems like test is looking at ABC1.xml to get columnMetaData.text but not able to locate it beause its in ABC2.xml.

    Please suggest if i am doing anything silly here.

    Thanks
Working...
X