12 Replies Latest reply on Jun 25, 2012 3:41 AM by splatch

    Switchyard JtaTransactionManager on Unit Tests

    edevera

      I am trying to run some integration tests based on the SwitchYardRunner.class. I have basically adapted the camel-jms-binding quickstart to my needs, which is basically adding the transactionManager as well as the transacted parameters to the camel URI binding as shown below:

       

      {code}

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0">

          <composite

                  xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"

                  name="camel-jms-binding"

                  xmlns:swyd="urn:switchyard-config:switchyard:1.0"

                  targetNamespace="urn:com:edevera:services:1.0.0">

              <service name="myService" promote="myService">

                  <camel:binding.camel xmlns:camel="urn:switchyard-component-camel:config:1.0"

                                       configURI="jms://MyQueue?connectionFactory=%23JmsXA&amp;transactionManager=%23jtaTransactionManager&amp;transacted=true">

                      <camel:operationSelector operationName="save"/>

                  </camel:binding.camel>

              </service>

          </composite>

      </switchyard>

      {code}

       

      When I execute the CamelJMSBindingTest included in this quickstart I get the following error:

       

      {code}

      java.lang.reflect.InvocationTargetException

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

                at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

                at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

                at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)

                at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

      Caused by: org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException; nested exception is java.lang.NullPointerException: null

                at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:166)

                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:118)

                ... 9 more

      Caused by: java.lang.NullPointerException

                at org.switchyard.test.SwitchYardRunner$TestLifecycleListener.testFinished(SwitchYardRunner.java:88)

                at org.junit.runner.notification.RunNotifier$7.notifyListener(RunNotifier.java:145)

                at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:41)

                at org.junit.runner.notification.RunNotifier.fireTestFinished(RunNotifier.java:142)

                at org.junit.internal.runners.model.EachTestNotifier.fireTestFinished(EachTestNotifier.java:41)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:269)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

                at org.switchyard.test.SwitchYardRunner.run(SwitchYardRunner.java:78)

                at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)

                at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)

                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)

                ... 9 more

       

       

      Results :

       

       

      Tests in error:

        sendHostMessageToJMSQueue(com.edevera.CamelJMSBindingTest): Could not create a JtaTransactionManager as no TransactionManager was found in JNDI. Tried [java:jboss/UserTransaction, java:comp/UserTransaction]

      {code}

       

      Does anyone know how to prepare a TransactionManager from a Switchyard Test?