Issue Details (XML | Word | Printable)

Key: SFTP-22
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Magnus Larsson
Reporter: Magnus Larsson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
SFTP Transport Project

Add support to stop services during execution of doSetUp() methods

Created: 19/Dec/09 06:02 PM   Updated: 19/Jan/10 06:49 AM
Component/s: Test
Affects Version/s: 2.2.1-RC1
Fix Version/s: 2.2.1-RC2

Time Tracking:
Not Specified

Labels:
User impact: Medium
Similar Issues:


 Description  « Hide
To ensure a well known environement for sftp-tests we reset the sftp-endpoints to a well known state in the doSetUp() method by calling the helper method initEndpointDirectory() for each involved sftp-endpoint.

A problem that occurs from time to time is that the actual sftp-endpoints also access these endpoints during the execution of the doSetUp() method which leads to strange file operation error related to that both the initEndpointDirectory() method and the endpoints tries to handl the files. Typically a remove och delete operation fials since the file no longer exists...

It is suggested that the involved services are temporarly stopped during the execution of the initEndpointDirectory() method.
A setup method could for example look like:

@Override
  protected void doSetUp() throws Exception {
    super.doSetUp();

    Service s1 = muleContext.getRegistry().lookupService("serviceDuplicateHandlingRename");
    Service s2 = muleContext.getRegistry().lookupService("serviceDuplicateHandlingThrowException");
    s1.stop();
    s2.stop();
    
    // Set up the in & outbound directories
    initEndpointDirectory(INBOUND_ENDPOINT_NAME);
    initEndpointDirectory(OUTBOUND_ENDPOINT_NAME);

    // Set up the in & outbound directories
    initEndpointDirectory(INBOUND_ENDPOINT_NAME2);
    initEndpointDirectory(OUTBOUND_ENDPOINT_NAME2);

    s1.start();
    s2.start();
  }

An even better approach is to develop small helper method that takes a list of services and a list on endpoints and then internally does the following:
1. stops the services
2. calls initEndpointDirectory() for each endpoint
3. starts the services again.

Then the code above could be replaced by:

@Override
  protected void doSetUp() throws Exception {
    initEndpointDirectories(
    	new String[] {"serviceDuplicateHandlingRename", "serviceDuplicateHandlingThrowException"} , 
    	new String[] {INBOUND_ENDPOINT_NAME, INBOUND_ENDPOINT_NAME2, OUTBOUND_ENDPOINT_NAME, OUTBOUND_ENDPOINT_NAME2});
  }


 All   Comments   Work Log   Change History   Transitions   FishEye      Sort Order: Ascending order - Click to sort in descending order
Magnus Larsson added a comment - 19/Jan/10 06:49 AM
Done!

Applied to some tests.
Remaining tests can be modified to use this feature on a need bases.