View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.file;
8   
9   import org.mule.api.endpoint.InboundEndpoint;
10  import org.mule.api.service.Service;
11  import org.mule.api.transport.MessageReceiver;
12  import org.mule.tck.MuleTestUtils;
13  import org.mule.transport.AbstractMessageReceiverTestCase;
14  import org.mule.util.FileUtils;
15  
16  import com.mockobjects.dynamic.Mock;
17  
18  import java.io.File;
19  
20  public class FileMessageReceiverTestCase extends AbstractMessageReceiverTestCase
21  {
22      File read = FileUtils.newFile("testcasedata/read");
23      File move = FileUtils.newFile("testcasedata/move");
24      Mock session = MuleTestUtils.getMockSession();
25  
26      public void testReceiver() throws Exception
27      {
28          // FIX A bit hard testing receive from a unit simple as we need to reg
29          // listener etc.
30          // file endpoint functions tests for this
31      }
32  
33      public MessageReceiver getMessageReceiver() throws Exception
34      {
35          endpoint.getConnector().start();
36          Mock mockComponent = new Mock(Service.class);
37          mockComponent.expectAndReturn("getInboundRouter", null);
38          mockComponent.expectAndReturn("getResponseRouter", null);
39          read.deleteOnExit();
40          move.deleteOnExit();
41  
42          return new FileMessageReceiver(endpoint.getConnector(), (Service)mockComponent.proxy(),
43              endpoint, read.getAbsolutePath(), move.getAbsolutePath(), null, 1000);
44      }
45  
46      public InboundEndpoint getEndpoint() throws Exception
47      {
48          return muleContext.getEndpointFactory().getInboundEndpoint("file://./simple");
49      }
50  }