webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  JUnit

    Posted Tue June 14, 2011 06:50 PM

    Did anyone created a junit test class to test IS flow/hava service?

    any suggestion / best practice?

    Thanks a lot!!


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General


  • 2.  RE: JUnit

    Posted Mon August 03, 2015 06:56 AM

    Hi Fabrizio,

    Little late with this response, but I think what you are looking for the WmTestSuite tool.

    It is actually a tool that SAG offers to customers. I have no idea about the pricing information. (some details here: wmtestsuite - webMethods - Software AG Tech Community & Forums)

    Also in the mean time other tool might have been developed that will ease the testing of Integration Server services.
    You can check this out: WebMethods New Tools Survey - 1 minute (5 questions) - webMethods - Software AG Tech Community & Forums

    Hope it helps,
    Vlad Turian


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: JUnit

    Posted Wed August 05, 2015 03:17 AM

    Hello,

    I have developed my own Java framework for testing Flow services with JUnit. It is an abstraction over IData, so you can test the services using POJOs instead of handling IData yourself:

    You can define your IS documents or Input/Output parameters as simple POJOs using public attributes or even Getters/Setters:

    public class Address
    {
    private String street;
    
    @PipelineName("CityName")
    private String city;
    
    [...]
    }

    The service is modeled as a simple Java class using lots of Reflection and Generics to minimize the needed code:

    public class GetAddress extends Service<GetAddress.Input, GetAddress.Output>
    {
    public static class Input extends ServiceInput
    {
    public String id;
    }
    
    public static class Output extends ServiceOutput
    {
    public Address address;
    }
    }

    A simple test may then look like this:

    GetAddress sut = new GetAddress();
    GetAddress.Input input = new GetAddress.Input();
    GetAddress.Input.id = "123";
    
    GetAddress.Output output = sut.call(input);
    
    assertThat(output.address.getStreet(), is("My Street"));

    Here’s an (older) blog post describing the functionality (before I extracted it as a framework): Unit-testing Flow Services in webMethods’ Integration Server with JUnit.

    The framework is in use for almost two years now and is actively developed. The complete source code is on GitHub and it’s completely free, of course. Feel free to modify/add behaviour and send me a Pull Request.

    I would love to get feedback on the framework! And please let me know, if I can be of further help to you.

    Best regards,
    Stefan


    #webMethods-General
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: JUnit

    Posted Thu August 13, 2015 09:21 AM

    Hi Stefan,
    we have implemented jUnit in our project

    1. Install jUnit plugin in Designer if not exist
    2. Create package and folders like ( folders for junit test case and another folder to keep input pipeline xml files)
    3. Create a class and use Junit API’s to create helper object , context object and call Services on Integration Server and retrieve output.
    4. Write custom logic to check if output has expected data or not (JHelperObj.getContentByAttrubite)
    5. Accordingly throw positive or negative response.

    JunitHelper JHelperObj= new JunitHelper();
    public Context contextCall= JHelperObj.connectServer(“http://localhost:5555”);
    String response1=JHelperObj.jUnitHelperMain(contextCall, “PipelineFileName”, folder, svcName);

    If test is positive then assetValue=true; else assetValue=false;


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 5.  RE: JUnit

    Posted Thu August 20, 2015 05:46 AM

    Hi Rohit,

    thanks for the explanation! I never thought of running the tests directly on Integration Server.

    However, if I understand you correctly, you also create the JUnit tests directly on Integration Server. In my opinion, this has two negative consequences:

    1. You need to work with Software AG Designer. Compared to your Java IDE of choice, SAG Designer is slow and doesn’t allow additional plugins (or they simply don’t work as expected). In my experience, whenever I need to program a Java service, I switch to Eclipse, because working with local projects (and the needed libraries) and remote compiling in SAG Designer is too cumbersome.
    2. Tests don’t test, whether services are available via the network. If they run within Integration Server, they almost always will be able to call the services under test. In my case, I would like to know in addition, whether the services can be called from the network (from where they have to be called later). I know this leads to more of an integration test instead of a unit test, but I would prefer to write complex services as plain old Java modules with fast unit tests any way. Then I only need to add the pre-compiled and tested JAR to IS and call its methods.

    Furthermore, my framework does not only allow unit tests to call the services, but any Java application. The framework is used as an abstraction layer on top of IS, so Java applications don’t have to deal with IData etc.

    Best regards,
    Stefan


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: JUnit

    Posted Sun August 23, 2015 11:03 AM

    IMO it’s a bit unnatural to create unit tests in a language other than the one the tested units are created in. That’s the reason for the existence of the many xUnit libraries for different languages. I think there should also be one for the flow language.


    #Integration-Server-and-ESB
    #webMethods-General
    #webMethods


  • 7.  RE: JUnit

    Posted Thu August 27, 2015 06:39 AM

    You are absolutely right! Writing unit tests should never be “unnatural” for the developers to maximize the possibility that they actually write tests. That’s the reason why we created a test framework for Natural (NatUnit) instead of using the testing tools inside Software AG Designer.

    However, in case of Flow as a visual language I would not recommend writing tests with it. All the pointing and clicking gets annoying pretty fast (at least in my opinion). But that’s a general problem with all visual programming languages.


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General