View Javadoc

1   /*
2    * $Id: FileMuleMessageFactoryTestCase.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.MuleMessage;
14  import org.mule.api.transport.MuleMessageFactory;
15  
16  public class FileMuleMessageFactoryTestCase extends AbstractFileMuleMessageFactoryTestCase
17  {
18      @Override
19      protected MuleMessageFactory doCreateMuleMessageFactory()
20      {
21          return new FileMuleMessageFactory(muleContext);
22      }
23  
24      @Override
25      protected Object getValidTransportMessage()
26      {
27          return tempFile;
28      }
29          
30      public void testMessageProperties() throws Exception
31      {
32          MuleMessageFactory factory = createMuleMessageFactory();
33          
34          MuleMessage message = factory.create(getValidTransportMessage(), encoding);
35          assertNotNull(message);
36          assertMessageProperties(message);
37      }
38      
39      public void testCreateMessageFromStream() throws Exception
40      {
41          MuleMessageFactory factory = createMuleMessageFactory();
42          
43          ReceiverFileInputStream stream = new ReceiverFileInputStream(tempFile, false, null);
44          MuleMessage message = factory.create(stream, encoding);
45          assertNotNull(message);
46          assertMessageProperties(message);
47      }
48  
49      private void assertMessageProperties(MuleMessage message)
50      {
51          assertEquals(tempFile.getName(), 
52              message.getOutboundProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME));
53          assertEquals(tempFile.getParent(), message.getOutboundProperty(FileConnector.PROPERTY_DIRECTORY));
54      }
55  }
56  
57