Here you can find documentation of WmUnit 2.0, information about configurating WmUnit 2.0. and the way how you should migrate from WmUnit 1.0 to WmUnit 2.0

Getting started

WmUnit is a package for testing webMethods services. As such, its main class, pl.infovide.wmunit.WmTestCase, extends junit.framework.TestCase and adds some interesting features to it. WmTestCase is the public class your classes should extend.

WmUnit operates on XML documents. It takes care of boring details of translating it into IData or BrokerEvents.

WmTestCase has four main methods:

  • Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
    Invokes a service from a given package on a server denoted by a specific server alias and waits for the result. Aliases are explained in the configuration section

  • Document publish(String serverAlias, String docType, Document doc)
    Publishes a document of type docType using a server serverAlias. docType has to be in IS form of "pl.infovide.doc.SampleDoc" not in broker's "pl::infovide::doc::SampleDoc". Why is there a serverAlias not a brokerAlias? Because WmUnit uses standard pub.publish:publish service for publishing documents so it needs to know where to invoke it.

  • void subscribe(String docTypeName, String serverAlias, String brokerAlias)
    Subcribes for documents of type docTypeName on a broker brokerAlias. serverAlias points to a server on which the IvWmUnit package is installed. IvWmUnit must be installed and enabled for subscribe to work. Subscribing to a document type is an asynchronous call and you can poll the broker to see if there's any document available with the boolean documentPublished(String docTypeName) method. You can get the last document published on broker using method getDocument(String docTypeName) or all documents of specified type, published during lifetime of the object, by calling method getDocuments(String docTypeName).

  • void unsubscribe(String docTypeName)
    Removes the subscribtion for the documents of type docTypeName. Also removes the client from broker.

Configuring WmUnit

WmUnit is configured via the wmunitconf.xml file. Below is a sample configuration file. There may be many server aliases but only one of them may be the default one. Similarly, only one of the brokers may be marked as the default broker.

How do you use aliases in your code? Assuming the configuration as shown below, you could write

          Document inDoc = someMethodToGetADocument();
          Document outDoc = invoke("my.folder","myService",inDoc,"server1")
          // do something with outDoc
which would connect to server "127.0.0.1:5555" and invoke a "my.folder:myService" service, giving it an inDoc document on input.

Default server is available through the getDefaultServer() call. So the above example might be rewritten to
          Document inDoc = someMethodToGetADocument();
          Document outDoc = invoke("my.folder","myService",inDoc,getDefaultServer());
          // do something with outDoc

Accessing brokers' settings works the same way
          subscribe("my.folder.docType", "server1", "broker1")
          // wait for a document
          Document doc = getDocument("my.folder.docType");
          // do something with doc
or
          subscribe("my.folder.docType", "server1", getDefaultBroker())
          // wait for a document
          Document doc = getDocument("my.folder.docType");
          // do something with doc
or even
          subscribe("my.folder.docType", getDefaultServer(),getDefaultBroker())
          // wait for a document
          Document doc = getDocument("my.folder.docType");
          // do something with doc



Here's the promised configuration example:
<wmunitconf>
    <servers>
        <server alias="server1" default="true">
            <address>127.0.0.1:5555</address>
            <user>Administrator</user>
            <password>manage1</password>
        </server>
        <server alias="server2">
            <address>127.0.0.1:5666</address>
            <user>Administrator</user>
            <password>manage2</password>
        </server>
    </servers>
    <brokers>
        <broker alias="broker1" default="true">
            <address>127.0.0.1:6849</address>
            <name>broker1</name>
            <clientGroup>IntegrationServer</clientGroup>
        </broker>
        <broker alias="broker2">
            <address>127.0.0.1:6859</address>
            <name>broker2</name>
            <clientGroup>IntegrationServer</clientGroup>
        </broker>
    </brokers>
	<xmlInSeparatedFile>yes</xmlInSeparatedFile>
	<outputDir>Sample/TestDir</outputDir>
	<devDbg>none</devDbg>

</wmunitconf>

Migrating from WmUnit 1.0 to 2.0

Removed APIs
Removed API New API
org.chatka.wmunit package has been removed Use classes from pl.infovide.wmunit package instead

Deprecated APIs

Main changes:

  • The whole family of various invokeService methods has been replaced by a single method
    Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
  • There's now a single publish(String serverAlias, String docType, Document doc) method for publishing documents.


Deprecated API New API
com.infovide.qac.wmunit.WTestCase
Document invokeService(Document doc,Context connectedContext)
pl.infovide.wmunit.WmTestCase
Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
com.infovide.qac.wmunit.WTestCase
Document invokeService(String packageName, String serviceName, Document doc,Context connectedContext)
pl.infovide.wmunit.WmTestCase
Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
com.infovide.qac.wmunit.WTestCase
Document invokeService(Document doc, String wsdlPath, Context connectedContext)
There's no direct replacement.
com.infovide.qac.wmunit.WTestCase
Document invokeService()
pl.infovide.wmunit.WmTestCase
Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
com.infovide.qac.wmunit.WTestCase
Document invokeService(Document doc)
pl.infovide.wmunit.WmTestCase
Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
com.infovide.qac.wmunit.WTestCase
Document invokeService(String packageName, String serviceName, Document doc)
pl.infovide.wmunit.WmTestCase
Document invoke(String packageName, String serviceName, Document doc, String serverAlias)
com.infovide.qac.wmunit.WTestCase
Document invokeService(Document doc, String wsdlPath)
There's no direct replacement.
com.infovide.qac.wmunit.WTestCase
public HashMap invokeServiceHTTPPost(String host, int port, String file, String body, String user, String password)
pl.infovide.wmunit.WmTestCase
public HashMap invokeHTTP(String host, int port, String file, String body, String user, String password)
com.infovide.qac.wmunit.WTestCase
Document invokeServiceWithoutInput(String wmPackage, String serviceName)
There's no direct replacement.
com.infovide.qac.wmunit.WTestCase
Document publishDocument(String docTypeName, Document doc)
pl.infovide.wmunit.WmTestCase
Document publish(String serverAlias, String docType, Document doc)
com.infovide.qac.wmunit.WTestCase
Document publish(String docTypeName, Document doc)
pl.infovide.wmunit.WmTestCase
Document publish(String serverAlias, String docType, Document doc)

License

WmUnit is licensed under the terms of Common public license.

Read more

If you want more information, please read instruction