IBM
Contents Index Previous Next



Using More Complex Selections


Apart from manually selecting items in the Browser, you can make more complex selections by using the Selector. These selections can then be displayed in a sub Browser.

The Selector tool is available from the Browser Tools menu. Like the other TTCN Suite tools, the Selector tool works on selections. The purpose of the Selector tool is to, from an existing selection, create a new selection.

With the Selector, you can make selections in three ways:

You can make selections by specifying restrictions on table names, restrictions on tables types and even restrictions on the contents of the tables.

Restrictions can also include the analysis status of the table, i.e. not analyzed, error and OK.

Selections can also be made depending on references between TTCN objects. A typical use of this feature might be to select (and perhaps later Convert to TTCN-MP) an entire Test Case, i.e. the Test Case Behaviour and all its associated declarations, constraints, Test Steps etc.

Note: UNIX only

The Selector is only available on UNIX.

Tools > Selector

Creates a new selection from a given selection. The Selector dialog is opened:

Figure 185 : Selector dialog

Name Restriction

Enables the user to define the restrictions on the identifiers of the named TTCN tables (e.g. ASPs, PDUs, Constraints, Test Cases, Test Steps and Defaults) to be selected. This restriction is a regular expression (see Regular Expressions). If the name restriction field is empty then no restrictions on the table names will apply.

Example 191

The name restriction ^abc will select all tables whose names begin with the string "abc".

Type Restriction

Enables the user to define the restrictions on which kind of TTCN tables that are to be selected. Click once to select one or more table types.

Example 192

Suppose that the initial selection is the entire Dynamic Part. Choosing the table types Test Case Dynamic Behaviour and Test Step Dynamic Behaviour together with the name restriction ^abc will select all test cases and test steps whose names begin with the string "abc".

If no table types at all are selected then no type restrictions are assumed to apply (i.e. the same effect as selecting all table types).

Content Restriction

Enables the user to define the restrictions on the contents of TTCN tables that are to be selected. This restriction is a regular expression (see Regular Expressions). If the content restriction field is empty then no restrictions on the contents of tables will apply.

Example 193

Suppose that the initial selection is the entire TTCN document. Choosing the table type TTCN PDU Type Definition together with the Content restriction ^xyz will select all TTCN PDUs which have a field beginning with the string "xyz".

Select Mode

Enables the user to choose a select mode: restrict, extend or replace.

Figure 186 : Selector mode

Relations

When a TTCN document is analyzed, the TTCN Suite builds a symbol table of all the named TTCN objects that are in the TTCN document. If required, the Selector will perform a `look-up' in this table in order to select referenced objects.

It is required that the TTCN document is analyzed before applying the Selector with the Relations option. This will ensure that the entries in the symbol table are consistent with the TTCN document on the screen.

There are three kinds of references: References, References recursively and Referenced by

Example 194

If the initial selection is a single test case and we make a type restriction of Test Step Dynamic Behaviour but no Name or Content restrictions, then choosing Extend and References will add to the current selection all the test steps (if any) that the selected test case references.

Example 195

To extract an entire test, select the desired test case and apply Extend and References recursively without any other restrictions. The Selector will select the Test Case Behaviour and all its associated declarations, constraints, attached Test Steps (including any Test Steps that these Test Steps may attach), Defaults etc. The Convert to MP command can then be used to output this test case in TTCN-MP format.

Example 196

If the initial selection is a single PDU definition, then choosing Extend and Referenced by without any other restrictions will select all the objects (e.g. constraints and behaviours) that use this PDU type.

Keeping and Retrieving a Selection

File > Keep Selection

Saves the current selection for later retrieval. This operation may, for example, be used when an Access application is to be applied on the TTCN document. To be able to retrieve the saved selection in another session the Save Document command needs to be issued after this command. For more information see Getting Started with TTCN Access.

File > Retrieve Selection

Retrieves the saved selection.

Searching by Using the Selector

A search pattern (regular expression) can be defined for either the complete content of a set of objects or only for the names.

A search always operates with a Browser selection as its scope. It will produce another selection as the result. By creating a sub Browser from the resulting selection a convenient environment for viewing the objects that fulfilled the search predicate is achieved.

Making Sub Browsers from Selections

Often, after making a selection, it is useful to make a sub Browser which only contains the items which are selected. This can easily be done by using the Browser command from the Tools menu of the Browser.

Example 197

Applying the Selector on an entire TTCN document with the Analyze status option set to error will select all objects that have syntax and/or static semantic errors. Choosing the Browser command from the Tools menu of the Browser where the selection was applied will create a Sub-browser that only contains the error objects (including the structure needed to "glue" them together).

Regular Expressions

When you use the Selector or search from the Table Editor, string patterns are used for matching and searching for named objects or text strings. In UNIX terminology these patterns are called regular expressions. Regular expressions include symbols specifying the pattern to be searched for. Some of these symbols are:

\ < > ^ $ [ ] *

Use of these symbols in regular expressions involves a quite complicated syntax which can be very powerful. We illustrate some common uses below, but for full information we suggest that the user takes a look at the UNIX manual entry for regexp (do a man regexp), and look under the heading Regular Expressions.

Example 198

TTCN tables contain fields. Fields contain text strings. Text strings contain words.

The pattern abc will match all words that include the string "abc", e.g. abcxyz xyzabc, xyzabcxyz, abc.

The pattern \<abc\> will match all words that are exactly "abc". This is useful for finding TTCN identifiers embedded in strings and comments.

The pattern ^abc will match any field that begins with the string "abc", e.g. abcxyz abc, abcabc.

The pattern abc$ will match any field that ends with the string "abc", e.g. xyzabc, abc, abcabc.

The pattern ^abc$ will only match fields containing exactly "abc".

The pattern abc[1-5]$ will select all fields that end with "abc" and a single number between 1 and 5, e.g. abc1 and xyzabc4, but not abc7 or abc12.


http://www.ibm.com/rational
Contents Index Previous Next