Oct 2nd, 2012, 07:45 AM
Spring Integration Testing Questions
I have a few questions regarding unit/mock/end-to-end testing with Spring Integration.
As some background, the context is configured right now with bridges in a "default" profile connecting different units of work within the flow as well as the components that integrate with external systems. For unit testing, a "test" profile is used that just defines queues for the different units of work within the flow, so the messages can be intercepted and interrogated. The "test" profile also contains service activators that act as mock components.
1) What is the best way to mock various Spring Integration components since many of the gateways are actually made up of two different components? I solved this by creating service activators for each component I wanted to mock. Is this a good/recommended approach? Is there a better way?
2) How can I mock components that are in a chain and easily swap them in and out depending on whether I'm doing unit/integration testing? I found this challenging because components in a chain do not have an input/output channel. If I wanted to mock a component in a chain, it seems like I would have to mock the entire chain. There can potentially be many steps in the chain, so a lot of the configuration would go untested. Does anyone have any recommendations?
3) Is there a good way to add unit integration tests into this approach? In order to add unit tests that integrate with external systems, I would have to add yet another profile that defines queues for intercepting messages, as well as all the components that integrate with external systems. Taking this approach there is a lot of duplication in the configuration. Is there any better/recommended way to tackle this?