Class SftpRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class SftpRule
    extends org.junit.rules.ExternalResource
    SftpSystemRule is a helper class to allow SFTP testing.
    Author:
    Ikasan Development Team
    • Constructor Summary

      Constructors 
      Constructor Description
      SftpRule()  
      SftpRule​(java.lang.String user, java.lang.String password, java.lang.String baseDir, java.lang.Integer port)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void after()
      Override to tear down your specific external resource.
      protected void before()
      Override to set up your specific external resource.
      java.lang.String getBaseDir()  
      java.io.InputStream getFile​(java.lang.String fileName)  
      java.lang.String getFileAsString​(java.lang.String fileName)  
      int getPort()  
      void putFile​(java.io.File file)  
      void putFile​(java.lang.String fileName, byte[] bytes)  
      void putFile​(java.lang.String fileName, java.lang.String content)  
      void start()
      Start the sshd.
      void stop()
      Stop the sshd.
      • Methods inherited from class org.junit.rules.ExternalResource

        apply
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SftpRule

        public SftpRule​(java.lang.String user,
                        java.lang.String password,
                        java.lang.String baseDir,
                        java.lang.Integer port)
      • SftpRule

        public SftpRule()
    • Method Detail

      • putFile

        public void putFile​(java.lang.String fileName,
                            java.lang.String content)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • putFile

        public void putFile​(java.io.File file)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • putFile

        public void putFile​(java.lang.String fileName,
                            byte[] bytes)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getFile

        public java.io.InputStream getFile​(java.lang.String fileName)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getFileAsString

        public java.lang.String getFileAsString​(java.lang.String fileName)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getPort

        public int getPort()
      • getBaseDir

        public java.lang.String getBaseDir()
      • start

        public void start()
        Start the sshd.

        The ssh will normally be started by JUnit using the before() method. This method allows the sshd to be started manually to support advanced testing scenarios.

      • stop

        public void stop()
        Stop the sshd.

        The ssh demon will normally be stopped by JUnit using the after() method. This method allows the sshd to be stopped manually to support advanced testing scenarios.

      • before

        protected void before()
                       throws java.lang.Throwable
        Override to set up your specific external resource.
        Overrides:
        before in class org.junit.rules.ExternalResource
        Throws:
        java.lang.Throwable - if setup fails (which will disable after
      • after

        protected void after()
        Override to tear down your specific external resource.
        Overrides:
        after in class org.junit.rules.ExternalResource