}
public void testCurrencyCodeIsHonouredWhenCurrencyCodeAndCurrencySymbolIsSet()
{
NumberConverter converter = getNumberConverter();
Mock mock = buildMockUIComponent(2);
UIComponent component = (UIComponent) mock.proxy();
converter.setLocale(Locale.US);
converter.setType("currency");
Double value = new Double(99);
setFacesContext(facesContext);
try
{
String outPut = converter.getAsString(facesContext, component, value);
assertEquals("$99.00", outPut);
//Locale is US. By general convention the output prefix would be '$'
// since we set the currency code to 'DEM' value should be DEM[value]
converter.setCurrencyCode("DEM");
// Let us set the symbol to '*'. This should not take effect, since currency
// code is set.
converter.setCurrencySymbol("*");
outPut = converter.getAsString(facesContext, component, value);
assertEquals("DEM99.00", outPut);
try
{
if(converter.getAsObject(facesContext, component, "DEM99.00") instanceof Number)
{
// FIXME =-= sobryan: this is not reporting an error as of
// JSF 1.1_02 - should it? I'm thinking not because adam documented
// that the error was not reported in JSF 1.2 either.
//fail("Exception should occur - since currency should not be considered while formatting");
}
}
catch(Exception e)
{
;//Expected to fail.
}
}
finally
{
setFacesContext(null);
}
mock.verify();
}