Performing Basic Operations in Unit Testing Mode

How to:

This tutorial demonstrates basic operation in unit testing mode, illustrating breakpoints, single stepping, setting the input document, and modifying registers.

Note: Though not illustrated in the tutorials, it is possible to abbreviate commands, tokens, and switches up to an unambiguous prefix. For example, the letter b is sufficient for the breakpoint command. A node name can also be abbreviated. It will be resolved among the nodes of the flow.


Top of page

x
Procedure: How to Perform Basic Operations in Debugger

For this tutorial, the process flow called testflow has already been deployed to channel file1. It stores the name of the root element in the special register reg1 and tests whether reg1 has the value default.

  1. Start the debugger by typing the following command in the iSM console:
    Enter Command:> tool Debugger

    The debugger starts and responds with the debug> prompt, with the following default message:

    Command line process flow debugger
    Type help for more information
    debug>

    The following image illustrates the process flow that is being referenced by this tutorial.

  2. Change the default source to the source code of this flow as follows:
    debug> set source file1:testflow
    Current source changed to file1:testflow
  3. List the nodes in the process flow and their relationships as follows:
    debug> list
    Node Start in source file1:testflow
      OnCompletion -> SetReg1
        OnSuccess -> 'Is Default?'
          true -> Default
            OnSuccess -> End
          false -> NotDefault
            OnSuccess -> End

The output has one line per node, beginning with the Start node. The outgoing edges are listed underneath, indented one level to the right. The format is edgename -> nodename.

For example, the second line says there is an OnCompletion edge from the Start node to the SetReg1 node. In the subsequent lines, the Is Default? node has two out edges, true and false because they appear at the same indentation level.

You can use the list command to find out the exact names of the nodes.


Top of page

x
Procedure: How to Execute the First Run
  1. Set a breakpoint on the ‘Is Default?’ node. The name must be in quotes because it contains a space and a special character.
    debug> breakpoint 'Is Default?'
    breakpoint created
    b1: breakpoint -source file1:testflow 'Is Default?' -inedge
  2. Run the flow with the default document.
    debug> run
    Thread t1: W.debugger.1~file1:testflow started
    Thread t1: W.debugger.1~file1:testflow suspended
    by breakpoint at inedge of 'Is Default?'

    The execution stops at the breakpoint.

  3. Inspect the values of the special registers.
    debug> show registers
    Registers in pflow scope and above
       ibse-port = [CFG] '9000'
       iway.channel = [SYS] 'debugger'
       iway.config = [SYS] 'myapp'
       iway.flowname = [DOC] 'W.debugger.1~file1:testflow'
       iway.lastnode = [SYS] 'SetReg1'
       iway.pid = [SYS] '12748'
       iway.serverfullhost = [SYS] 'portable.ibi.com'
       iway.serverhost = [SYS] 'portable'
       iway.serverip = [SYS] '192.168.2.12'
       iway.startup.time = [SYS] '1401722478791'
       iway.workdir = [SYS] 'c:/iway/config/myapp'
       iwayconfig = [SYS] 'myapp'
       iwaydata = [SYS] 'c:/iway/'
       iwayhome = [SYS] 'c:/iway/'
       iwayversion = [SYS] '7.0.2'
       iwayworkdir = [SYS] 'c:/iway/config/myapp'
       name = [SYS] 'debugger'
       protocol = [SYS] 'Lcl'
       reg1 = [USR] 'default'
       tid = [DOC] 'b489cc73-ecf5-43b5-8cc5-9faab83cd972'
  4. Execute a single step.
    debug> step
    Thread t1: W.debugger.1~file1:testflow suspended
    at inedge of Default

    The reg1 register contains the value default, therefore the execution steps to the Default node.

  5. Resume execution.
    debug> resume
    Thread t1: W.debugger.1~file1:testflow resumed
    Thread t1: W.debugger.1~file1:testflow terminated normally with 1
    document

    The flow reaches the End node and terminates.

  6. Show the output document. For this flow, it is the same as the input document.
    debug> show document
    Document 0 from End
    <default/>

Top of page

x
Procedure: How to Execute the Second Run
  1. Run the flow again. Execution stops at the breakpoint.
    debug> run
    Thread t2: W.debugger.2~file1:testflow started
    Thread t2: W.debugger.2~file1:testflow suspended
    by breakpoint at inedge of 'Is Default?'
  2. Set the value of the reg1 register to elem.
    debug> set register reg1 elem
  3. Execute a single step.
    debug> step
    Thread t2: W.debugger.2~file1:testflow suspended
    at inedge of NotDefault

    This time, the execution reaches the NotDefault node, since the register value is not default.

  4. Resume execution. The flow terminates.
    debug> resume
    Thread t2: W.debugger.2~file1:testflow resumed
    Thread t2: W.debugger.2~file1:testflow terminated normally with 1
    document

Top of page

x
Procedure: How to Execute the Third Run
  1. Delete the breakpoint.
    debug> delete b1
    deleted b1: breakpoint -source file1:testflow 'Is Default?' -
    inedge
  2. Create a breakpoint on the Default node and another on the NotDefault node. Show the breakpoints.
    debug> breakpoint Default
    Breakpoint created
    b2: breakpoint -source file1:testflow Default -inedge
    debug> breakpoint NotDefault
    Breakpoint created
    b3: breakpoint -source file1:testflow NotDefault -inedge
    debug> show breakpoints
    b2: breakpoint -source file1:testflow Default -inedge
    b3: breakpoint -source file1:testflow NotDefault -inedge
  3. Execute the flow for the third time. Set the input document to change the root element name.
    debug> run -xml <test/>
    Thread t3: W.debugger.3~file1:testflow started
    Thread t3: W.debugger.3~file1:testflow suspended
    by breakpoint at inedge of NotDefault

    The execution reaches the NotDefault node, since the reg1 register does not have the value default.

  4. Show the value of the reg1 register.
    debug> show register reg1
    reg1 = [USR] 'test'
  5. Resume execution. The flow terminates.
    debug> resume
    Thread t3: W.debugger.3~file1:testflow resumed
    Thread t3: W.debugger.3~file1:testflow terminated normally with 1
    document

Top of page

x
Procedure: How to Execute the Fourth Run
  1. Add an outedge breakpoint on the 'Is Default?' node.
    debug> breakpoint 'Is Default?' -outedge
    breakpoint created
    b4: breakpoint -source file1:testflow 'Is Default?' -outedge
  2. Rerun the flow with the same arguments as the last run. In particular, the input document is <test/>.
    debug> rerun
    Thread t4: W.debugger.4~file1:testflow started
    Thread t4: W.debugger.4~file1:testflow suspended
    by breakpoint at outedge of 'Is Default?'

    The execution stops after the 'Is Default?' node is processed but before the edges are dispatched.

  3. Display the returned edges. The edge is false because the root element is not called default.
    debug> show edges
    Returned edge: false
  4. Change the returned edge to true, and step to the next node.
    debug> set edges true
    debug> step
    Thread t4: W.debugger.4~file1:testflow suspended
    by breakpoint at inedge of Default

    The execution reaches the Default node because the edge was changed to true.

  5. End the debugger session. This will abort the execution of the flow before leaving the tool.
    debug> end
    Tool Debugger complete

iWay Software