Search code examples
citrus-framework

Why are some linux commands not executable in Citrus like PWD


I am connecting to Linux server using SFTP protocol using citrus FTP component. the following command that was provide in the documentation was executing fine.

<send endpoint="ftpClient">
  <message>
    <payload>
      <ftp:command>
        <ftp:signal>MKD</ftp:signal>
        <ftp:arguments>test</ftp:arguments>
      </ftp:command>
    </payload>
  </message>
</send> 

but when I provide another command like PWD as shown below

<send endpoint="ftpClient">
      <message>
        <payload>
          <ftp:command>
            <ftp:signal>PWD</ftp:signal>
            <ftp:arguments></ftp:arguments>
          </ftp:command>
        </payload>
      </message>
    </send> 

I am getting error. but when i execute the above command using SSH protocol the command was executing fine

<send endpoint="sftpClient">
  <message>
    <payload>
      <ftp:command>
        <ftp:signal>pwd</ftp:signal>
        <ftp:arguments></ftp:arguments>
      </ftp:command>
    </payload>
  </message>
</send>

I am unable to figure out the problem and another thing is how execute two commands in a sequence using citrus ftp component for example ex: I want to move to a particular path and have see the size of files in that path for this we have to use "CD" command first and next we have "ls -l" how can I achive this using citrus. Here is the stack trace of the error

 TEST FAILED ssh_connection_Test <com.consol.citrus.samples.todolist> Nested exception is: 
com.consol.citrus.exceptions.CitrusRuntimeException: Failed to read ftp XML object from source
    at com.consol.citrus.ftp.message.FtpMarshaller.unmarshal(FtpMarshaller.java:120)
    at com.consol.citrus.ftp.message.FtpMessage.getCommand(FtpMessage.java:429)
    at com.consol.citrus.ftp.message.FtpMessage.getPayload(FtpMessage.java:384)
    at com.consol.citrus.ftp.client.FtpClient.send(FtpClient.java:108)
    at com.consol.citrus.actions.SendMessageAction.doExecute(SendMessageAction.java:125)
    at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
    at com.consol.citrus.TestCase.executeAction(TestCase.java:234)
    at com.consol.citrus.TestCase.doExecute(TestCase.java:153)
    at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
    at com.consol.citrus.Citrus.run(Citrus.java:403)
    at com.consol.citrus.testng.AbstractTestNGCitrusTest.invokeTestMethod(AbstractTestNGCitrusTest.java:124)
    at com.consol.citrus.testng.AbstractTestNGCitrusTest.run(AbstractTestNGCitrusTest.java:108)
    at com.consol.citrus.testng.AbstractTestNGCitrusTest.run(AbstractTestNGCitrusTest.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:212)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 37; cvc-enumeration-valid: Value 'PWD' is not facet-valid with respect to enumeration '[OPEN, ABOR, ACCT, ALLO, APPE, CDUP, CWD, DELE, EPRT, EPSV, FEAT, HELP, LIST, MDTM, MFMT, MKD, MLSD, MLST, MODE, NLST, NOOP, PASS, PASV, PORT, PWD, QUIT, REIN, REST, RETR, RMD, RNFR, RNTO, SITE, SMNT, STAT, STOR, STOU, STRU, SYST, TYPE, USER]'. It must be a value from the enumeration.]
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:909)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:782)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:751)
    at com.consol.citrus.ftp.message.FtpMarshaller.unmarshal(FtpMarshaller.java:95)
    ... 36 more

Solution

  • The error information you are giving is not related to the PWD signal. It fails because you send the signal ls -ltr which is not a supported signal when using the FTP client.

    In case you want to list the files with FTP on the server you need to use the LIST signal.

    Please do not mix up SSH and FTP commands and signals. Of course you can also open a SSH session and fire up the list files command with ls. But then you need to use the Citrus SSH client.