Maybe not the answer you are looking for, but as usual, the solution is to:
- Create an interface abstracting the notification functionality.
- Create a default implementation that delegates to the system notification API.
- When running tests replace (or decorate) the default implementation with a mock implementation that supports testing.
This can be simplified with the following technology:
- Dependency injection frameworks (such as RoboGuice) to streamline the choice of implementation.
- Mocking library (such as EasyMock) to automate the creation of mock implementations.