Testing an MDA component

 

Testing an MDA component

As you have probably noticed, when you create a J MDA component, a folder named “Test project” is automatically created within the J MDA component. We are now going to use this folder to test two features of the Java code generator we have developed:

·         the possibility of annotating an operation with the {synchronized} tagged value or the “JavaCode” note (Figure 26).

·         the possibility of creating a Java generation work product on a class, in order to generate code for this class (Figure 27).

 

Start by creating the following model within the “Test project” folder:

 

Figure 25. The package, class and operation you should create inside the “Test project” folder

 

 

Testing the availability of new attributes and notes

To check that the {synchronized} attribute is available to annotate operations, carry out the steps shown in Figure 26 below.

 

Figure 26. Checking the availability of the tagged value you created during the quick tour project

 

Steps:

1.      In the explorer, select the “testOperationSynchronized” operation you created within the "Test project" folder.

2.      Click on the  icon in the “Auxiliary properties” tab of the auxiliary window.

3.      Scroll down the list of available tagged values until you see the “synchronized” tagged value.

4.      Select this tagged value and then click on “Create.

 

To check the availability of the “JavaCode” note type, carry out the same steps, but instead of clicking on the  icon, click on the  icon.

 

 

Testing the “Generate” command

To check the “Generate” command defined inside the “JavaGenerator” J MDA component, carry out the steps shown in Figure 27 below.

 

Figure 27. Checking the "Generate" command on a class

 

Steps:

1.      In the explorer, right-click on the class you have created in the "Test project" folder. The context menu then appears.

2.      Run the “JavaGenerator/Generate” command.

 

The results of this operation are as follows:

o        the generation is automatically launched

o        the “TestClass.java” file is generated in the generation directory specified when the “Generate” command was created: “C:\project\java”.

·          

Figure 28. The content of the generated file