为什么某些 linux 命令在 Citrus 中无法执行,例如 PWD
Why are some linux commands not executable in Citrus like PWD
我正在使用 Citrus 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 组件按顺序执行两个命令,例如:我想移动到特定路径并查看大小该路径中的文件为此我们必须首先使用 "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
您提供的错误信息与PWD信号无关。失败是因为您发送的信号 ls -ltr
在使用 FTP 客户端时不受支持。
如果您想在服务器上列出带有 FTP 的文件,您需要使用 LIST
信号。
请不要混淆 SSH 和 FTP 命令和信号。当然,您也可以打开 SSH 会话并使用 ls
启动列表文件命令。但是你需要使用 Citrus SSH 客户端。
我正在使用 Citrus 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 组件按顺序执行两个命令,例如:我想移动到特定路径并查看大小该路径中的文件为此我们必须首先使用 "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
您提供的错误信息与PWD信号无关。失败是因为您发送的信号 ls -ltr
在使用 FTP 客户端时不受支持。
如果您想在服务器上列出带有 FTP 的文件,您需要使用 LIST
信号。
请不要混淆 SSH 和 FTP 命令和信号。当然,您也可以打开 SSH 会话并使用 ls
启动列表文件命令。但是你需要使用 Citrus SSH 客户端。