View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.sftp;
8   
9   import org.mule.transport.AbstractMuleMessageFactoryTestCase;
10  import org.mule.util.FileUtils;
11  
12  import java.io.File;
13  
14  import static org.junit.Assert.assertTrue;
15  
16  public abstract class AbstractSftpMuleMessageFactoryTestCase extends AbstractMuleMessageFactoryTestCase
17  {
18      protected File tempFile;
19      private File tmpDirectory;
20  
21      protected byte[] testBytes;
22      protected String testString;
23  
24      @Override
25      protected void doSetUp() throws Exception
26      {
27          super.doSetUp();
28  
29          createWorkDirectory();
30          tempFile = File.createTempFile("simple", ".mule", tmpDirectory);
31          testBytes = "testing bytes".getBytes();
32          testString = "testing string";
33      }
34  
35      private void createWorkDirectory()
36      {
37          // The working directory is deleted on tearDown (see
38          // AbstractMuleTestCase.disposeManager)
39          tmpDirectory = FileUtils.newFile(muleContext.getConfiguration().getWorkingDirectory(), "tmp");
40          if (!tmpDirectory.exists())
41          {
42              assertTrue(tmpDirectory.mkdirs());
43          }
44      }
45  
46      @Override
47      protected Object getValidTransportMessage()
48      {
49          return testBytes;
50      }
51  
52      @Override
53      protected Object getUnsupportedTransportMessage()
54      {
55          return new File("fooFile");
56      }
57  }