문제

I've been trying to use a the following regular expression extractor

Reference Name: FMSFlightPlan
Regular Expression: (?s)<FMSFlightPlan>(.*?)</FMSFlightPlan>
Template: $1$
Match No. 1

to match the string between the two FMSFlightPlan tags in the XML (the number of lines between the tags varies, hence the (?s) establishing dotall mode)

<FMSFlightPlan>
6500
AN NTEST/GL 
- FPN/FN/RP:DA:LEMG:AA:LEXJ:F:BLN,N38092W003375.UN865. 
BUGIX,N42215W003381.R753.EMANU,N42575W003469 
 </FMSFlightPlan>

Several testing applications tell me that my regex is correct. However when I try to use a Beanshell Assertion to print out the captured string I get the error message:

Assertion error: true Assertion failure: false Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.io.*; //write out the data results to a file outfile = "/Users/Dani . . . '' Token Parsing Error: Lexical error at line 12, column 380. Encountered: "\n" (10), after : "\"3811\tYes\tAAR\tSTN\t835\t\t$B738\tfp,nradps,art,CCAAN,EXCD,wp00,p00\t37919\ta0\ti\t10\t0\t3\t0\t \t14\t 25/M\t0000ADF\t140785\t133806\t006979\t01:15:00\t0484\t360\t0379\t360\t0112\t 000932\tP00 \t007115\t2013-02-13T21:23:00Z\t2013-02-14T08:35:00+00:00\t000837\t00:10:00\t000000\t00:00:00\t000837\t00:10:00\t000000\t000000\t000000\t00:00:00\t000000\t00:00:00\t"

So it seems the extractor returns a string but the Beanshell Assertion doesn't recognize it as a variable. Why would this be the case after establishing dotall mode? Is there an escaping error somewhere? I also don't understand what the error message means by

Encountered: "\n" 

since there are no \n characters in the text being parsed.

I've considered using XPath extractor instead of Regular Expression extractors but have heard that this is not optimal when a lot of operations or threads are involved.

도움이 되었습니까?

해결책

(?s) - means Single line, correct? It is then hitting a \n which is a new line signal. That is probably causing the error. It is not expecting a new line character.

Could you use the regular Response Assertion? I think you can use the regex in the Patterns to test.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top