Testing Concurrent Java programs

                        Sameer Arora
                       Xebia IT Architects.




                                        1
AGENDA

    What makes Concurrent programs hard to test.


    How concurrent application's design drives testability.


    Testing asynchronous code - demo.


    Testing Blocking operations and Resource Management - demo.


    Testing Thread Safety - demo.


    Complementary testing approaches.


    Questions & Feedback




                                                                  2
What makes concurrency hard to test


Tests for Concurrent Programs are themselves concurrent programs.



Failures are rare and probabilistic in nature.



Execution is Platform Dependent.




                                                                3
Design and Testability

Encapsulating concurrent interactions .



Thread Delegation.



Effectively Immutability.



Figuring Single Thread Confinement.



Composition.

                                          4
Testing Asynchronous Method Calls




   Asynchronous Job Signal Demo

                                    5
Testing for Resource Management




                                  6
Bounded Job Queue




Test for Blocking Operations - Demo
                                      7
Testing for Thread Safety




Bounded Job Queue Thread Interleaving Test


                                             8
Complementary Testing Approaches

    Injecting Callbacks.


    Static code Analysis Tools.


    Code Review.


    Profilers and Monitoring tools.


    Frameworks for Multi-threaded Testing.
     
         ConcJunit
     
         Awaitility
     
         MultiThreadedTC



                                                9
Questions




Questions/Comments/Feedback




                              10
Thank you



            11

Testing concurrent java programs - Sameer Arora