2 Replies Latest reply on Apr 14, 2016 11:28 AM by mlybarger

    mock boolean return type

    mlybarger

      I'm having troubles with the test runner trying to mock a service interface that returns a boolean.

       

      I use the below ExchangeHandler, and the invocation goes fine,  I can step through and see handleMesage gets called, and the exchange.send gets invoked.  Then I get a NPE thrown when it tries to cast the return type. 

       

       

      public class EH implements ExchangeHandler {
           @Override
           public void handleMessage(Exchange exchange) {
                if exchange.getContract.getConsumerOperation.getName().equals("methodReturnsbool")) {
                     exchange.send(exchange.createMessage().setContent(true);
                }
      
           }
      }
      

       

      As I had control of the service and implementation, I modified this to a Boolean and it's working fine.  However, I just wanted to know if anyone else has knowledge of this limitation?  It seems the test runner, has problems converting a boolean result.  I'm on SY 1.x...

        • 1. Re: mock boolean return type
          tcunning

          Mark,

           

          Can you provide the exception and a small test case?   If autoboxing/unboxing isn't working it's something we should fix.

          • 2. Re: mock boolean return type
            mlybarger

            Tom,

             

            I put together a test case to show this. I have two projects.  Foo and Bar.  Foo invokes Bar over sca binding.  bar has a method that returns boolean (and others).  Bar is mocked in the test using mock similar to shown above. When bar returns boolean is invoked, exception is thrown as shown in the test.  When bar returns Boolean, exception is not thrown.  

             

            git clone https://github.com/mlybarger/bar.git

            git clone https://github.com/mlybarger/foo.git

            cd bar && mvn install && cd ..

            cd foo && mvn test

             

            Please inspect the failing FooBeanTest in from the project above.  Maybe I should create an issue in jira.  I tried with sy 2.0.0-Final too and it fails there also.

             

            -mark-