java多行字符串在有理函数测试中表现奇怪

发布于 2024-12-06 17:39:50 字数 1812 浏览 2 评论 0原文

我只是想知道为什么它会这样。

在IBM RFT 6.x版本中集成了eclipse IDE。 我运行以下几行以从另一个程序获取文本输出。

String Text = "";
String Text_Value = "";

Text = (String) outputText().getProperty(".value");
Text_Value = (String) outputText().getProperty(".value");

outputText().getProperty(".value") 捕获的原始输出是

2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup sc11
************************************************************
 CPU0  Usage                    : 3.2%
 CPU1  Usage                    : 6.29%
 Smooth CPU Usage               : 4.65%
 Real CPU Usage                 : 4.65%
------------------------------------------------------------
 CPU Usage Sample Rate          : 2(s)
 CPU OverLoad Level[1]          : 10%
 CPU OverLoad Level[2]          : 20%
 CPU OverLoad Level[3]          : 90%
 CPU OverLoad Level[4]          : 95%
 CPU Peak Usage                 : 99.88%
 CPU Peak Usage Time            : 2008-10-31 20:12:54
------------------------------------------------------------
 The History Real CPU Usage     :
 No   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU
 0     3.87   4.76   4.72   4.76   4.76   4.69   4.65   4.65
 1     4.69   4.65
************************************************************

,这里发生了奇怪的事情。 我得到了字符串变量

Text = "\r\n2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup sc11"

Text_Value = "\r\n2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup     sc11\r\n************************************************************\r\n.....4.69   4.65
          \r\n************************************************************"

Text_Value 正是我想要的,但文本总是在“show cpup sc11”中被截断。

预计双线也会做同样的事情。

当我尝试程序的其他输出时。这不会发生。这两个变量是相同的。

I just wonder why it act this way.

In IBM RFT 6.x version integrated with a eclipse IDE .
I run the follow lines to get a text output from another program.

String Text = "";
String Text_Value = "";

Text = (String) outputText().getProperty(".value");
Text_Value = (String) outputText().getProperty(".value");

the original output captured by outputText().getProperty(".value") is

2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup sc11
************************************************************
 CPU0  Usage                    : 3.2%
 CPU1  Usage                    : 6.29%
 Smooth CPU Usage               : 4.65%
 Real CPU Usage                 : 4.65%
------------------------------------------------------------
 CPU Usage Sample Rate          : 2(s)
 CPU OverLoad Level[1]          : 10%
 CPU OverLoad Level[2]          : 20%
 CPU OverLoad Level[3]          : 90%
 CPU OverLoad Level[4]          : 95%
 CPU Peak Usage                 : 99.88%
 CPU Peak Usage Time            : 2008-10-31 20:12:54
------------------------------------------------------------
 The History Real CPU Usage     :
 No   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU   %CPU
 0     3.87   4.76   4.72   4.76   4.76   4.69   4.65   4.65
 1     4.69   4.65
************************************************************

and the strange thing happens here.
I got the string variable

Text = "\r\n2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup sc11"

and

Text_Value = "\r\n2011-09-27 19:11:05.996 [Process ID:0x00000000] show cpup     sc11\r\n************************************************************\r\n.....4.69   4.65
          \r\n************************************************************"

The Text_Value is exactly what I want but the Text is always be cut off here in "show cpup sc11".

the twoline is expected to do the same thing.

when i try other output of the program.This would not happen.The two variable is same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁人与我共长歌 2024-12-13 17:39:51

应该是同步问题。由于控件未完全填充,您的 Text 被切断。执行 Text_Value 行时,outputText() 对象已完全填充,因此 Text_Value 不会被截断。您可以通过在 Text 行之前插入 sleep(10) 命令来证明这一点。将值 10 更改为足以使 outputText() 控件完全填充的任意秒数。

It's probably a synchronization issue. Your Text is cut off because the control is not quite populated. By the time Text_Value line is executed, the outputText() object is populated fully, so Text_Value is not truncated. You could prove this by inserting a sleep(10) command prior to the Text line. Change the value 10 to whatever arbitrary number of seconds is long enough for the outputText() control to have been fully populated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文