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