-
Notifications
You must be signed in to change notification settings - Fork 614
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
Delay in autoconfiguration of TestBinder #2893
Comments
@kutmk Your two workarounds are reasonable solutions when using |
@kutmk, do you have any updates on the suggestions above? Since there are ways to address this, we are leaning towards leaving things as they are. Please let us know. |
@sobychacko Currently, the necessity for import is inconsistent and the conditions are complex. I believe this could lead to confusion for users. |
Ok, that sounds good. Why don't you send that as a PR, and we will evaluate for any side effects? |
Of course, I will send a PR. |
This has been addressed via #2900. |
With the update in #2566, it is no longer necessary to import
TestChannelBinderConfiguration
to use TestBinder.However, if no message handler is registered (i.e., not defining Supplier/Consumer/Function), it seems that the autoconfiguration of
TestChannelBinderConfiguration
is delayed. In this case, the injection ofOutputDestination
fails. Therefore, it is still necessary to import it.Log excerpt
Is this the intended behavior? Is it not possible to completely eliminate the import?
Demo and workaround
Demo and workaround: This demo intends to test an application that uses Test Binder,
StreamBridge
, andOutputDestination
without registering a message handler.Environment
Cause
The
TestChannelBinderConfiguration
is autoconfigured whenDefaultBinderFactory#initializeBinderContextSimple
is executed.If a message handler is registered, this method is called before the injection of the test class's member variables due to
OutputBindingLifecycle
orInputBindingLifecycle
.However, if a message handler is not registered, this method is not called until during the application’s execution when a Binder is needed (such as during the execution of
StreamBridge#send
). As a result, the Bean is not created until then, and the injection fails.The text was updated successfully, but these errors were encountered: