I am trying to set karate.env through netty server and respond back what environment is used. Update made to karate.env using java system.setProperty is not reflecting in feature files. But java have updated system.setProperty correctly.
Any input will help. Thanks.
Background:
* def setEnvVar = Java.type('CMA_Release.Java_Lib.setEnvVar')
Scenario: pathMatches('/orangeFMW/psd2_cma/cctoken') && methodIs('post')
* call setEnvVar.set('karate.env',request.Environment)
* print request.Environment
* print karate.env
# * call read('classpath:karate-config.js')
# few other operations
* def response = "Selected Environment : " + karate.env
Response : Selected Environment : null
Server log
scenario matched: pathMatches('/orangeFMW/psd2_cma/cctoken') &&
methodIs('post')
UAT // Java update the value correctly
not a js function or feature file:
setEnvVar.set('karate.env',request.Environment) - [type: NULL, value: null]
[print] UAT
[print]
Java class
public class setEnvVar {
public static void set(String key, String value){
System.setProperty(key, value);
System.out.println(System.getProperty(key,value));
}