You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gravitino.apache.org by "Surya00011 (via GitHub)" <gi...@apache.org> on 2025/08/22 08:52:19 UTC
[D] Improvement: Testing OwnerDetails#validate exit behavior [gravitino]
GitHub user Surya00011 created a discussion: Improvement: Testing OwnerDetails#validate exit behavior
## While working on unit test for ```OwnerDetails```#validate method, I ran into a small complication:
- If entityType is invalid, the method ends up calling Main.exit(-1).
- Since this uses System.exit, it terminates the JVM immediately.
- That makes it difficult to write a proper test for this path, because the test process itself stops.
From my side, I just wanted to share this with you. Adding tests for this case isn’t straightforward without special handling. I thought it would be helpful for you to know, in case it comes up again.
Thanks @justinmclean
GitHub link: https://github.com/apache/gravitino/discussions/8250
----
This is an automatically sent email for dev@gravitino.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@gravitino.apache.org
Re: [D] Improvement: Testing OwnerDetails#validate exit behavior [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
GitHub user justinmclean added a comment to the discussion: Improvement: Testing OwnerDetails#validate exit behavior
Yes, this issue was previously encountered and we came up with a solution. Take a look at some of the tests that use `Main.useExit = false;`
GitHub link: https://github.com/apache/gravitino/discussions/8250#discussioncomment-14189131
----
This is an automatically sent email for dev@gravitino.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@gravitino.apache.org
Re: [D] Improvement: Testing OwnerDetails#validate exit behavior [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
GitHub user justinmclean added a comment to the discussion: Improvement: Testing OwnerDetails#validate exit behavior
If you set this in a test, it will throw an RuntimeException exception rather than exiting:
```
public static void exit(int code) {
if (useExit) {
System.exit(code);
} else {
throw new RuntimeException("Exit with code " + code);
}
}
```
GitHub link: https://github.com/apache/gravitino/discussions/8250#discussioncomment-14189142
----
This is an automatically sent email for dev@gravitino.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@gravitino.apache.org