简体   繁体   中英

java multi-line string behave strange in rational function test

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM