Table of Contents
Invariants: Preconditions
Point Preconditions
Task: Pass the suite tests.PointPreconditions.
Write an aspect to throw an IllegalArgumentException whenever an attempt is made to set one of the int fields of a Point to a value that is less than zero.
before advice with set and args primitive pointcuts.
This should make the test cases of tests.PointPreconditions pass, which wouldn't without your aspect.
Group Preconditions
Task: Pass the suite tests.GroupPreconditions.
Group is a FigureElement class that encapsulates groups of other figure elements. As such, only actual figure element objects should be added to Group objects. Also, a group cannot be added to itself. Write an aspect to throw an IllegalArgumentException whenever an attempt is made to call Group.add() with a null value, or with the group itself.
call and args primitive pointcuts; target primitive pointcut to capture the target of the add() call.
This should make the test cases of tests.GroupPreconditions pass.
After you have completed the exercise, remove your aspect from the build path; then continue with Exercise 4.
