Uploaded image for project: 'MINA SSHD'
  1. MINA SSHD
  2. SSHD-158

Latest HEAD does not build on Windows

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 0.7.0
    • 0.7.0
    • None

    Description

      The tests do not pass on the latest version when run on Windows. The problem is, that the operating system paths are used for scp and sftp. The backslashes (on Windows) do not work with scp and sftp. Fix: Use slashes instead of forward slashes. Attached You can find a patch.

      Index: src/test/java/org/apache/sshd/SftpTest.java
      ===================================================================
      — src/test/java/org/apache/sshd/SftpTest.java (revision 1238412)
      +++ src/test/java/org/apache/sshd/SftpTest.java (working copy)
      @@ -147,24 +147,25 @@
      @Test
      public void testReadWriteWithOffset() throws Exception

      { File root = new File("target/scp"); - File target = new File("target/scp/out.txt"); + String unixPath = "target/scp/out.txt"; + File target = new File(unixPath); root.mkdirs(); assertTrue(root.exists()); ChannelSftp c = (ChannelSftp) session.openChannel("sftp"); c.connect(); - c.put(new ByteArrayInputStream("0123456789".getBytes()), target.getPath()); + c.put(new ByteArrayInputStream("0123456789".getBytes()), unixPath); assertTrue(target.exists()); assertEquals("0123456789", readFile("target/scp/out.txt")); - OutputStream os = c.put(target.getPath(), null, ChannelSftp.APPEND, -5); + OutputStream os = c.put(unixPath, null, ChannelSftp.APPEND, -5); os.write("a".getBytes()); os.close(); c.disconnect(); assertTrue(target.exists()); - assertEquals("01234a", readFile("target/scp/out.txt")); + assertEquals("01234a", readFile(unixPath)); target.delete(); assertFalse(target.exists()); Index: src/test/java/org/apache/sshd/ScpTest.java =================================================================== --- src/test/java/org/apache/sshd/ScpTest.java (revision 1238412) +++ src/test/java/org/apache/sshd/ScpTest.java (working copy) @@ -128,28 +128,31 @@ String data = "0123456789\n"; - File root = new File("target/scp"); - File target = new File("target/scp/out.txt"); + String unixDir = "target/scp"; + String fileName = "out.txt"; + String unixPath = unixDir + "/" + fileName; + File root = new File(unixDir); + File target = new File(unixPath); root.mkdirs(); assertTrue(root.exists()); target.delete(); assertFalse(target.exists()); - sendFile("target/scp/out.txt", "out.txt", data); + sendFile(unixPath, fileName, data); assertFileLength(target, data.length(), 5000); target.delete(); assertFalse(target.exists()); - sendFile("target/scp", "out.txt", data); + sendFile(unixDir, fileName, data); assertFileLength(target, data.length(), 5000); sendFileError("target", "scp", "0123456789\n"); - readFileError("target/scp"); + readFileError(unixDir); - assertEquals(data, readFile("target/scp/out.txt")); + assertEquals(data, readFile(unixPath)); - assertEquals(data, readDir("target/scp")); + assertEquals(data, readDir(unixDir)); target.delete(); root.delete(); @@ -167,8 +170,13 @@ final SCPClient scp_client = new SCPClient(conn); final Properties props = new Properties(); props.setProperty("test", "test-passed"); + File f = new File("target/scp/gan"); scp_client.put(toBytes(props, ""), "test.properties", "target/scp/gan"); + assertTrue(f.exists()); scp_client.put(toBytes(props, ""), "test2.properties", "target/scp/gan"); + assertTrue(f.exists()); + f.delete(); + conn.close(); }

      private byte[] toBytes(final Properties properties, final String comments) {

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            web Georg Weber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified