WmUnit is a high-level, JUnit compliant, framework for testing your webMethods Integration Server services. It's been used in production since 2002.
Look at the examples listed below if you have any questions - please, read the documentation and the apidocs.
Usage example 1 Invoking service |
import com.wm.app.b2b.client.ServiceException; import java.text.ParseException; import org.dom4j.Document; import pl.infovide.wmunit.WmTestCase; import pl.infovide.wmunit.WmUnitConf; import pl.infovide.wmunit.utils.Utils; // your imports here class MyTestCase extends WmTestCase throws ServiceException, ParseException { protected void setUp() { utils = new Utils(); } public void testGetCustomerId_01() { String accountId = "12345"; // Create an input XML document. // In WmUnit, you're using XML and XPath. // WmUnit takes care of translating XML into IData. Document inDoc = makeData(utils.getXML("getCustomerId.xml")); inDoc.selectSingleNode("//WmUnitIn/docGetCustomerId/accountId").setText(accountId); // Invoke a "pl.iv.wmunit:getCustomerId" service // on the default IS and collect the output. Document outDoc = invoke("pl.iv.wmunit","getCustomerId",inDoc, getDefaultServer()); // Your assertions go here... String errorCode = outDoc.valueOf("//Outdoc/docGetCustomerIdOut/errorCode"); assertEquals("0", errorCode); } } |
---|---|
Usage example 2 Publish/subscribe. |
import com.wm.app.b2b.client.ServiceException; import java.text.ParseException; import org.dom4j.Document; import pl.infovide.wmunit.WmTestCase; import pl.infovide.wmunit.WmUnitConf; import pl.infovide.wmunit.utils.Utils; // your imports here // In this scenario, we publish a document and expect // some service to publish another document in response to ours. class MyTestCase extends WmTestCase throws ServiceException, ParseException { private final static String ourDocType = "pl.infovide.wmunit:getInvoicesRequest"; private final static String expectedDocType = "pl.infovide.wmunit:getInvoicesReply"; protected void setUp() { // Aliases are configured in wmunitconf.xml. // If you want to use default broker and server // put methods getDefaultServer() and getDefaultBroker() instead of aliases. subscribe(expectedDocType, "server1","broker1"); } protected void tearDown() { // Don't leave the subscription on broker. unsubscribe(expectedDocType); } public void testGetInvoices_01() { String accountId = "12345"; // Create an input XML document. // Again, WmUnit will translate it into broker's format. Document inDoc = makeData(utils.getXML("getInvoices.xml")); inDoc.selectSingleNode("//WmUnitIn/getInvoicesRequest/accountId").setText(accountId); // Publish a request and sleep a while. publish(ourDocType, inDoc); sleep(1000); // Get the last published document of type 'expectedDocType'. Document publishedDoc = getDocument(expectedDocType); assertNotNull("No document published.", publishedDoc); // Your assertions go here... List invoices = publishedDoc.selectNodes("//Outdoc/getInvoicesReply/invoices"); assertTrue("No invoices retrieved.", invoices.size() > 0); } } |
Read documentation