I am trying to test the flow of a spring integration XML that I built. I am using a Custom Transformer class to write my own transformation in which I am setting the profile based on the property. This property is set to dev in application.properties file. Is there anyway to dynamically change that value for test purposes? I tried passing it as VM arguments but the value of env variable in this class is still dev. It only helps in changing the target property file.
@PropertySource("classpath:application-${spring.profiles.active}.properties")
public class CustomTransformer {
@Value("${spring.profiles.active}")
private String env;
public Message<?> transform(Message<String> message){
String payload = message.getPayload().toString();
Message<?> message2 = MessageBuilder.withPayload(payload).copyHeadersIfAbsent(message.getHeaders()).setHeader("profile", env).build();
System.out.println("Message 2:\n" + message2.getPayload().toString());
return message2;
}
}