JBoss Community Archive (Read Only)

SwitchYard

Unit Testing

The SwitchYard tooling provides support for stubbing out test classes for services.

New Service Test Wizard

This wizard creates a new service test class.  The class is created with references to any mix-ins specified and a method stub for each operation in the selected service interface.  The method stubs include code for passing a message to the operation and processing the result.  The user needs to initialize the message data and validate the results.  The following illustrates the stubs that are created by the wizard:

SomeServiceTest
@RunWith(SwitchYardRunner.class)
@SwitchYardTestCaseConfig(mixins = CDIMixIn.class, config = SwitchYardTestCaseConfig.SWITCHYARD_XML)
public class SomeServiceTest {

    private SwitchYardTestKit testKit;
    private CDIMixIn cdiMixIn;
    @ServiceOperation("ExampleService")
    private Invoker service;

    @Test
    public void testSomeInOnlyOperation() throws Exception {
        // TODO Auto-generated method stub
        // initialize your test message
        Object message = null;
        service.operation("someInOnlyOperation").sendInOnly(message);

        // validate the results
        Assert.assertTrue("Implement me", false);
    }

    @Test
    public void testSomeInOutOperation() throws Exception {
        // TODO Auto-generated method stub
        // initialize your test message
        Object message = null;
        String result = service.operation("someInOutOperation")
                .sendInOut(message).getContent(String.class);

        // validate the results
        Assert.assertTrue("Implement me", false);
    }

}

images/author/download/attachments/59146367/qs-new-test-wizard.jpg

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 09:45:00 UTC, last content change 2013-11-15 21:22:55 UTC.