Announcement Announcement Module
Collapse
No announcement yet.
Junit and SimpleAsyncTaskExecutor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Junit and SimpleAsyncTaskExecutor

    I am using Junit (within Eclipse) to invoke Spring Batch. My problem is that within Junit I never get any result using the xml configuration shown below. However, everything works perfectly (within Junit) if I change "SimpleAsyncTaskExecutor" in the example below to instead be "SyncTaskExecutor".

    So my question is whether this is normal behavior within Junit. I.e., that when using Junit it is always necessary to change from SimpleAsyncTaskExecutor to SyncTaskExecutor. The implication of the question is whether I can expect that when not using Junit, it will work okay to change back to using SimpleAsyncTaskExecutor.


    Code:
    <bean id="jobLauncher"
    class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    <property name="jobRepository" ref="jobRepository" />
    <property name="taskExecutor">
    <bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
    </property>
    </bean>

  • #2
    You can't run multithreaded test in junit. Launching your job using the async task executor means that you've fired off another thread besides the main junit thread. This won't work if you expect the job to finish before the test completes and says "SUCCESSFUL".

    You should read this:

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

    Comment


    • #3
      Thank you Chudak. I carefully read the article you recommended, and it was very helpful.
      cheers
      Robert
      Originally posted by chudak View Post

      Comment

      Working...
      X