View Javadoc

1   /*
2    * $Id: FileMessageReceiverTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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      public MessageReceiver getMessageReceiver() throws Exception
38      {
39          endpoint.getConnector().start();
40          Mock mockComponent = new Mock(Service.class);
41          mockComponent.expectAndReturn("getInboundRouter", null);
42          mockComponent.expectAndReturn("getResponseRouter", null);
43          read.deleteOnExit();
44          move.deleteOnExit();
45  
46          return new FileMessageReceiver(endpoint.getConnector(), (Service)mockComponent.proxy(),
47              endpoint, read.getAbsolutePath(), move.getAbsolutePath(), null, 1000);
48      }
49  
50      public InboundEndpoint getEndpoint() throws Exception
51      {
52          return muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint("file://./simple");
53      }
54  }