Announcement Announcement Module
Collapse
No announcement yet.
End to End pipeline testing with jdbc:inbound-channel-adapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • End to End pipeline testing with jdbc:inbound-channel-adapter

    I want to test the behaviour of a pipeline fronted by a jdbc:inbound-channel-adapter
    I want to test end to end - so I want to setup the database table, let the inbound-adapter process the data and then check outputs.

    My problem is that I don't know of an elegant way to keep the test thread alive long enough for the inbound-adapter threads to do some work.

    At the moment I'm thinking of something like:

    Code:
        @Test(timeout= 2000)
        public void testJdbcInbound() {
            context.start();
            while (databaseStillHasMessages()) {
                    context.stop();
            }
            checkOutPuts();
        }
    If all goes well rows in database will be deleted/updated and I can use this to indicate test is complete - databaseStillHasMessages() - but if it is not working then i need to end the test at the some point - hence use of timeout= 2000for this.

    How are others doing this?
    Last edited by ndw; Sep 13th, 2011, 01:21 PM.

  • #2
    Check out some test cases in JDBC module. They do exactly that.

    Comment


    • #3
      Thanks Oleg

      For example you mean JdbcMessageStoreChannelIntegrationTests ?

      Any plans to make something like that pattern part of a spring-integration-test utility at some point?

      I'm thinking something like -
      I register the number of messages I expect to be produced and a set of channels that should recieve output messages with the PipelineTestUtil, and the test utility registers a handler on each of the channels. The handler would look something like the JdbcMessageStoreChannelIntegrationTests#Service.

      I start the pipeline/context/inbound-adapter and then call await(however-long-i-think-it-should-take) on the utility. Assuming test doesn't timeout I can get the messages from each channel that I registered an interest in and check the results..
      eg :
      Code:
             
          pipelineTestUtil.setExpectedMessages(no-of-messages-I-expect)
          pipelineTestUtil.registerOutputChannels(channelsThatShouldGetOutputs);
          startThePipeline();   // maybe pipelineTestUtil.startThePipeline()
          try{
              pipelineTestUtil.await(how-long-it-should-take);
              List<Messages<?>> messagesToCheck = pipelineTestUtil.getMessagesFromChannel(name-of-one-of-output-channels)
          } catch 
          ....

      Comment

      Working...
      X