Results 1 to 3 of 3

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

  1. #1

    Default 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 at 12:21 PM.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

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

  3. #3

    Default

    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 
        ....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •