4 Replies Latest reply on Jan 28, 2014 12:20 PM by Dustin Barlow

    Issue with Switchyard generated JUnit tests

    Dustin Barlow Newbie

      I am running Fuse Service Works (6.0.0 EAP) which installs JBoss EAP 6.1 and Switchyard 1.1.  I am also using JBoss Developer Studio 7.1.0.GA (JBDev) along with the switchyard-site-assembly-1.1.0.zip plugins installed (and updated).

       

      I am able to run any of the Switchyard quickstarts JUnit tests I try inside of JBoss Developer Studio without any issue so I think my environment is sane.  I am also able to run them from the command line.

       

      When I have Switchyard generate the JUnit test for my Bean service in my very simple project, it generates the following (minus the mods I made on line 26 and 27):

       

      package com.example.switchyard.switchyard_example;
      
      import org.junit.Assert;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.switchyard.component.test.mixins.cdi.CDIMixIn;
      import org.switchyard.test.Invoker;
      import org.switchyard.test.ServiceOperation;
      import org.switchyard.test.SwitchYardRunner;
      import org.switchyard.test.SwitchYardTestCaseConfig;
      import org.switchyard.test.SwitchYardTestKit;
      
      @RunWith(SwitchYardRunner.class)
      @SwitchYardTestCaseConfig(config = SwitchYardTestCaseConfig.SWITCHYARD_XML, mixins = { CDIMixIn.class })
      public class PaymentsTest {
      
          private SwitchYardTestKit testKit;
          private CDIMixIn cdiMixIn;
          @ServiceOperation("Payments")
          private Invoker service;
      
          @Test
          public void testSubmit() throws Exception {
              // TODO Auto-generated method stub
              // initialize your test message
              Invoice message = new Invoice();
              message.setAmount(1234);
              service.operation("submit").sendInOnly(message);
      
              // validate the results
              Assert.assertTrue("Implement me", false);
          }
      }
      

       

      When I run this as a jUnit test in JBDev or from the command line, I get the following error.

       

      0[main] WARN  org.jboss.weld.interceptor.util.InterceptionTypeRegistry  - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
      1[main] WARN  org.jboss.weld.interceptor.util.InterceptionTypeRegistry  - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled

      Jan 22, 2014 6:49:31 PM org.apache.deltaspike.core.util.ProjectStageProducer initProjectStage

      INFO: Computed the following DeltaSpike ProjectStage: Production

      1439 [main] ERROR org.switchyard.test.SwitchYardRunner  - Error while test kit startup

      java.lang.NullPointerException

          at org.switchyard.deploy.internal.Deployment.deployReferenceBindings(Deployment.java:282)

          at org.switchyard.deploy.internal.Deployment.start(Deployment.java:143)

          at org.switchyard.test.SwitchYardTestKit.deploy(SwitchYardTestKit.java:756)

          at org.switchyard.test.SwitchYardTestKit.start(SwitchYardTestKit.java:176)

          at org.switchyard.test.SwitchYardRunner.createTest(SwitchYardRunner.java:60)

          at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236)

          at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

          at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233)

          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:85)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      java.lang.Exception: Stack trace

          at java.lang.Thread.dumpStack(Thread.java:1288)

          at org.switchyard.component.test.mixins.cdi.CDIMixIn.uninitialize(CDIMixIn.java:245)

          at org.switchyard.test.SwitchYardTestKit.cleanupMixIns(SwitchYardTestKit.java:809)

          at org.switchyard.test.SwitchYardTestKit.cleanup(SwitchYardTestKit.java:185)

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

          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:85)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

       

      I did some poking around in the quickstarts and found that the JUnit tests there didn't have the "config = SwitchYardTestCaseConfig.SWITCHYARD_XML" as a parameter to the @SwitchYardTestCaseConfig so I removed it from my JUnit test and the test worked.

       

      I noticed that SWITCHYARD_XML's value is set to "/META-INF/switchyard.xml".  Is there a reason this isn't a relative path and could be the reason for the null pointer error?  or is it something else?

       

      I was able to work around it finally, but since the Switchyard tooling generates that, I wanted to raise it as a potential bug/issue.