String[] types = {"number", "percent", "currency", "pattern"};
String[] customMessage = {"number", "percent", "currency", "pattern"};
for (int i = 0; i < failingValues.length ; i++)
{
MockFacesContext12 context = new MockFacesContext12(externalContext,
lifecycle,
application);
try
{
Mock mock = buildMockUIComponent(3);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
org.apache.myfaces.trinidad.convert.NumberConverter converter =
new org.apache.myfaces.trinidad.convert.NumberConverter();
UIViewRoot root = facesContext.getViewRoot();
root.setLocale(Locale.US);
for (int j = 0; j < 3; j++)
{
context.setViewRoot(root);
}
try
{
// ADF Converter is not lenient.
converter.setMessageDetailConvertNumber(customMessage[0]);
converter.setMessageDetailConvertPercent(customMessage[1]);
converter.setMessageDetailConvertCurrency(customMessage[2]);
converter.setMessageDetailConvertPattern(customMessage[3]);
if ("pattern".equals(types[i]))
converter.setPattern("##.000");
else
converter.setType(types[i]);
Object obj = converter.getAsObject(context, component, failingValues[i]);
fail("Expected converter exception");
}
catch (ConverterException ce)
{
// We expected a exception to occur
assertEquals(ce.getFacesMessage().getDetail(), customMessage[i]);
}
}
finally
{
context.release();
}
}
}