Trying to use MUnit's DB Server to mock a database table using a CSV file. Problem is that that I am getting table not found errors.
I'm following these two articles:
Running the sample from the help.mulesoft.com article presents the same error.
How do I get the MUnit DB Server to create table from the CSV file?
Here is the test and config
<dbserver:config name="MUnit_DB_Server_Config" doc:name="MUnit DB Server Config" doc:id="c861f371-037e-4c90-92ab-d8affc693bb6" >
<dbserver:connection csv="EP0001F1.csv" database="DEV" connectionStringParameters="MODE=DB2" />
</dbserver:config>
<db:config name="Test_Database_Config" doc:name="Database Config" doc:id="7b8b820d-f517-498e-8d3c-92ee7a09fe35" >
<db:generic-connection url="${db.url}" driverClassName="${db.driver}" />
</db:config>
<munit:test name="get:\(country)\associates\workforce\links:associate-workforce-link-sapi-config-200-application\json-FlowTest" description="Verifying functionality of [get:\(country)\associates\workforce\links:associate-workforce-link-sapi-config-200-application\json]">
<munit:enable-flow-sources>
<munit:enable-flow-source value="associate-workforce-link-sapi-main" />
<munit:enable-flow-source value="get:\(country)\associates\workforce\links:associate-workforce-link-sapi-config" />
</munit:enable-flow-sources>
<munit:behavior>
<set-variable variableName="country" value="#['US']" doc:name="country" />
</munit:behavior>
<munit:execution>
<http:request config-ref="HTTP_Request_Configuration" method="GET" path="#['/$(vars.country)/associates/workforce/links']" responseTimeout="30000">
<http:headers><![CDATA[#[{"Accept":"application/json"}]]]></http:headers>
</http:request>
</munit:execution>
<munit:validation>
<munit-tools:assert-that expression="#[attributes.statusCode]" is="#[MunitTools::equalTo(200)]" message="The HTTP Status code is not correct!" doc:name="Assert That Status Code is 200" />
<munit-tools:assert-that expression="#[output application/java ---write(payload, 'application/json') as String]" is="#[MunitTools::equalTo(MunitTools::getResourceAsString('scaffolder/response/get_200_{country}_associates_workforce_links_application_json.json'))]" message="The response payload is not correct!" doc:name="Assert That - Payload is Expected" />
</munit:validation>
</munit:test>
Properties
db:
url: "jdbc:h2:mem:DEV;DB_CLOSE_DELAY=-1"
driver: "org.h2.Driver"
db-config:
name: "Test_Database_Config"
The error I am getting is
ERROR 2019-12-26 09:58:48,394 [[MuleRuntime].io.09: [associate-workforce-link-sapi].GetLinks.BLOCKING @4d5314c4] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : Table "EP0001F1" not found; SQL statement:
select * from EP0001F1 order by EPDRC desc [42102-166].
Error type : DB:QUERY_EXECUTION
Element : GetLinks/processors/1 @ associate-workforce-link-sapi:implementation.xml:11 (Select)
Element XML : <db:select doc:name="Select" doc:id="9b7e9a39-10bf-44ca-a7af-eaa5b0189ece" config-ref="${db-config.name}" maxRows="100">
<db:sql>select * from EP0001F1 order by EPDRC desc</db:sql>
</db:select>
The CSV file gets copied to the test-classes folder
And I know the h2 driver is being used (as opposed to the actual driver) as the exception cause is from org.h2.jdbc.
are you running with Mule 4.2.2? Thre is an issue in that patch version of the runtime causing this problem. If you run your tests with Mule 4.2.1 it should work, you can change the mule-artificat.json to require 4.2.1 as the minMuleVersion and in the MUnit Run Configuration also set the Runtime version to 4.2.1. All the rest seems to be correct.