Forum Discussion
Poobury
11 years agoNew Contributor
A pleasure, Rao. Far too many times have I taken from the community (in the technical help sense, not in the "stealing from my next door neighbours" sense ) but not given in return, so it's about time I gave something back!
On that note, I've since noticed with my workaround that it works fine as long as the project remains open, but if you reload the project, the http status codes that were set are lost. However, I weirdly noticed that if you opened the assertion dialog to view the status code before the project was saved, closed and re-opened, then the status codes were persisted. Looking at the source, I worked out that if I effectively called
then that resolves the issue.
However, as usual, nothing is ever easy, and the
On that note, I've since noticed with my workaround that it works fine as long as the project remains open, but if you reload the project, the http status codes that were set are lost. However, I weirdly noticed that if you opened the assertion dialog to view the status code before the project was saved, closed and re-opened, then the status codes were persisted. Looking at the source, I worked out that if I effectively called
assertion.setConfiguration(assertion.createConfiguration())
then that resolves the issue.
However, as usual, nothing is ever easy, and the
createConfiguration()method is protected, so once again, I have to resort to reflection:
// XXX Invoke assertion.createConfiguration() to copy the assertion "codes" we set above into the configuration to be persisted into the project.
java.lang.reflect.Method statusAssertionCreateConfigurationMethod = assertion.getClass().getDeclaredMethod("createConfiguration");
// Make the protected method accessible
statusAssertionCreateConfigurationMethod.setAccessible(true);
// Create the configuration and set it on the assertion.
def assertionConfiguration = statusAssertionCreateConfigurationMethod.invoke(assertion)
assertion.setConfiguration(assertionConfiguration)
- nitinmahawadiwa8 years agoOccasional Contributor
Thank you Paul,
I was looking for similar solution on Java, but your script's Reflection suggestion helped me & saved my time as well.
Related Content
- 2 years agodkhanForce
- 8 years agocheriewoo
- 11 years agoavitaurus19