R
Rhino
I'm trying to figure out how to write a test case for this code. The code
is pretty simple but I can't think of a way to test it with JUnit3.
Here's the code:
--------------------------------------------------------------------
public ResourceBundle getResources(Locale currentLocale, String
listBase) {
final String METHOD_NAME = "getResources()"; //$NON-NLS-1$
ResourceBundle locList = null;
/* Get the list resource bundle for the current locale. */
try {
locList = ResourceBundle.getBundle(listBase, currentLocale);
} catch (MissingResourceException mr_excp) {
Object[] msgArgs = {CLASS_NAME, METHOD_NAME, listBase,
currentLocale.toString(), mr_excp};
msgFmt.applyPattern(locMsg.getString("msg011")); //$NON-
NLS-1$
throw new IllegalArgumentException(msgFmt.format(msgArgs));
}
return (locList);
}
----------------------------------------------------------------------
If the method returned a null ResourceBundle, that would be relatively easy
to test for. But if it doesn't find the "listBase" value, it will simply
find the next best fit, assuming there is a reasonable alternative and
therefore not return null.
Any suggestions?
is pretty simple but I can't think of a way to test it with JUnit3.
Here's the code:
--------------------------------------------------------------------
public ResourceBundle getResources(Locale currentLocale, String
listBase) {
final String METHOD_NAME = "getResources()"; //$NON-NLS-1$
ResourceBundle locList = null;
/* Get the list resource bundle for the current locale. */
try {
locList = ResourceBundle.getBundle(listBase, currentLocale);
} catch (MissingResourceException mr_excp) {
Object[] msgArgs = {CLASS_NAME, METHOD_NAME, listBase,
currentLocale.toString(), mr_excp};
msgFmt.applyPattern(locMsg.getString("msg011")); //$NON-
NLS-1$
throw new IllegalArgumentException(msgFmt.format(msgArgs));
}
return (locList);
}
----------------------------------------------------------------------
If the method returned a null ResourceBundle, that would be relatively easy
to test for. But if it doesn't find the "listBase" value, it will simply
find the next best fit, assuming there is a reasonable alternative and
therefore not return null.
Any suggestions?