1   /*
2    * $Id: FileAppendEndpointTestCase.java 12332 2008-07-14 20:30:57Z 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.test.integration.transport.file;
12  
13  import org.mule.api.transport.DispatchException;
14  import org.mule.module.client.MuleClient;
15  import org.mule.util.FileUtils;
16  
17  import java.io.File;
18  import java.io.FileInputStream;
19  
20  public class FileAppendEndpointTestCase extends FileAppendConnectorTestCase
21  {
22      public void testBasic() throws Exception
23      {
24          String myDirName = "myout";
25          String myFileName = "out.txt";
26          FileInputStream myFileStream = null;
27  
28          // make sure there is no directory and file
29          File myDir = FileUtils.newFile(myDirName);
30          if (myDir.isDirectory())
31          {
32              // Delete Any Existing Files
33              File[] files = myDir.listFiles();
34              for (int i = 0; i < files.length; i++)
35              {
36                  assertTrue(files[i].delete());
37              }
38              // This may fail if this directory contains other directories.
39              assertTrue(myDir.delete());
40          }
41          try
42          {
43              assertFalse(FileUtils.newFile(myDir, myFileName).exists());
44  
45              MuleClient client = new MuleClient();
46              client.send("vm://fileappend", "Hello1", null);
47              fail("Expected exception: java.lang.IllegalArgumentException: configuring outputAppend on the file endpoint is no longer support. You can configure a the File connector instead.");
48          }
49          catch (Exception e)
50          {
51              // java.lang.IllegalArgumentException: configuring outputAppend on the
52              // file endpoint is no longer support. You can configure a the File
53              // connector instead.
54              assertEquals(DispatchException.class, e.getClass());
55          }
56  
57      }
58  
59      protected String getConfigResources()
60      {
61          return "org/mule/test/integration/providers/file/mule-fileappend-endpoint-config.xml";
62      }
63  }