Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9981

CamelSpringJUnit4ClassRunner registers listeners twice

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.14.0, 2.15.0, 2.17.1
    • 2.17.2, 2.18.0
    • camel-test
    • ALL

    • Novice
    • Important

    Description

      Using camel-test-spring I found that CamelSpringJUnit4ClassRunner registers the listener twice. This causes the following error in transactional tests:

      java.lang.IllegalStateException: Cannot start a new transaction without ending the existing transaction.
      

      To fix it, it is required to only add the expected listeners :

      line:57
               public CamelTestContextManager(Class<?> testClass) {
                  super(testClass);
      
                  // inject Camel first, and then disable jmx and add the stop-watch
                  // WARNING: The listeners are registered within the super class.
                  /// DON'T get current listeners.
                  // List<TestExecutionListener> list = getTestExecutionListeners();
                  //
                  List<TestExecutionListener> list = new ArrayList<TestExecutionListener>(3);
      
                  list.add(new CamelSpringTestContextLoaderTestExecutionListener());
                  list.add(new DisableJmxTestExecutionListener());
                  list.add(new StopWatchTestExecutionListener());
                  OrderComparator.sort(list);
                  registerTestExecutionListeners(list);
              }
      
      

      Spring version: 4.2.5.

      Attachments

        1. camel-9981-test.zip
          6 kB
          Gardella Juan Pablo

        Activity

          People

            davsclaus Claus Ibsen
            gardellajuanpablo Gardella Juan Pablo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: