English 中文(简体)
无法在MuleSoft Munit模块中选取“Insertlogs”模块
原标题:Not able to Mock "Insert Logs" Module in MuleSoft Munit

我在尝试下行不通,但在试办案时却低于例外。

Error : [module-alliant-logger.xml:52]: Cannot use error type ALLIANT-LOGGER:PARSING : namespace already exists. Caused by: org.mule.runtime.core.api.config.ConfigurationException: [module-alliant-logger.xml:52]: Cannot use error type ALLIANT-LOGGER:PARSING : namespace already exists.

Munit flow:

<munit:test name="munit-demo-test-suiteTest" doc:id="5133bc2a-1b4a-4efa-bc9e-a293bd3f0764" >
    <munit:behavior>
        <munit-tools:mock-when doc:name="Mock when transform" doc:id="b0513fbf-a209-494b-b39f-c5c20f69256a" processor="ee:transform">
            <munit-tools:with-attributes >
                <munit-tools:with-attribute whereValue="Transform Message" attributeName="doc:name" />
                <munit-tools:with-attribute whereValue="b228d101-a703-4824-8687-4da4f4792104" attributeName="doc:id" />
            </munit-tools:with-attributes>
            <munit-tools:then-return >
                <munit-tools:payload value= #[%dw 2.0&#10;output application/json&#10;---&#10;{&#10;    "ErrorSource" : "Unknown-ErrorSource",&#10; "ErrorDescription":"Unknown-ErrorDescription"&#10;}]  mediaType="application/json" />
            </munit-tools:then-return>
        </munit-tools:mock-when>
        <munit-tools:mock-when doc:name="Mock when : logger:insert-logs" doc:id="86d27f7c-5560-4094-8b3b-3435e08122e3" processor="alliant-logger:insert-logs">
            <munit-tools:with-attributes >
                <munit-tools:with-attribute whereValue="5bc0671a-6ccf-4ac0-8077-94e918f50c44" attributeName="doc:id" />
                <munit-tools:with-attribute whereValue="Alliant_logger_Config" attributeName="config-ref" />
            </munit-tools:with-attributes>
            <munit-tools:then-return >
                <munit-tools:payload value="Success" mediaType="application/octet-stream" />
                <munit-tools:attributes value= #[{&#10;  "headers": {&#10;    "content-type": "application/json",&#10;    "user-agent": "PostmanRuntime/7.36.1",&#10;    "accept": "*/*",&#10;    "cache-control": "no-cache",&#10;    "postman-token": "c30d4d25-4bf0-4dd8-b118-addddbabae35",&#10;    "host": "localhost:8083",&#10;    "accept-encoding": "gzip, deflate, br",&#10;    "connection": "keep-alive",&#10;    "content-length": "69"&#10;  },&#10;  "clientCertificate": null,&#10;  "method": "POST",&#10;  "scheme": "http",&#10;  "queryParams": {},&#10;  "requestUri": "/api/Create",&#10;  "queryString": "",&#10;  "version": "HTTP/1.1",&#10;  "maskedRequestPath": "/Create",&#10;  "listenerPath": "/api/*",&#10;  "relativePath": "/api/Create",&#10;  "localAddress": "/127.0.1.1:8083",&#10;  "uriParams": {},&#10;  "rawRequestUri": "/api/Create",&#10;  "rawRequestPath": "/api/Create",&#10;  "remoteAddress": "/127.0.1.1:55537",&#10;  "requestPath": "/api/Create"&#10;}]  />
            </munit-tools:then-return>
        </munit-tools:mock-when>
    </munit:behavior>
    <munit:execution>
        <munit:set-event doc:name="Set Event" doc:id="ec2d7f54-dcf9-4a46-ba45-aa7a5952be0d">
            <munit:payload value= #[%dw 2.0&#10;output application/json&#10;---&#10;{&#10;  "ErrorSource": "Source",&#10;  "ErrorDescription": "Description"&#10;}]  mediaType="application/json" />
        </munit:set-event>
        <flow-ref doc:name="Flow Reference" doc:id="e306b636-d827-4d51-a7b1-28e2730200a0" name="munit-demoFlow1"/>
    </munit:execution>
    <munit:validation>
        <munit-tools:assert-that doc:name="Assert that" doc:id="c7e2f3d0-fdfb-4f63-95ec-a97bf3f5b50e" expression="#[payload]" is="#[MunitTools::notNullValue()]"/>
    </munit:validation>
</munit:test>

下面是主要流动,我想 mo。 我创建了一个单独的Mule应用程序以记录错误。 如今,这一应用作为这一转变中的单元(独立性)。 “Insertlog”

<flow name="munit-demoFlow1"
    doc:id="945f8d10-a965-46ef-a2a8-8156afe41965">
    <http:listener doc:name="Listener"
        doc:id="767336a9-5a33-4913-b55e-41f94f7a6625"
        config-ref="HTTP_Listener_config" path="/LoggerTesting" />
    <ee:transform doc:name="Transform Message"
        doc:id="b228d101-a703-4824-8687-4da4f4792104">
        <ee:message>
            <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
    "ErrorSource" : "Unknown-ErrorSource",
    "ErrorDescription":"Unknown-ErrorDescription"
}]]></ee:set-payload>
        </ee:message>
    </ee:transform>
    <alliant-logger:insert-logs
        doc:name="Insert Logs" doc:id="5bc0671a-6ccf-4ac0-8077-94e918f50c44"
        config-ref="Alliant_logger_Config" />
    <set-payload doc:name="Set Payload"
        doc:id="94400a58-db42-4a7e-b4db-42a2242d508b"
        value="#[%dw 2.0&#10;output application/java&#10;---&#10;if(payload as String ==  Success  as String) &#10;  its working &#10;else&#10;  its not working ]" />
</flow>

Below request/response passing in "Insert Log". Insert-log

Alliantlogger为模块。

“Alliant

I am using localhost URL to access it. I run two application parallel so, its working fine. Alliant Logger Configuration

我知道,Error从“Insertlog”中投下,但无法得出这一说法。 由于这一错误,我无法回避测试案例。 如果我评论“Insertlog”的话,那是工作上的罚款,但我想谈谈“Insertlog”。

问题回答

I am facing the same error with connectors mocking in MUnit. "Cannot use error type xxxxxxx:PARSING : namespace already exists." In Mule Runtime 4.4 is no problem, but the error occurs in 4.5 and 4.6.





相关问题
Mule ESB - How to get MimeMessage instead of MimeBodyPart?

I m trying to get the FROM email address in Mule ESB. I m getting the retrieved object as MimeBodyPart, I d like to have MimeMessage instead. How to do this? Any solution - either in Mule or Java is ...

JaxWsProxyFactoryBean for Mule CXF transport?

I am new to mule. Are there any way to call CXF based web services using JaxWsProxyFactoryBean? It will be nice to reuse Java interface instead of wsdl files. With CXF we can simply reuse our java ...

Drools, spring and mule

Has anyone combined these technologies? Could you share lessons learnt?

How to keep inbound host with custom Mule ESB router

I created a custom router with one endpoint. The custom router looks up the destination of the endpoint based on the URL parameters of the inbound URL. I have an example of this up and running, and I ...

热门标签