为什么某些Linux命令无法在Citrus中执行,例如PWD

时间:2018-10-01 10:35:07

标签: citrus-framework

我正在使用柑橘类FTP组件使用SFTP协议连接到Linux服务器。文档中提供的以下命令运行良好。

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

但是当我提供如下所示的PWD之类的命令时

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

我遇到错误。但是当我使用SSH协议执行上述命令时,该命令执行得很好

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

我无法找出问题所在,另一件事是如何使用柑橘ftp组件依次执行两个命令,例如ex:我想移至特定路径并为此查看该路径中文件的大小我们必须首先使用“ CD”命令,然后我们必须使用“ ls -l”,如何使用柑橘来达到此目的。   这是错误的堆栈跟踪

 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

1 个答案:

答案 0 :(得分:1)

您提供的错误信息与PWD信号无关。之所以失败,是因为使用FTP客户端时发送的信号ls -ltr不受支持。

如果要在服务器上使用FTP列出文件,则需要使用LIST信号。

请不要混淆SSH和FTP命令和信号。当然,您也可以打开SSH会话并使用ls启动list files命令。但是然后您需要使用Citrus SSH客户端。