Results 1 to 6 of 6

Thread: Problem with the file Spring Integration Sample

  1. #1
    Join Date
    Aug 2010
    Posts
    9

    Default Problem with the file Spring Integration Sample

    Hi,

    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.

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

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

    Default

    Thank you for pointing this out. I'lll update the sample.
    I opened up a JIRA, so you can follow the progress: https://jira.springframework.org/browse/INTSAMPLES-6

  3. #3
    Join Date
    Aug 2010
    Posts
    9

    Default If ran as a Java Program works fine

    Hi,

    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.

    Thanks

  4. #4

    Default

    I guess the Problem is with JUnit

    read the below post as an additional knowledge.

    http://today.java.net/pub/a/today/20...adedTests.html

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

  5. #5
    Join Date
    Aug 2010
    Posts
    9

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

    Thanks,

    Alberto

  6. #6

    Default

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

    http://groboutils.sourceforge.net/

Posting Permissions

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