Testing Java code

After writing Java™ code to modify pattern instances, test the code to check that it works correctly.

Before you begin

Before you test your Java code, you must build the pattern plug-ins; see Building pattern plug-ins.

About this task

You can test your Java code either by creating an instance of a pattern and checking that it is modified as you expect or by using the Java debugger to step through the code.

Procedure

  • To test your user-defined pattern by creating an instance of the pattern, see Testing a user-defined pattern.
  • To use the Java debugger, you must open a temporary workspace to generate an instance of your user-defined pattern, then return to the original workspace to step through the code. To use the Java debugger, complete the following steps:
    1. In your Java code file, add a breakpoint to the required line of code. To add a breakpoint, right-click the marker bar (vertical ruler) to the left of the required code and click Toggle Breakpoint.
    2. In the Pattern Authoring editor, click the Create Pattern tab.
    3. Click Debug Pattern.
      The Workspace Launcher window opens.
    4. Select the temporary workspace in which to generate an instance of your user-defined pattern. Click Browse and select a workspace or enter a workspace in the Workspace field. Click OK.
      The selected workspace opens.
    5. In the temporary workspace, you must generate an instance of your user-defined pattern. In the Application Development view, click the Patterns Explorer tab and select your user-defined pattern.
    6. In the Pattern Specification tab, click Create New Instance. Enter a name for the instance of your user-defined pattern and click OK.
    7. Enter any mandatory pattern parameters and click Generate.
      The generation of the pattern instance stops when it reaches the breakpoint in your Java code.
    8. In the original workspace, in the Confirm Perspective Switch window, click Yes.
      The original workspace switches to debug mode and shows the code paused at your breakpoint.
    9. You can now use the Java debugger to test your code; see Java Debugger.
    10. When you have finished testing the code in the Java debugger, close the temporary workspace and switch back to the Integration Development perspective in the original workspace; see IBM App Connect Enterprise Toolkit perspectives.

What to do next

You can either change your Java code and retest it or you can package and distribute your user-defined pattern:
To ensure that changes in your Java code are included in your generated pattern, change the version number of the Java plug-in, as described in the following steps.
  1. Update the version number of the Java plug-in in manifest.mf.
  2. Update the version number of the pattern on the Create Pattern tab.
  3. Re-create the pattern plug-ins and pattern archive, as described in Building pattern plug-ins.

    To check that the pattern archive contains the correct versions of the plug-ins, you can look at the feature.xml file.

  4. Install the pattern.