#1114 Easily fixed compiler errors when compiling "jcommon" source

1.0.x
open
nobody
5
2014-08-18
2013-07-31
David Tonhofer
No

Some errors when compiling source in Eclipse, demanding source code tuning

1) In JCommon:

   SerialUtilitiesTest.testGradientPaintSerialization()

Line 194: assertEquals(gp1.getColor1(), gp2.getColor1());

"gp2 may be null at this location"

--> Solution: One should not catch and suppress the potential Exception a few
lines earlier but let it up the stack.

2) In JCommon:

   SerialUtilitiesTest.testAlphaCompositeSerialization()

Line 232: assertEquals(ac1.getRule(), ac2.getRule());

"gp2 may be null at this location"

--> Solution: One should not catch and suppress the potential Exception a few
lines earlier but let it up the stack.

3) ... More generally...

There are quite a lot of

    catch (Exception e) {
        e.printStackTrace();
    }

in these test cases, which does not make much sense. These are test cases and
Exceptions should fail the test case in which they occur.

Recommending to let thse Exception up the stack

4) Same problem in:

   org.jfree.ui.junit.Size2DTests.testCloning()
   org.jfree.ui.junit.BooleanListTests.testCloning()
   org.jfree.ui.junit.ObjectListTests.testCloning()
   org.jfree.ui.junit.ShapeListTests.testCloning()

where Exceptions are incongruously caught using:

   catch (CloneNotSupportedException e) {
        System.err.println("BooleanListTests.testCloning: failed to clone.");
   }

Discussion