|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hyphenType.optionsextractor.OptionsExtractor<T> org.hyphenType.unittesting.UnitTestingOptionExtractor<T>
T
- public class UnitTestingOptionExtractor<T extends Options<?>>
An OptionsExtractor
that is ready for unit tests. This kind of
OptionsExtractor
will replace the actual routines to terminate the
JVM (Options#exit(Enum)
and Options#exit(int)
) with mock
implementations. Calls for exit methods will be logged and can be read by
unit tests after the code under test was executed. To analyze the usage of
exit methods, the following methods are available:
ArgumentsProcessorEngine
).
ArgumentsProcessorEngine
,
OptionsExtractor
Constructor Summary | |
---|---|
UnitTestingOptionExtractor(Class<T> clazz)
Creates a new UnitTestingOptionExtractor object that will work as
a factory for objects whose options interface's class is the class given
as argument. |
|
UnitTestingOptionExtractor(Class<T> clazz,
boolean throwsNotExceptionalExit)
Creates a new UnitTestingOptionExtractor object in a way that
allows the caller to chose whether or not calls to
Options#exit(Enum) or Options#exit(int) will result into
throwing a NonExceptionalExit exception. |
Method Summary | |
---|---|
protected InvocationHandler |
buildInvocationHandler(OptionValues<T> values,
Class<? extends Options<?>> optionsInterface,
Class<? extends StatusCode> exitCodeEnumClass,
String[] rawArguments)
Prepared to be replaced by a subclass. |
boolean |
exitEnumCalled(T options)
Returns whether or not the method Options#exit(Enum) was called
on the given options. |
boolean |
exitIntCalled(T options)
Returns whether or not the method Options#exit(int) was called on
the given options. |
Enum<?> |
getStatusCodeEnum(T options)
Retrieves the status code of a certain options object. |
int |
getStatusCodeInt(T options)
Retrieves the status code (int) of a certain options object. |
Methods inherited from class org.hyphenType.optionsextractor.OptionsExtractor |
---|
options, options |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnitTestingOptionExtractor(Class<T> clazz) throws InvalidOptionsInterfaceException
UnitTestingOptionExtractor
object that will work as
a factory for objects whose options interface's class is the class given
as argument. This constructor will configure
UnitTestingOptionExtractor
to factor option objects that throw
NonExceptionalExit
exceptions. If you want to chose whether or
not the options objects will throw NonExceptionalExit
, use the
constructor
UnitTestingOptionExtractor(Class, boolean)
instead.
clazz
-
InvalidOptionsInterfaceException
InvalidOptionException
public UnitTestingOptionExtractor(Class<T> clazz, boolean throwsNotExceptionalExit) throws InvalidOptionsInterfaceException
UnitTestingOptionExtractor
object in a way that
allows the caller to chose whether or not calls to
Options#exit(Enum)
or Options#exit(int)
will result into
throwing a NonExceptionalExit
exception.
clazz
- The option interface class.throwsNotExceptionalExit
- A flag to configure whether option objects will throw
NonExceptionalExit
when one calls
Options#exit(Enum)
or Options#exit(int)
.
InvalidOptionsInterfaceException
InvalidOptionException
NonExceptionalExit
Method Detail |
---|
protected InvocationHandler buildInvocationHandler(OptionValues<T> values, Class<? extends Options<?>> optionsInterface, Class<? extends StatusCode> exitCodeEnumClass, String[] rawArguments)
OptionsExtractor
OptionsExtractor
is useful to replace the composition of objects that will process the
arguments.
buildInvocationHandler
in class OptionsExtractor<T extends Options<?>>
public boolean exitEnumCalled(T options)
Options#exit(Enum)
was called
on the given options.
options
-
public Enum<?> getStatusCodeEnum(T options)
Options#exit(Enum)
is called. If
Options#exit(Enum)
was never called on the given options object,
this method will throw a RuntimeException
. You can call
exitEnumCalled(Options)
to avoid
having to catch the exception.
options
- The options object that we will extract the status code
enumeration from.
Options#exit(Enum)
was
already called.
RuntimeException
- If the method Options#exit(Enum)
was never called.public boolean exitIntCalled(T options)
Options#exit(int)
was called on
the given options.
options
-
public int getStatusCodeInt(T options)
Options#exit(int)
is called. If
Options#exit(int)
was never called on the given options object,
this method will throw a RuntimeException
. You can call
UnitTestingOptionExtractor#exitEnumCalled(int)
to avoid having to
catch the exception.
options
- The options object that we will extract the status code
integer from.
Options#exit(int)
was
already called.
RuntimeException
- If the method Options#exit(int)
was never called.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |