assertEquals("123",msg.getString("prop"));
}
public void testBytesConversion() throws Exception
{
MapMessageImpl msg;
byte[] dummy = { (byte)1 , (byte)2 , (byte)3 };
// Boolean
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getBoolean("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Byte
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getByte("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Short
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getShort("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Char
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getChar("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Int
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getInt("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Long
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getLong("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Float
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getFloat("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Double
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getDouble("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// String
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
try { msg.getString("prop"); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
assertEquals(3,msg.getBytes("prop").length);
// Bytes
msg = new MapMessageImpl();
msg.setBytes("prop",dummy);
msg.markAsReadOnly();
byte[] data = msg.getBytes("prop");
assertEquals(3,data.length);
assertEquals(1, data[0]);
assertEquals(2, data[1]);
assertEquals(3, data[2]);
}