3 Replies Latest reply on Jan 14, 2013 8:55 AM by kcbabo

    SwitchYard Unit Testing errors

    eleni.papadopoulou

      Hi,

       

      I have implemented a JUnit Test Case for a very simple switchyard service, which expects as input a String and returns as output a String.

      In order to generate the Unit Test Case I right clicked in the green anchor of the service in the switchyard editor and I selected the option 'New service Test Class'.

      When I run the JUnit test I get the following error: java.lang.NoClassDefFoundError: javax/enterprise/inject/spi/Extension , although I have the  javax.inject-1.jar and the cdi-api-1.0-SP4.jar in my project's dependencies.

       

      Also, I also implemented a Unit Test similar to the WebServiceTest in the bean-service quickstart and in this case the test is not executed at all as I get the error: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy.

       

      Can you please help me understand what I am doing wrong?

       

      Attached you can find the two Unit Test Cases.   

       

      Thank you!

        • 1. Re: SwitchYard Unit Testing errors
          kcbabo

          You shouldn't need those dependencies directly in your project's pom.xml as they should be included transitively from the switchyard-component-bean dependency.  Can you attach the actual projects you are using for these tests?  Both errors seem to be class path resolution issues and/or project configuration problems.

          • 2. Re: SwitchYard Unit Testing errors
            eleni.papadopoulou

            Hi,

             

            You can find attached the project included the implemented Unit Test cases for which I get the errors I mentioned in my previous post.

            The exact error I get during Maven build is :  WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

             

            I have also attached the surefire reports of the tests.

             

            Thank you in advance.

            • 3. Re: SwitchYard Unit Testing errors
              kcbabo

              There are a number of things at play here:

               

              1. The Weld error you referenced above is harmless and is just an indication that injection of a user transaction is not available for your unit test.
              2. Without changing anything, the project compiles and one of the tests passes in my environment.
              3. The web service test is failing because you are using a SOAP 1.2 media type ("application/soap+xml") with a SOAP 1.1 request.  Chanigng your unit test to use "text/xml" instead allows the test to pass.
              4. I noticed there is an Ant build script and a number of dependencies in the pom.xml which should be inherited transitively from our SwitchYard component definitions (Drools and CDI are two examples).  Whenever possible, try to stick with our component dependencies in your pom.xml and allow the transitive dependencies to be resolved on their own.  This is not causing an issue with your current project, but there is potential for it to cause problems.  You can add pom.xml dependencies to any SY project by right-clicking on your project and selecting Configure -> SwitchYard Capabilities ...

               

              hth,

              keith