Composer User's Guide

CHAPTER 12

Testing and Debugging

Novell exteNd Composer provides many aids to testing and debugging. In fact, in most cases you'll find it possible to do end-to-end animation (complete roundtrip testing) of all services in your project without having to deploy to the app server. Document input/output, XML transformations, transaction-control logic, logging, etc., can be tested in real time using "live" connections to back-end systems. Since Composer's design-time/debug-time environment executes against exactly the same Java classes that are used in the Composer Enterprise Server environment, you can have high confidence that if a service is trouble-free in the design-time setting, it will operate reliably on the app server.

Among the powerful testing and debugging features offered by Composer are:

These features and strategies for their use will be discussed in this chapter.

 
Top of page

What are the Animation Tools?

Composer's service and component editors provide animation tools that allow you to test and troubleshoot actions interactively within your services and components. You can execute a service or component's Action Model step-by-step and watch the result of each action. Not only will you see any errors as they happen, but you can verify that connections and data have behaved as you had planned.

For concentrating one particular section of an Action Model, the animation tools allow you to toggle one or more breakpoints. When used in conjunction with the run-to-breakpoint tool, breakpoints allow you to quickly run through action-model sections that work properly, coming to a stop at exactly a particular action, From there, you can step through each action in sequence. You can also, optionally, step over loops, Component Actions, and other code blocks that would otherwise be tedious to "step into."

 
Top of section

The Basic Animation Tools

The animation tools are available on the service and component editor Action Model tool bars. In addition to the Action Model tool bars, the editors provide menu options on Composer's Animate menu, as well as corresponding keyboard commands. The table below describes the various tools and their functions.

Animation Toolbar Button

Description

12IconStartAnimation

Start Animation—Clicking this button starts the animation process. Optionally, you may select Animate>Start Animation or press the F5 key.

12IconStopAnimation

End Animation—Clicking this button stops the animation process. Optionally, you may select Animate>End Animation or press the Shift + F5 keys.

12IconStepInto

Step Into—Clicking this button executes the currently selected action and highlights the next sequential action. If the currently selected action is a Component, Repeat, Decision, or Try/On Fault action, then the next highlighted action becomes the details of those actions. For a Repeat Loop pressing Step Into will execute each action in the loop as well iterate through each loop. For a Decision Action, Step Into will process the next action in the True or False branch. For the Try/On Fault action, Step Into will process the next action inside the execute, and possibly the On Fault branch. For a Component action, a separate window will open and you will "step into" that component. Optionally, you may select Animate> Step Into or press the F7 key.

12IconStepOver

Step Over—Clicking this button executes the currently selected action and highlights the next sequential action. Unlike the Step Into button, clicking this button does not highlight and execute the details of Component, Repeat, Decision, or Try/On Fault actions. For a Component action a separate window will NOT open when another service or component is called. It simply executes the call and moves onto the next sequential action; you essentially "step over" the called service or component, or Repeat, Decision, or Try/On Fault action. Optionally, you may select Animate> Step Over or press the F8 key.

12IconToggleBreakpoint

Toggle Breakpoint—Clicking this button sets the highlighted action in the Action Model as a breakpoint. You may set more than one breakpoint. Other ways to Toggle a breakpoint include selecting Animate>Toggle Breakpoint, pressing the F2 key and clicking with the RMB while in the action model.

12IconRunToBreakpoint

Run To Breakpoint/End—Clicking this button runs the animation to the next breakpoint or to the end of the Action Model. Optionally, you may select Animate>Run To Breakpoint/End or press the F9 key.

12IconPauseAnimation

Pause Animation—Clicking this button pauses the animation. Optionally, you may select Animate>Pause Animation or press the F6 key.

 
Top of section

Starting Animation

When you first open a service or component, the Start Animation and Toggle Breakpoint tools are the only "enabled" tools; the others are dimmed. Once you click the Start Animation button, the remainder of the Action Animation tools become enabled and you can click them at any point. If you want to halt the animation temporarily, you can use the Pause button. Likewise, if you want to abort the animation, you can do so at any time by clicking the red "End Animation" button.

