pyswarm Documentation (http://pyswarm.sourceforge.net/)

2.3.  Generating Your Application

Congratulations, you finished the model of your first pyswarm system including a neat implementation diagram and a class diagram. It is pretty easy, isn't it? And with a little routine you will become very quick in modeling real applications.

All you need to manage pyswarm project settings and generate applications is already brought to you by the pyswarm SDK. I assume, you already have a working pyswarm SDK installation, as described in the Part II, “SDK Installation Manual” and you have customized the SDK preferences to the local environment of your machine by using pyswarm-sdk-edit.py, which should reside along with all other command-line tools in the same directory, by default the scripts directory of Python. The Part VI, “SDK Manual” provides detail information on all commands.

In general the entire generation process is conrolled by the script pyswarm-generate.py. In order to avoid to tell the pyswarm-generate command for each generation run what to do exactly, you just create a new project where you can specify project-specific settings that are stored in the project file, e.g. which XMI-file to use for the generation or where to store the generation log-file. This project-file is passed to the generator which then inspects it and decides how to proceed.

So, the first thing we need to do is to create a new pyswarm project file ( * .pysp file). After doing that we will use this PYSP file to generate the PetStore application.

[Tip] Tip

If you have installed the downloaded projects directly into your home directory, you can use the ~/projects/petstore.pysp file instead of creating your own pysp file. Just make sure that the specified XMI file (~/projects/PetStore/PetStore.xml) of this pysp is really the file you want to use for your test generation.

  1. Start a shell

  2. Assuming, that all your project data is installed in ~/projects/, please enter a line similar to the following (customize paths and filenames where necessary):

    (use with-out line breaks)

    $ > pyswarm-new.py ~/projects/petstore.pysp ~/projects/PetStore/PetStore.xml --app= ~/projects/apps/PetStore/ --pyspname= "My PetStore Project"

    • ~/projects/petstore.pysp is the new pyswarm project file you want to create and in which we store the following project settings (thus we don't need to provide them at the next step).

    • ~/projects/PetStore/PetStore.xml is the XMI-file with the UML model of the application we had designed in this tutorial and which we want to generate next.

    • ~/projects/apps/PetStore/ is the directory in which the SDK will generate all versions of this project's generations. Each version will be put into its own sub-directory of this location where the name of the sub-directory is the timestamp of the generation.

    • "My PetStore Project" is the title for this project. However this is just for your convenience, it has no effect to the application.

    [Important] Important

    If any option arguments, i.e. paths, contain empty spaces or other ambigious signs just put those arguments between two double-quotes, e.g. --app= "~/projects/PetStore/generated app sources"

    [Note] Note

    You can find more information on this command in Section 3.5, “ Create Project: pyswarm-new ”.

  3. Now we can just execute pyswarm-generate.py from the shell - as it is described here - or from an IDE which allows you to provide additional arguments to the execution command.

    (use with-out line breaks)

    $ > pyswarm-generate.py ~/projects/petstore.pysp --tolerant

    • That's it. We call the generator with the command-line script pyswarm-generate.py and tell it to generate the project specified in the given PYSP file, using the tolerant mode.

      [Important] Important

      Please note that the generator will throw some error and warning messages. This will happen since the PetStore model is incomplete, e.g. some nodes and sub-packages are empty. This should not prevent you from testing the address part of the generated application as described in the following sections.

    • Since we don't provide further options the generator will take the project settings or as fall-back the SDK preferences.

      [Note] Note

      You can find more information on this command in Section 3.4, “ Copy Project: pyswarm-generate ”.

Procedure 2.33. Create and Generate an pyswarm Project File for the PetStore Example

This document was created using the >e-novative> DocBook Environment (eDE)