【问题标题】:Munit4 throws "org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1679456e'"Munit4 抛出“org.springframework.beans.factory.BeanCreationException:创建名称为 '(inner bean)#1679456e' 的 bean 时出错”
【发布时间】:2020-09-06 10:25:25
【问题描述】:

我尝试在我的 munit 测试中模拟一个变量;

 <munit:behavior >
            <set-payload value='xxxxx' doc:name="Set Payload" doc:id="597412dc-64c7-45e0-87c5-2e8ce3dd967e" mimeType="application/json"/>


     <munit-tools:mock-when doc:name="Mock when" doc:id="fe3ee162-0a52-4b4d-a5bf-127b42b7f6b6" processor="set-variable">
                        <munit-tools:with-attributes >
                            <munit-tools:with-attribute whereValue="ClientId" attributeName="doc:name" />
                            <munit-tools:with-attribute whereValue="clientid" attributeName="variableName" />
                        </munit-tools:with-attributes>
                        <munit-tools:then-return >
                            <munit-tools:variables >
                                <munit-tools:variable key="clientid" value="ss" />
                            </munit-tools:variables>
                        </munit-tools:then-return>
                    </munit-tools:mock-when>
    </munit:behavior>
    <munit:execution >
                <flow-ref doc:name="Flow-ref to post:\raml-main" doc:id="de9bf3d4-cd3f-42e1-89cf-621c3852634e" name="raml-main"/>
            </munit:execution>
            <munit:validation >
                <munit-tools:assert-that doc:name="Assert that" doc:id="292449c4-51e6-4135-afba-c56016b5ef7d" is="#[MunitTools::equalTo(200)]" expression="#[vars.httpStatus]" message="Different status code"/>
            </munit:validation>

但是当我运行测试时; 我明白了;

caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1679456e': FactoryBean threw exception on object creation; nested exception is org.mule.runtime.core.api.config.ConfigurationException: Element 'ss' is not defined in the Mule Registry
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:185) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:137) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:302) ~[spring-beans-4.3.17.RELEASE.jar:4.3.17.RELEASE]

...........

Caused by: org.mule.runtime.core.api.config.ConfigurationException: Element 'ss' is not defined in the Mule Registry

这是为什么呢?我选择了一个流来测试。我的测试有测试属性文件,它正在工作。 我已经定义为;

为什么我不能模拟变量?

【问题讨论】:

    标签: mule mule-studio mulesoft munit


    【解决方案1】:

    我刚刚遇到了你的问题。我一直在解决同样的问题。我相信如果你使用 value="#["ss"]" 它会起作用。我试图将 200 放入一个名为 httpStatus 的变量中,这似乎对我有用。

                    <munit-tools:variables >
                        <munit-tools:variable key="httpStatus" value="#[200]" />
                    </munit-tools:variables>    
    

    【讨论】:

      【解决方案2】:

      以下内容对我有用。我正在使用 mule 4.3 和 munit2。

      <munit-tools:variables >
        <munit-tools:variable key="clientid" value='#["ss"]' />
      </munit-tools:variables>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-25
        • 2016-06-05
        • 2020-02-21
        • 2018-04-27
        • 2020-10-20
        • 2020-11-04
        • 2021-11-11
        相关资源
        最近更新 更多