Testing interoperability productions without connecting to external systems

Primary tabs

Hello all,
I'm trying to write tests for an interoperability production using %UnitTest.TestProduction. I'd like to control the behavior of the SOAP operations so they don't actually connect to external systems when I'm testing. My first thought for this is to create a mock outbound adapter class that answers with some configured class method:

Class UnitTest.Helper.Integration.MockSoapAdapter Extends EnsLib.SOAP.OutboundAdapter

Property MockAdapterAnswerClass As %String;

Property MockAdapterAnswerMethod As %String;

Parameter SETTINGS = "MockAdapterAnswerClass,MockAdapterAnswerMethod";

Method InvokeMethod(pMethodName As %String, Output pResult As %RegisteredObject, pArgs...) As %Status
    return $classmethod(..MockAdapterAnswerClass, ..MockAdapterAnswerMethod, pMethodName, .pResult, pArgs...)


And then in my test I could inject the mock adapter and the answer method through the settings:

ClassMethod SomeAnswer(pMethodName As %String, Output pResult As %RegisteredObject, pArgs...) As %Status
    // define some test behavior here

Method OnAfterProductionStart() As %Status
    $$$QuitOnError(..ChangeSetting(,"Some Operation", "Adapter", "UnitTest.Helper.Integration.MockSoapAdapter"))
    $$$QuitOnError(..ChangeSetting(,"Some Operation", "MockAdapterAnswerClass", ..%ClassName(1)))
    $$$QuitOnError(..ChangeSetting(,"Some Operation", "MockAdapterAnswerMethod", "SomeAnswer"))
    // create request, send request, verify response

But I'm finding I can't actually change the outbound adapter class as a setting on the operation. Does anybody have ideas on how to connect an operation to a mock outbound adapter class in a test context? Or is there something simpler I should be doing? Thanks.

  • 0
  • 1
  • 96
  • 3
  • 1


I'd add another Operation called MockSOAPOperation which accepts SOAP requests and calls your method.

After that change Business Host setting(s) to point to this mock operation.

Thanks for the reply. How can my unit test configure a BPL process to call my mock operation instead of the real operation? Do I have to rewrite the business process to use indirection in the target of each <call> element and make the target a custom setting on the business host?

Well, I always specify BH calls with indirection, so I guess my answer would be yes.


You might consider using OnBeforeProductionStart() instead of OnAfterProductionStart() when you want to change settings.