}
@Test
public void testBooleanWrapper() throws Exception
{
BooleanWrapper wrapper = new BooleanWrapper();
wrapper.setElement(createElement("bool", Boolean.toString(true)));
assert (Boolean) wrapper.convert(Boolean.class);
assert (Boolean) wrapper.convert(Boolean.TYPE);
try
{
// Try an invalid conversion
wrapper.convert(InvalidClass.class);
assert false;
}
catch (ConversionException ex)
{
}
// test the marshal() method
ByteArrayOutputStream out = new ByteArrayOutputStream();
wrapper.marshal(out);
byte[] expected = ("<bool>" + Boolean.toString(true) + "</bool>")
.getBytes();
assertEquals(expected, out.toByteArray());
// test the conversionScore() method
assert ConversionScore.exact == wrapper.conversionScore(Boolean.class);
assert ConversionScore.exact == wrapper.conversionScore(Boolean.TYPE);
assert ConversionScore.compatible == wrapper
.conversionScore(Object.class);
assert ConversionScore.nomatch == wrapper
.conversionScore(InvalidClass.class);
}