Groovy строка replaceAll не работает должным образом - PullRequest
0 голосов
/ 13 июня 2019

Hy Every!

У меня проблема с Groovy ReplaceAll в JMeter JSR223. В одном случае это работает, в другом - нет.

Уже есть trye и Sampler, и препроцессор. Но ничего не меняется.

Jmeter 5.1.1 Пробоотборник JSR223 и препроцессор JSR223

  1. Шаблон bodyData (препроцессор JSR223)
  2. Простой контроллер
  3. HTTP Sampler (HTTP-запрос)
  4. bodyData ReplaceAll (препроцессор JSR223)

-------------- РАБОТА -----------------

def bodyData_3DS_default = '' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
    '<soap:Body>' +
        '<ns3:sendSms xmlns:ns2="" xmlns:ns3="">' +
            '<customerId>' + '$' + '{customerId}' + '</customerId>' +
            '<customerType>' + '$' + '{customerType}' + '</customerType>' +
            '<phone>' + '$' + '{phone}' + '</phone>' +
            '<templateId>' + '$' + '{templateId}' + '</templateId>' +

            '<!--Optional:-->' +
            '<smsFlag>' + '$' + '{smsFlag}' + '</smsFlag>' +
            '<callingSystemName>' + '$' + '{callingSystemName}' + '</callingSystemName>' +
        '</ns3:sendSms>' +
    '</soap:Body>' +
'</soap:Envelope>';
bodyData_3DS_default = bodyData_3DS_default.replaceAll('<!--[A-Za-z_0-9:<>${}/ ]*-->', '');
vars.put('bodyData_3DS_default', bodyData_3DS_default);

JSR223 ПРЕПРОЦЕССОР

def bodyData = '${bodyData_3DS_default}';
['smsFlag'].each { removeOptional ->
    bodyData = bodyData.replaceAll('<'+ "${removeOptional}" + '[A-Za-z_0-9:<>${}()/_]*' + "</${removeOptional}" + '>', '');
}
vars.put('bodyData', bodyData);

-------------- РЕЗУЛЬТАТ ----------------

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns3:sendSms xmlns:ns2="" xmlns:ns3=""><customerId>CUSTOM</customerId><customerType>PHYSICAL</customerType><phone>79990001122</phone><templateId>000000006</templateId><callingSystemName>acs</callingSystemName></ns3:sendSms></soap:Body></soap:Envelope>

------------ НЕ РАБОТАЕТ ---------------------------

def bodyData_Services_default = '' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
    '<soap:Body>' +
        '<ns3:sendSms xmlns:ns2="" xmlns:ns3="">' +
            '<customerId>' + '$' + '{customerId}' + '</customerId>' +
            '<customerType>' + '$' + '{customerType}' + '</customerType>' +
            '<phoneAlgorithm>' + '$' + '{phoneAlgorithm}' + '</phoneAlgorithm>' +
            '<text>' + '$' + '{textSms}' + '</text>' +
                '<!--Optional:-->' +
            '<smsFlag>' + '$' + '{smsFlag}' + '</smsFlag>' +
            '<callingSystemName>' + '$' + '{callingSystemName}' + '</callingSystemName>' +          
        '</ns3:sendSms>' +
    '</soap:Body>' +
'</soap:Envelope>';
bodyData_Services_default = bodyData_Services_default.replaceAll('<!--[A-Za-z_0-9:<>${}/ ]*-->', '');
vars.put('bodyData_Services_default', bodyData_Services_default);

JSR223 ПРЕПРОЦЕССОР

def bodyData = '${bodyData_Services_default}';
['smsFlag'].each { removeOptional ->
    bodyData = bodyData.replaceAll('<'+ "${removeOptional}" + '[A-Za-z_0-9:<>${}()/_ ]*' + "</${removeOptional}" + '>', '');
}
vars.put('bodyData', bodyData);

--------- РЕЗУЛЬТАТ ------------------------------

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns3:sendSms xmlns:ns2="" xmlns:ns3=""><customerId>CUSTOM</customerId><customerType>PHYSICAL</customerType><phoneAlgorithm>last_updated_first</phoneAlgorithm><text>teXT</text><smsFlag>true</smsFlag><callingSystemName>blankpin</callingSystemName></ns3:sendSms></soap:Body></soap:Envelope>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...