assertEquals(1.23f,msg.getFloat("prop"),0);
}
public void testDoubleConversion() throws Exception
{
MapMessageImpl msg;
// Boolean
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getBoolean("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Byte
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getByte("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Short
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getShort("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Char
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getChar("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Int
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getInt("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Long
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getLong("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Float
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getFloat("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
// Double
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
assertEquals(1.23,msg.getDouble("prop"),0.0000001);
// String
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
assertEquals("1.23",msg.getString("prop"));
// Bytes
msg = new MapMessageImpl();
msg.setDouble("prop",1.23);
msg.markAsReadOnly();
try { msg.getBytes("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(1.23,msg.getDouble("prop"),0);
}