View Javadoc

1   /*
2    * $Id: FileAppendEndpointTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
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.test.integration.transport.file;
12  
13  import org.mule.module.client.MuleClient;
14  import org.mule.util.FileUtils;
15  
16  import java.io.File;
17  import java.util.Arrays;
18  import java.util.Collection;
19  
20  import org.junit.Test;
21  import org.junit.runners.Parameterized.Parameters;
22  
23  import static org.junit.Assert.assertFalse;
24  
25  public class FileAppendEndpointTestCase extends FileAppendConnectorTestCase
26  {
27      @Parameters
28      public static Collection<Object[]> parameters()
29      {
30          return Arrays.asList(new Object[][]{
31              {ConfigVariant.SERVICE,
32                  "org/mule/test/integration/providers/file/mule-fileappend-endpoint-config-service.xml"},
33              {ConfigVariant.FLOW,
34                  "org/mule/test/integration/providers/file/mule-fileappend-endpoint-config-flow.xml"}});
35      }
36  
37      public FileAppendEndpointTestCase(ConfigVariant variant, String configResources)
38      {
39          super(variant, configResources);
40      }
41  
42      @Override
43      @Test
44      public void testBasic() throws Exception
45      {
46          File myDir = FileUtils.newFile(OUTPUT_DIR);
47  
48          // output directory may not exist before dispatching to the endpoint with
49          // invalid
50          // configuration
51          File outputFile = FileUtils.newFile(myDir, OUTPUT_FILE);
52          assertFalse(outputFile.exists());
53  
54          // this should throw java.lang.IllegalArgumentException: Configuring
55          // 'outputAppend' on a
56          // file endpoint is no longer supported. You may configure it on a file
57          // connector instead.
58          MuleClient client = new MuleClient(muleContext);
59          client.dispatch("vm://fileappend", "Hello1", null);
60  
61          assertFalse(outputFile.exists());
62      }
63  }