-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix WebSocket subscription tests #27
Conversation
assertThat(msg.get("subscriptionName"), instanceOf(String.class)); | ||
assertThat(callback.getMessage().getHeaders().get("X-Request-Id"), instanceOf(String.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we don't get an NPE/cast error if the values are wrong. The one test that uses these values now assigns them after the asserts.
// Sometimes the connection occurs during the validations above. Check for completion only if it's not connected | ||
if (!callback.isConnected()) { | ||
callback.reset(); | ||
callback.waitForCompletion(); | ||
assertThat("Connected", callback.isConnected(), is(true)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the connection message comes fast enough, it will occur before the reset. The assert here will then fail since reset()
clears all the flags used by the test callback class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might put the assert outside of the IF, just so it is always checked. Makes test clearer to me.
// Sometimes the connection occurs during the validations above. Check for completion only if it's not connected | |
if (!callback.isConnected()) { | |
callback.reset(); | |
callback.waitForCompletion(); | |
assertThat("Connected", callback.isConnected(), is(true)); | |
} | |
// Sometimes the connection occurs during the validations above. | |
// So wait for completion only if it's not already connected | |
if (!callback.isConnected()) { | |
callback.reset(); | |
callback.waitForCompletion(); | |
} | |
assertThat("Connected", callback.isConnected(), is(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
One nit about waitForCompletion IFs
// Sometimes the connection occurs during the validations above. Check for completion only if it's not connected | ||
if (!callback.isConnected()) { | ||
callback.reset(); | ||
callback.waitForCompletion(); | ||
assertThat("Connected", callback.isConnected(), is(true)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might put the assert outside of the IF, just so it is always checked. Makes test clearer to me.
// Sometimes the connection occurs during the validations above. Check for completion only if it's not connected | |
if (!callback.isConnected()) { | |
callback.reset(); | |
callback.waitForCompletion(); | |
assertThat("Connected", callback.isConnected(), is(true)); | |
} | |
// Sometimes the connection occurs during the validations above. | |
// So wait for completion only if it's not already connected | |
if (!callback.isConnected()) { | |
callback.reset(); | |
callback.waitForCompletion(); | |
} | |
assertThat("Connected", callback.isConnected(), is(true)); |
Fixes #26
The
requestId
changes are due to PR Vantiq/ag2rs#7934, It removed the field from the subscription's return, presumably because the value is also available in the headerX-Request-Id
.