Currently when writing tests where we need to be sure that a file is fully processed we force the test to "sleep" for a time period sufficient for the background processing. This leads to both non robust test code and/or tests that take unnecessary long time to be executed.
Instead of forcing the test code to "sleep" a helper method that uses Mule ESB internal notification mechanism could listen for internal delivery notifications to detect when the background processing is complete and allow the test code to continue immediately after the background processing is complete.
Example of current test code:
// Send an file to the SFTP server, which the inbound-endpoint then can pick up
muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME) + "?connector=sftpCustomConnector", TEST_MESSAGE, fileNameProperties);
// TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
// for example since we dont have the TestComp
Thread.sleep(10000);
...continue tests here...
Currently when writing tests where we need to be sure that a file is fully processed we force the test to "sleep" for a time period sufficient for the background processing. This leads to both non robust test code and/or tests that take unnecessary long time to be executed.
Instead of forcing the test code to "sleep" a helper method that uses Mule ESB internal notification mechanism could listen for internal delivery notifications to detect when the background processing is complete and allow the test code to continue immediately after the background processing is complete.
Example of current test code:
// Send an file to the SFTP server, which the inbound-endpoint then can pick up
muleClient.dispatch(getAddressByEndpoint(muleClient, INBOUND_ENDPOINT_NAME) + "?connector=sftpCustomConnector", TEST_MESSAGE, fileNameProperties);
// TODO dont know any better way to wait for the above to finish? We cant use the same as SftpFileAgeFunctionalTestCase
// for example since we dont have the TestComp
Thread.sleep(10000);
...continue tests here...
To simplify usage of the helper method dispatchAndWaitForDelivery() but still allow for some flexibility I added a parameter-object, DispatchParameters where most parameters are optional.
...and usage of some optional parameter looks like:
DispatchParameters p = new DispatchParameters(INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME);
p.setSftpConnector("sftpCustomConnector");
dispatchAndWaitForDelivery(p);
Open issue:
The helper method dispatchAndWaitForDelivery() uses programmatic registration of message-event listeners.
To make programmatic registration of message-event listeners to work we have to add a declaration in the mule config file like:
To me registration of the bean (endpointMessageNotificationLogger) should not be required by I can't get the notification to work unless I regiter the bean...
Magnus Larsson added a comment - 10/Dec/09 03:31 AM To simplify usage of the helper method dispatchAndWaitForDelivery() but still allow for some flexibility I added a parameter-object, DispatchParameters where most parameters are optional.
Simples possible call looks like:
...and usage of some optional parameter looks like:
DispatchParameters p = new DispatchParameters(INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME);
p.setSftpConnector("sftpCustomConnector");
dispatchAndWaitForDelivery(p);
Open issue:
The helper method dispatchAndWaitForDelivery() uses programmatic registration of message-event listeners.
To make programmatic registration of message-event listeners to work we have to add a declaration in the mule config file like:
To me registration of the bean (endpointMessageNotificationLogger) should not be required by I can't get the notification to work unless I regiter the bean...
Simples possible call looks like:
dispatchAndWaitForDelivery(new DispatchParameters(INBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME));...and usage of some optional parameter looks like:
Open issue:
The helper method dispatchAndWaitForDelivery() uses programmatic registration of message-event listeners.
To make programmatic registration of message-event listeners to work we have to add a declaration in the mule config file like:
To me registration of the bean (endpointMessageNotificationLogger) should not be required by I can't get the notification to work unless I regiter the bean...