Announcement Announcement Module
No announcement yet.
Problem with the file Spring Integration Sample Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with the file Spring Integration Sample


    I am testing the newest Spring Integration Samples and I found an issue with the File Sample from the Basic category: the program ends before being able to copy anything. Since I am new at SINT I am curious if there is something I am doing wrong or is just a glitch on the sample.

    To make it work I just added an infinite loop to the test code.

    public class FileBasedFileCopyTest {
    	public void testFileBasedCopy(){
    		ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/fileCopyDemo-file.xml", FileBasedFileCopyTest.class);
    		while (true) {

  • #2
    Thank you for pointing this out. I'lll update the sample.
    I opened up a JIRA, so you can follow the progress:


    • #3
      If ran as a Java Program works fine


      I converted the JUnit test to a regular Java program (moved the code to a main method) and then it works, since the program is not being terminated.

      I guess that Junit and Spring Integration with pollers have certain issues.



      • #4
        I guess the Problem is with JUnit

        read the below post as an additional knowledge.

        not sure if this helps...
        Last edited by Paresh; Oct 26th, 2010, 06:22 AM.


        • #5
          Waiting for all the threads to finish

          Thanks Paresh for the hint. I did a little more of investigation and the problem arises due to the concurreny features of the framework. Since we do not want the Test Unit thread to finish before the SI threads are done, then we should make the test wait for the results. As far as I understand, there are 3 ways to do so:
          1. Make the test wait by using code (Thread.sleep or an infinite While loop as I did)
          2. Send the output of your message flow to QueueChannel and block by waiting to receive on this channel
          3. Use a CountDownLatch to synchronize your test and the SI components that are being tested

          I really wouldn't know how to make #3 work, so I will just ignore that

          I do not like #2 if the purpose of your test is to see if all the wiring done on your Context configuration file is working (It seems to me that you would have to change it to include this output channel). If you are testing that your business code receives or sends messages, then it this would be the way to go.

          But if your goal is to test that the whole integration job works, it seems to me that # 1 is the way to go. Ugly but fits its purpose.

          Any suggestions or comments on how to improve this will be appreciated.




          • #6
            I guess u can have a look at GroboUtils, not sure if it fits to ur requirement...