CAUTION:    Although Copy, Paste, and action editing operations (including adding new actions) are all available at animation time, we recommend that you not edit the action model during animation. If you do, exceptions and/or unpredictable behavior may occur. If you need to edit the action model, use the Stop button to abort the animation first, then apply your edits; then begin the animation again.

Procedure To start the animation:

  1. Open a service or component. The service or component appears in its respective editor.

  2. Click the Start Animation button in the Action pane's tool bar, or press F5 on the keyboard. All of the tools on the action tool bar become active, except for the Start Animation button, which is now dimmed.

  3. Follow the instructions in the sections below to perform the desired Animation activity.

 
Top of section

Toggling a Breakpoint

The Toggle Breakpoint tool allows you to set a breakpoint in the Action Model where you'd like the process to stop. This is especially helpful if you have a lengthy Action Model with long sections that work properly. You can set the breakpoints at the beginning of each action that is causing a problem and then step through the action to troubleshoot it.

Procedure To toggle a breakpoint:

  1. Open a service or component. The service or component opens in its respective editor.

  2. Adjust the Action pane as necessary to view its content.

  3. In the Action pane, select the action where you'd like the breakpoint to be. This is where the animation will stop.

  4. Click the Toggle Breakpoint button on the Action Model tool bar, or press F2 on the keyboard. The action you select changes to a red background with white text.

  5. If desired, repeat steps 3 and 4 to select additional Breakpoints.

  6. If it is not grayed out, click the Start Animation button on the Action Model tool bar. (If Start Animation is grayed out, you can choose another animation tool to complete the animation process from the current breakpoint.) The following changes occur when you click Start Animation:

  7. Follow the instructions in the sections below to perform additional animation processes.

 
Top of section

Running To a Breakpoint

The Run to Breakpoint tool works in conjunction with the Toggle Breakpoint tool to let you control the animation process. When you have a lengthy Action Model it is helpful to be able to control how long you want the animation process to run and at which point you'd like the process to stop. The Run to Breakpoint allows you to do just that.

Procedure To run the animation to a breakpoint:

  1. Open a service or component. The service or component you open appears in its respective editor.

  2. Adjust the editor's panes as necessary to view the Action pane's content.

  3. Select the action that you'd like to be the breakpoint for your test.

  4. Click the Toggle Breakpoint button on the Action pane tool bar, or press F2 on the keyboard.

  5. Click the Start Animation button on the Action pane tool bar, or press F5 on the keyboard. The Action pane of the service or component you've opened should look similar to this:

  6. Click the Run to Breakpoint button on the Action pane tool bar, or press F9 on the keyboard. The animation process runs all of the actions prior to the breakpoint, then stops and highlights the breakpoint in red, as shown.

    12ServiceToggleBreakpoint2

  7. Follow the instructions in the sections below to continue the animation process.

 
Top of section

Stepping Into an Action

