patterntesting.exception
Interface ExceptionFactoryMBean

All Known Implementing Classes:
ExceptionFactory

@Description(value="ExceptionFactory to control exceptions")
public interface ExceptionFactoryMBean

The Interface ExceptionFactoryMBean.


Field Summary
static String ALL_CLASSES
          The default value for setScope(String) if nothing was set.
 
Method Summary
 void activate()
          You can only provoke Exceptions if the active flag is set.
 void activateOnce()
          If you want to provoke an Exception only for the next time use this method.
 void deactivate()
          You don't want to provoke an exception any longer?
 String getFire()
          Only exceptions of this returned type will be fired.
 Throwable getLastProvoked()
          Gets the last provoked exception.
 String getLimitedTo()
          Deprecated. replaced by getFire() (will be removed with 1.2)
 long getMaxNumberOfProvoked()
          Gets the max number of provoked exceptions.
 long getNumberOfProvoked()
          Gets the number of provoked exceptions.
 String getScope()
          Returns the scope for which the exceptions will be thrown.
 boolean isActive()
          Checks if is active.
 boolean isAssertsEnabled()
          To see if the (Sun) Java-VM was called with the option "-ea" ("enable asserts") this getter shows it.
 void reset()
          Resets all preferences.
 void resetFire()
          Allows again that all exceptions would be fired.
 void resetScope()
          To set the scope back to "all classes" use this method here.
 void setActive(boolean activ)
          You can only provoke Exceptions if the active flag is set.
 void setFire(String classname)
          You want to provoked an SocketException whenever it is possible?
 void setLimitedTo(String limitedTo)
          Deprecated. replaced by setFire(String) (will be removed with 1.2)
 void setMaxNumberOfProvoked(long n)
          Limit the number of provoked maximal total number of provoked exceptions to n.
 void setScope(String classname)
          To limit the exception to be thrown for a given class you can use this method here.
 

Field Detail

ALL_CLASSES

static final String ALL_CLASSES
The default value for setScope(String) if nothing was set.

See Also:
Constant Field Values
Method Detail

isActive

boolean isActive()
Checks if is active.

Returns:
true, if is active

setActive

@Description(value="exceptions can only be provoked it is set to active")
void setActive(boolean activ)
You can only provoke Exceptions if the active flag is set.

Parameters:
activ - true or false

activate

@Description(value="Exceptions will be provoked until the deactivate method is called")
void activate()
You can only provoke Exceptions if the active flag is set. Call this method to set it.


activateOnce

@Description(value="Exceptions will be only provoked once")
void activateOnce()
If you want to provoke an Exception only for the next time use this method.


deactivate

@Description(value="Exceptions will be no  longer provoked")
void deactivate()
You don't want to provoke an exception any longer? Then call this method.


isAssertsEnabled

@Description(value="JavaVM started with \'-ea\'?")
boolean isAssertsEnabled()
To see if the (Sun) Java-VM was called with the option "-ea" ("enable asserts") this getter shows it.

Returns:
true if asserts are enabled

getLastProvoked

@Description(value="returns the last provoked exception")
Throwable getLastProvoked()
Gets the last provoked exception.

Returns:
the last exception which was thrown by one of the provoke methods

getLimitedTo

@Deprecated
@Description(value="only exception of this sub type are thrown")
String getLimitedTo()
Deprecated. replaced by getFire() (will be removed with 1.2)

Only exceptions of this returned type are thrown. The return value is a String because of the use as MBean (works better in the JConsole).

Returns:
the limitedTo (e.g. "java.lang.Throwable")

setLimitedTo

@Deprecated
@Description(value="limit the exceptions only to methods which have it in the signature")
void setLimitedTo(String limitedTo)
                  throws ClassNotFoundException
Deprecated. replaced by setFire(String) (will be removed with 1.2)

You want to limit the provoked exceptions to IOException? Then give it as parameter to this setter method.
For better use with the JConsole the class could given as String. But don't forget to give the complete classname (with package) as String.

Parameters:
limitedTo - e.g. "java.io.IOException"
Throws:
ClassNotFoundException - the class not found exception

getFire

@Description(value="only exception of this sub type are thrown")
String getFire()
Only exceptions of this returned type will be fired. The return value is a String because of the use as MBean (works better in the JConsole).

Returns:
the exeption to be fired (e.g. "java.lang.Throwable")
Since:
1.1

setFire

@Description(value="fire this exception whenver it is possible")
void setFire(String classname)
             throws ClassNotFoundException
You want to provoked an SocketException whenever it is possible? Then give it as parameter to this setter method.
If you want to reset it and want to provoke any exception set it to Throwable or call the resetFire() method.
For better use with the JConsole the class could given as String. But don't forget to give the complete classname (with package) as String.

Parameters:
classname - e.g. "java.io.IOException"
Throws:
ClassNotFoundException - if parameter is not a class name
Since:
1.1

resetFire

@Description(value="enables all exceptions again")
void resetFire()
Allows again that all exceptions would be fired.

Since:
1.1

getNumberOfProvoked

@Description(value="total number of provoked exceptions")
long getNumberOfProvoked()
Gets the number of provoked exceptions.

Returns:
the number of provoked exceptions

setMaxNumberOfProvoked

@Description(value="how many exceptions should be provoked?")
void setMaxNumberOfProvoked(long n)
Limit the number of provoked maximal total number of provoked exceptions to n.

Parameters:
n - the maximal number of provoked exceptions (default is Long.MAX_VALUE)

getMaxNumberOfProvoked

@Description(value="gets the max number of provoked exceptions")
long getMaxNumberOfProvoked()
Gets the max number of provoked exceptions.

Returns:
the maximal number of provoked exceptions (default is Long.MAX_VALUE)

setScope

@Description(value="the factory can be registered for a given classname")
void setScope(String classname)
To limit the exception to be thrown for a given class you can use this method here. At the moment a scope is only limited to the class itself. Perhaps in the future this can change - than super classes or interfaces may be also supported as parameter.
A string is excepted instead of a Class object because of the jconsole. With the jconsole only basic types or strings are available as input fields.

Parameters:
classname - for which an exception should be thrown
Since:
1.1

resetScope

@Description(value="to set the scope back to all classes")
void resetScope()
To set the scope back to "all classes" use this method here.

Since:
1.1

getScope

@Description(value="returns the scope for which the exceptions will be thrown")
String getScope()
Returns the scope for which the exceptions will be thrown. The default value is "all classes" if the scope is not set.

Returns:
class for which an exception will be thrown.
Since:
1.1

reset

@Description(value="resets all preferences")
void reset()
Resets all preferences.

Since:
1.1


Copyright © 2009-2010 PatternTesting Team. All Rights Reserved.