My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
SimpleExceptionTest  
Dealing with Exceptions in jSupervisor.
Updated Aug 18, 2010 by panwei...@gmail.com

The source for this discussion is available in SimpleExceptionTest.java

This examples shows how jSupervisor deals with exceptions. There are two test methods:

  • testAuthentication_successful
  • testAuthentication_unsuccessful

testAuthentication_successful. This test case test is for succssful detection of expected exception.

1. Specifier spec = supervisor.getSpecifier() ; 
2. spec.excepts(new ConnectionException("Cannot connect well.")); 
3. myAuthenticationServer.connect("foo"); 

The expected excaption is declared in Line 2. It will be thrown by the invocation declared in Line 3. This is a valid sequence and the scenario plays out to completion.

testAuthentication_unsuccessful. This test case is for successful detection of incorrect exception.

1. Specifier spec = supervisor.getSpecifier() ; 
2. spec.excepts(new Exception("Unexpected Exception.")); 
3. myAuthenticationServer.connect("foo"); 

Line 2 here expects an exception of class Exception which will not be the actual exception thrown. This results in an execution failure and the scenario cannot run till completion.

Powered by Google Project Hosting