The Step Into tool runs the highlighted action in the Action Model and then moves to the next action in the sequence, even if it is inside another component. (In other words, if the next action is a Component Action, the target component opens and animation continues at the first action in that component's action model. You can use the Step Into tool to step through each action in the entire Action Model, or you can use it in conjunction with the Run to Breakpoint tool. Execution stops at the next breakpoint or when the action model ends, whichever comes first.

A possible scenario for using a breakpoint would be if you have ten actions that you know work properly but have doubts about the eleventh. You could set the eleventh action as a breakpoint, execute the Run to Breakpoint tool, and then step through the eleventh (and subsequent) action(s) by executing the Step Into tool.

NOTE:   When a service or component is called from an Action Model and a separate editor opens to display the called object, you must step through that object's Action Model to completion, at which point it closes and you return to the original Action Model.

Procedure To run the Step Into tool:

  1. Open a service or component. The service or component appears in its respective editor.

  2. Adjust the panes as necessary to view the Action Model's content.

  3. Click the Start Animation button on the Action pane tool bar, or press F5 on the keyboard. The Animation tools become active and the object's name is highlighted in the Action Model.

    12animation16

  4. Click the Step Into button on the Action tool bar, or press F7 on the keyboard. The first action becomes highlighted.

    12StepInto1

  5. Click the Step Into button again. The action executes and the next action becomes highlighted.

  6. Continue to work through the Action Model by clicking the Step Into button after each action executes and the subsequent action becomes highlighted.

  7. When an action that calls another service or component becomes highlighted, click the Step Into button. The following results:

  8. Click the Step Into button on the Action pane tool bar of the called component.

  9. Continue to click the Step Into button to execute all of the actions in the called component. When you've executed all of the actions, the window closes and you are returned to the point in the original Action Model where you left off and the next action is highlighted.

  10. Continue to click the Step Into button to execute all of the actions in the original service or component. When you are done, a message appears.

    12AnimationComplete

    NOTE:   An Action Model may call one or more components, and each component may call components as well. In each occurrence of a called component, the animation tools work exactly the same. For example, you may want to Toggle a Breakpoint within a called component and then perform a Run to Breakpoint in the original service or component. The Action Model begins to execute its actions, opens the called component, and then stops at the breakpoint you've set.

 
Top of section

Stepping Over an Action

The Step Over tool is useful when you don't want to step into the details of the Component, Repeat, Decision, or Try/On Fault actions.

For a Component action, it means you avoid the potentially timeconsuming opening of a separate editor to continue animating through the target component. The Step Over tool simply executes the target component and then highlights the next action in the Action Model.

Similarly, for blocks of code wrapped in Try/On Fault, Repeat, or other control-flow actions, using Step Over means you can execute an entire block of code at once without stepping individually through each action (which could get tiresome inside a loop).

You'll often find it handy to use the Step Over tool in conjunction with the Run to Breakpoint tool. For example, you could toggle a Breakpoint, execute the Run to Breakpoint tool, and then use the Step Over tool to execute the action you've designated as the breakpoint. The Step Over tool can save a great deal of time when testing lengthy Action Models, since you can avoid tediously stepping through individual actions that might not be of interest to you.

Procedure To use the Step Over tool:

  1. Open a service or component. The service or component appears in its respective editor.

  2. Adjust the panes as necessary to view the Action Model's content.

  3. Click the Start Animation button on the Action pane tool bar. The Animation tools become active and the object's name is highlighted in the Action Model.

    12animation22

  4. Step through the Action Model with the Step Into button until you reach a loop or other line of code that precedesan indented code block.

  5. Click the Step Over button on the Action tool bar, or press F8 on the keyboard. The first action after the block of indented code becomes highlighted. (All of the indented code will execute normally and you will be taken straight to the next "outdented" action, without needing to step through the indented action lines individually.)

  6. Continue to work through the Action Model by clicking the Step Over button as necessary.

  7. Continue to click the Step Into and/or StepOver buttons to execute all of the actions in the Action Model. When complete, a message appears.

    12AnimationComplete

 
Top of section

Pausing Animation

The Pause Animation tool allows you to pause the execution of an action in the Action Model. This is especially helpful in cases where Action Models contain lengthy loops.

Procedure To pause the animation:

  1. During the execution of an action, click the Pause Animation button on the Action pane's tool bar, or press F6 on the keyboard.

  2. To resume the animation process, click the Step Into, Step Over, or Run to Breakpoint (if a breakpoint has been set) as desired.

CAUTION:    Although Copy, Paste, and action editing operations are available when animation is paused, we recommend that you not edit the action model during animation. If you do, exceptions may occur.

 
Top of section

Aborting Animation

The Stop Animation tool simply stops the animation process. Once you stop the animation, you cannot restart from the place where you left off: you must restart from the beginning of the Action Model.

Procedure To stop the animation:

  1. While the animation is in progress, click the Stop Animation button on the Action pane's tool bar, or press Shift + F5 on the keyboard. The following message appears.

    12AnimationStopped

  2. Click OK.

 
Top of page

Execution Errors

If an action does not execute correctly, an error message appears.

12executionerror01

You can click the Details button to read more about the problem encountered. This will give you the full Java stack trace.

Error messages are also written to the System Log, which is viewable from the Composer View menu.

NOTE:   Composer's Log (or Output) pane will also show messages. To get the most comprehensive reporting of messages to the Log tab, set the Log Threshold to one in the General tab under Tools > Preferences. Also, check the Show Stack Trace checkbox in the same dialog.

12executionerror

 
Top of section

Clearing All Breakpoints

Once you have your action model working properly you will want to run through it from start to finish without interruption. To do this, you'll need to eliminate any breakpoints you had previously set. All your breakpoints can easily be removed at once using the Clear All Breakpoints menu option. This can be accessed in two ways:

  1. From the Animate menu, select Clear All Breakpoints

  2. While in the Action Panel of the Component Editor, right-click to bring up the contextual menu. Select Clear All Breakpoints.

    12ClearBreak

 
Top of section

Resetting All Documents

You may find it desirable or necessary, during a testing or debugging session, to reset the component's input, output, temp, and fault documents to their original states. You can do this manually by using the Reload XML Documents command under the Component menu on the main menubar.

 
Top of section

Clearing a Document

You can completely clear a document, including its root node, programmatically, using ECMAScript. Insert a Function Action that contains code similar to the following:

  Temp.removeChild( Temp.firstChild );

Execute the statement using the Execute button on Composer's main toolbar, or use the Apply button in the Function Action dialog. You will see the contents of the Temp document (in this case) "zero out."

NOTE:   The removeChild() method and the firstChild property are standard DOM ECMAScript extensions defined by W3C. You can use these and other methods to remove, add, or modify any portion of a document's structure in any action that uses ECMAScript. See Custom Scripting and XPath Logic in exteNd Composer, for more information.

 
Top of page

Te sting Tips

You may find it useful to leverage one or more of the following techniques when testing and debugging action models:

Each of these is discussed below.

 
Top of section

Using the ECMAScript alert() Function

You may want to inspect a data value before and/or after running a map or other type of action. To do so, you can create Function actions that contain the ECMAScript alert() function. The alert function displays a message box with a value you specify.

In the following example, an alert function action has been constructed so as to display a confirmation value of true.

12alert

NOTE:   You will want to disable any actions that use the alert() function prior to deploying your project to the app server environment. The alert() functionality is of use in design-time testing only. It should not be allowed to execute after deployment to the app server.

 
Top of section

Using a Project Variable to Turn Debugging On or Off

If your component or service contains many debugging related actions, you can ensure they do not run when your project is deployed. One way to do so is to create a project variable that can be used in a Decision action to decide whether to execute your debugging actions. Then place all your debugging-related actions inside Decision actions in your components.

Another tactic is to use a direct call into one of Composer's internal methods to determine whether the current environment is a runtime one versus a design one:

  gDebugMode = !Packages.com.sssw.b2b.rt.GNVxObjectFactory.isRuntime();

This is an example of using ECMAScript to call a custom Java method. The result here is that the (component-scoped) variable gDebugMode contains true if the component is running in Composer at design (or animation) time, but false if the component is running in a deployed project on a server.

An example of using this "sentinel variable" to decide whether it's okay to call alert() is shown below:

12DebugDecision

NOTE:   Log Actions are also invaluable for debugging and can be controlled easily via the General tab of the Preferences dialog. See "The Log Action" beginning on page 140.

 
Top of section

Watch Lists

You can watch specific data values change at animation time by adding one or more variables or data nodes to a watch list.

The watch list is visible when you bring the Watch tab (in the output pane, at the bottom of Composer's main window) to the front.

12Watch1

The Watch list is essentially an in-memory XML document (DOM) to which "watched" data items can be added or deleted. Watch-data updates in real time as you step through a component or service. Of course, the Watch view is strictly a design-time aid: It does not exist at runtime (on the server).

Watch-List Persistence and Scope

You can create a Watch list for each component and switch back and forth between components; each list is scoped to its own component.

If you add a Watch list variable or variables to a component, then re-Save the component, the Watch list will be there again the next time you open the component. The list is persisted along with the component.

You can also Save a Watch list as an XML file at any time. (Use the Save As XML menu command that appears in the context menu when you right-click the WATCH node.) This can be useful for troubleshooting purposes, since it lets you compare Watch list values at the same point in two different execution runs in two different design sessions.

Types of Variables You Can Watch

You can add two types of variables to the Watch view: ECMAScript variables and DOM nodes (for example: elements). If the DOM node is not a leaf node, it can be added to the Watch list either as a single node or with all its children. (The Watch target can be defined using XPath.)

NOTE:   Watch lists are read-only. You can add and remove items in the Watch window, but you cannot change the values of those items yourself.

How to Add Items to a Watch List

You can add items to the Watch tree in any of three ways:

Step-by-Step Example

The following steps show how to add a variable to a watch list, animate through a Component so as to see the variable change value, and delete an item from the list.

  1. Open a Component if one is not already open.

  2. Click the Watch tab (at the bottom of the Composer main window) to bring it forward.

  3. Right-mouse-click the root node ("WATCH") of the Watch view. A context menu appears. (See illustration above.)

  4. Select Add Watch from the context menu. A dialog appears:

    12Watch4

    This dialog is an expression builder: It lets you construct an ECMAScript expression that evaluates to an XPath value. You can do this in point-and-click fashion by choosing appropriate items in the pick-lists in the top three panes of the dialog. For example, if you want to add the Input element at INV:INVOICEBATCH/INV:INVOICE to your Watch list, using the above example, you would simply open the Input tree nodes as shown and doubleclick the appropriate node. The corresponding ECMAScript statement appears automatically in the text-edit field, as shown above.

    NOTE:   If you are interested in watching an ECMAScript variable, simply type the variable's name. (You must enter it by hand since ECMAScript user variables are not shown in the pick-lists.)

  5. Optionally use the Validate button to check the syntax of the expression.

  6. Close the dialog by clicking OK.

  7. Notice that the node or variable in question has been added to the Watch view. If the variable is a DOM node with children, doubleclick the node (or single-click the plus sign next to it) to toggle the node open, exposing its children and their values.

  8. Now click the Start Animation button to begin stepping through your action model.

    12Animate

  9. As you step through actions that change the values associate with the Watch variable(s), notice how the values change.

  10. To delete the Watch variable, right-mouse-click the node in question and choose Delete Watch from the context menu. The item disappears.

 
Top of page

Environmental Differences between Animation Testing and Deployment Testing

There are significant environmental differences between Animation testing in Composer and Deployment testing. Both types of testing are needed to adequately verify the components and services you build. The differences are detailed in the table below.


Testing in Composer

Deployment Testing

OS

Win98 or WinNT or Win 2000

WinNT, Sun Solaris, etc.

Platform

JRE (Java Runtime Environment)

Application Server JRE

Component or Service Startup

Directly from Composer

By Service Triggers only (i.e., deployment Servlets or EJBs).

xObject access

From disk files

From a JAR file in Application Server

Runtime Context

Test individual components or components running within a service

Always from within a service

Service and Component Inputs

Input documents frequently come from sample XML documents on the local machine as well as DOMs from other services or components

Input documents are passed into the services and components via Service Triggers, or DOMs from other services or components

Project Variables for:

  • Log File Paths

  • DTD URLs

  • XSL URLs

  • Send Mail Server

  • XML Inter-change URLs

Usually point to locations on local machine (but could be on Servers or Web)

Should point to locations on production Servers and Web

Testing Tools

In addition to Log actions, you can use dialog boxes (ECMAScript alert() function) to display runtime values

No dialog boxes can be used

JDBC Connection

Doesn't use Server Connection Pools

Uses Server-provided Connection pools

HTTP and LDAP Connections

May or may not be pointing to local machine(s) or test servers

Should be pointing to production server(s)




Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.  more ...