Hello all!
If a test fails with the JavaHeadlessException it is because something
is changed in ArgoUML so that some of the classes involved in the test
use classes or methods that in turn requires the graphical environment
to be rendered.
To be academic, the existence of classes that require this is bad
design.
In the real world, in ArgoUML, the design is not perfectly academic so
classes are entangled and a small change somewhere can lead to a test
case failing with JavaHeadlessException. The design is slowly improving,
especially with the work towards ArgoEclipse that I suppose will
fast-track this, but I think we can expect this for quite some time in
the future.
I can think of four ways to address this problem:
1. Remove the test case so that classes or methods that require this are
not tested.
2. Put those test cases in a separate pile so that they are not normally
tested but possible to run should a graphical environment be available.
3. Having conditional test cases that detects if the graphical
environment is required and behaves differently depending on it.
4. Having conditional classes or methods that detects if the graphical
environment is required and behaves differently depending on it.
The commit below is a case of 4, modifying ArgoUML to make a test case
run. I don't think it is a good idea.
In the Cookbook (section 2.6) the solution 2 is documented as guidelines
for the work with ArgoUML. The ordinary pile comprises classes starting
with Test and the classes that require the graphical environment-pile
comprises classes starting with GUITest. Our ant-config files are set up
to match. I still think that solution 2 is the best solution.
To reduce the confusion, we also use the java.awt.headless property when
running the normal pile test cases. That is what makes these test cases
fail with JavaHeadlessException even if there is a graphical environment
available when running them. If that is removed the test would work for
everyone, except for the nightly build that runs the tests from cron.
I have plans to fix the nightly build, running the test cases against an
Xvfb graphical environment. The reason for this is to be able to run
also the second pile nightly. Even so, I think it is a good idea to keep
the two piles striving to get the classes to the first pile because that
requires a better design. A simple check that subsystems (and packages)
that aren't GUI components don't have any GUITest* test cases can be
made to check the design on some level.
/Linus
> -----Original Message-----
> Subject: svn commit: r11792 -
> trunk/src_new/org/argouml/uml/ui/UMLLinkedList.java
...
> Log:
> Quick fix to allow tests to run. NEEDS PERMANENT FIX.
>
[...]
> private void makeDropTarget() {
> - new DropTarget(this,
> - DnDConstants.ACTION_COPY_OR_MOVE,
> - this);
> + // TODO: This test is *solely* to allow tests to complete
> without
> + // error in current environment. Tests need to be reorganize
to
> + // accommodate DnD (and to provide test coverage for it).
> + if (!GraphicsEnvironment.isHeadless()) {
> + new DropTarget(this,
> + DnDConstants.ACTION_COPY_OR_MOVE,
> + this);
> + }
> }
[...]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]