JSeq is a tool for automatically generating sequence diagrams from actual program runs. It can be used stand-alone, or in combination with JUnit.
You need the following to use JSeq:
See the installation instructions for information about how to configure your system to use JSeq.
To document scenarios in your UML model, you can use JSeq in combination with JUnit. In this case, you create one JUnit test case for each scenario that you want to document; JSeq then automatically creates sequence diagrams for the scenarios, based on the test cases.
I have not yet created an Ant task for running JSeq. However, this does not have to stop you from using Ant to generate your sequence diagrams. You can use the java task to start JSeq, like so:
<target name="make_diagram" depends="compile_tests"> <java fork="yes" classname="th.co.edge.jseq.Main" taskname="JSeq" failonerror="true"> <arg line="-format argouml"/> <arg line="-out ${basedir}/scenarios.zargo"/> <arg line="junit.textui.TestRunner"/> <arg line="scenarios.AllScenarios"/> <classpath refid="jseq.class.path"/> </java> </target>
In the example above, you create an ArgoUML model file called scenarios.zargo , based on the tests in the Java class scenarios.AllScenarios .
See the tutorial for a hands-on example of how this works.
To run JSeq from the command line, you use the jseq script. It can be used in one of three different ways: to start a new program; to attach to a running program; or to generate a new diagram for a previous run.
To start a new Java program and generate a diagram from the program run, you use
jseq [-options] <class> [args...]
To attach to a running Java program, you use
jseq [-options] -attach <address>
In this case, the Java program must have been started to allow debuggers to attach to it. See the documentation for your Java virtual machine for more information. For Sun's implementation, information can be found in the documentation for jdb.
An example for Sun's Java 2 SDK:
Start your program like this:
java -Xdebug -Xrunjdwp:transport=dt_shmem,address=mytest,server=y,suspend=n MyTestProgram
Start JSeq and attach to the running program:
jseq -attach mytest
To generate a sequence diagram from a previous run of JSeq, you use
jseq [-options] -read <filename>
In this case, the file to read should have been saved by an earlier invocation of JSeq, using the -save option.
Options for running a program
-classpath <path> | Sets the classpath that JSeq uses when running a program. |
-cp <path> | Same as -classpath . |
-save <filename> | Saves the program trace in a file, so that you can generate different diagrams from it without having to run the program again. |
Options for generating sequence diagrams
-out <filename> | Saves the diagram to a file. |
-format <format> | Generates different types of diagrams. Valid values for <format> ; are argouml , svg and text . |
-quiet | Does not generate any diagram. Useful in combination with -save . |
-start <methodname> | Generates a program trace and sequence diagram starting with the given method name. Can speed of execution of JSeq. |
-exclude <class regexp> | Excludes classes matching <class regexp>
when generating the program trace and the diagram. Can speed up execution of JSeq. The <class regexp> is a simplified regular expression, that must either be an exact match, or start or end with "*". For example, -exclude foo.bar.* and -exclude *.frotz are legal, while -exclude foo.*.frotz is not. You can give more than one -exclude option. |
-nostdexcludes | Does not exclude standard Java classes from the program trace and diagram. By default, the following packages are excluded: java.* , javax.* , sun.* , com.sun.* , junit.* . Please note that if you include all classes, the program trace will normally take a very long time to generate. |
Other options
-notrace | Turns off logging of method entries, etc. to System.err . By default, JSeq generates log output to show that is actually working. :-) |
-version | Prints version information to System.out and exits. |
This is a list of known problems in this version of JSeq.
I have only tested the BAT file on Windows 2000. I know that it will not work on Windows 95/98. I'm not sure about other Windows versions.
To work around this in JSeq with good results would require duplicating ArgoUML's layout code, something I feel is not a good idea. The proper solution to this problem is to fix ArgoUML.
Luckily, you just have to click on one of the method names in the diagram to fix this.