STEPlib SysML: How To use the Scripts to Generate implementation specific test data

Warning

../../_images/construction.png

This page is under construction.

To contribute or participate contact support@boost-lab.net

This page explains how to use the Scripts of the STEP architecture to generate the implementation specific Test Data files from the Test Data XML exported from MagicDraw. The instructions for generating the Test Data model can be found in STEPlib SysML: How To model Test Data.

Prerequisites

This assumes that:

Execution

Generate the Test Data XML

Note

These scripts are work in progress and will be consolidated at a future date.

The scripts assume that the XSD has already been generated as described in STEPlib SysML: How To use the XSD Scripts.

The video shows the steps in this process.



Export from MagicDraw

  1. Download the scriptssteplib AP243_working branch from: http://git2.boost-lab.net/admins/scriptssteplib/tree/AP243_working

  2. In MagicDraw use File > Export To > UML 2.5 XMI File the following to XML files and store in scriptssteplib:

    • Domain Model Test Data model to file Domain_model_TestData.xml

Flatten the xsd that was generated as part of the IS documentation

This script flattens the extensions in the XSD. It copies the DataContainer, and then for each complexType it flattens the extensions so that all the elements are listed in the order expected by the sequence. It removes all the inner content for the elements making the output file much smaller, but it is not a valid xsd - only to be used for sorting the TestData XML.

Check scriptssteplib/AntTestData/VariablesData.xml has the correct value for DataContainer and update if necessary.

  • (in Windows) open a cmd window from the scriptssteplib/AntTestData/ folder and run the following:

    java -jar ../saxon9.jar -t ../AntImp/DomainModel.xsd TestData_flatten_xsd.xsl > ../AntImp/DomainModel_flatten.xsd
    
    .
    

Generate an unsorted XML from the MagicDraw XML export

Check scriptssteplib/AntTestData/VariablesData.xml has the correct values (including for the xsd as generated in the previous step set as domain_model_xsd_file) and update if necessary.

Tip

The <RootPackageName> is the name of the SysML Package below which the TestData will be gathered. All immediate child packages will be created in their own DataContainer, but from then on packages will be flattened.

The <Header> is copied directly into the output XML so must be valid, the content for <Header> in VariablesData.xml is illustrative and the minimum valid content.

Generate the AP TestDataUnsorted.xml from the Domain_model_TestData.xml as follows:

  • (in Windows) open a cmd window from the scriptssteplib/AntTestData/ folder and run the following:

    java -jar ../saxon9.jar -t ../Domain_model_TestData.xml TestData_to_xml.xsl > TestDataUnsorted.xml
    
    .
    
  • (in Windows) to generate the results with debugging comments run the following:

    java -jar ../saxon9.jar -t debugMode=1 ../Domain_model_TestData.xml TestData_to_xml.xsl > TestDataUnsorted.xml
    
    .
    

The resultant file is: scriptssteplib/AntTestData/TestDataUnsorted.xml

Sort the XML

The next step is to sort the XML into the correct sequence as specified by the flattened XSD created in the first step. Check scriptssteplib/AntTestData/VariablesData.xml has the correct values. This script uses the DataContainer and domain_model_xsd_file, where the latter is the file generated in the first step.

  • (in Windows) open a cmd window from the scriptssteplib/AntTestData/ folder and run the following:

    java -jar ../saxon9.jar -t TestDataUnsorted.xml TestData_sort_xml.xsl > TestData.xml
    
    .
    
  • (in Windows) to generate the results with debugging comments run the following:

    java -jar ../saxon9.jar -t debugMode=1 TestDataUnsorted.xml TestData_sort_xml.xsl > TestData.xml
    
    .
    

The resultant file is: scriptssteplib/AntTestData/TestData.xml

Generate the Test Data JSON

Todo

text for this section

Section author: Judith Crockford (AP243)