OpenTTCN/Training/TTCN-3 Basics/Exercises/3.5
From OpenTTCN
Exercise 3.5: Using multiple modules
Goal: In this exercise we are learning how to use multiple modules.
Step 1: Using multiple modules
Many programming languages contain facilities how to slit definitions into modules and how to refer definitions of other modules. Instead of "module" (TTCN-3, TTCN-2, IDL) term other terms such as "package" (Java) and "namespace" (C++) are used.
Language Concept Mechanism to use ============================================================== C++ namespace using IDL module include Java package import TTCN-3 module import
The exact criteria how to select which definitions to slit into different modules is outside the scope of "TTCN-3 Basics" but splitting is used to make created modules more manageable and more modular. Maybe the following types of modules could be created: main, configuration, types, messages, functions, test cases, templates, control part, etc.
Step 2: Split DNSMainModule
Instructions 1:
Define your own slitting criteria and for the sake of an exercise split your "DNSMainModule" TTCN-3 module into 2-4 modules that are in their own files. Please notice that each separate module needs to have a separate module name. If two module uses the same name the tool cannot tell that they are different modules, but one of the will be shadowed by the other.
Instructions 2:
Insert correct "import from CorrectModuleNameHere all;" statements to appropriate modules you have created so that you import (make visible) necessary definitions in those places they are used.
Instructions 3:
Load the new modules again into the "dnsc" testing session. Check the session status to see how the new modules are reported. Of course, try to run the "TC_receive" test case again to see that your new test suite configuration works.
Summary
Well done! You have just completed your fifth TTCN-3 exercise of today. During this exercise you learned how to use multiple modules. You are now ready to proceed to the next exercise to learn how to specify attributes to instruct coding and decoding.
