-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build with Java 17 LTS #665
Conversation
…sues during test Cfr Issue #664 Instead of exposing and mocking the Random used by the strategy, hide it behind a `nextInt()` member method that can safely by intercepted by Mockito during tests.
Some comments about (1) (2) (3) |
(1) Feel free to make protected and extend as you mentioned. (2) The test does not need to test that Random/ThreadLocalRandom behave properly, since they have been thoroughly tested by the jdk release process. The test just needs to verify that the RandomDestinationConnectionStrategyTest calls Random/ThreadLocalRandom properly and returns their values. So mocking the Random return values, and checking that the RandomDestinationConnectionStrategy returns those values is a valid test. (3) I'd have to dig in to see if it is safe to remove. I don't think there's a harm in using a thread local Random to ensure the strategy is threadsafe. |
src/test/java/net/logstash/logback/appender/LogstashTcpSocketAppenderTest.java
Outdated
Show resolved
Hide resolved
Use a UnaryOperator as random generator instead of a public method whose only purpose is to serve as a hook for Mockito during test cases.
I chose to pass a UnaryOperator function as argument to the constructor to generate random numbers. The default implementation makes use of
I kept the |
Close #654 and #664