/**
* Tests that all supported types survive a serialize-deserialize cycle.
*/
@Test
public void testSerDeser() {
Metadata metadata = new MetadataBuilder()
.value("string", "value")
.value("int", 5)
.value("long", 99999999999L)
.value("float", 3.33f)
.value("double", 6.66d)
.value("boolean", Boolean.TRUE)
.value("bytes", new ByteArray("foobar".getBytes()))
.value("date", time)
.build();
DataOutput output = new DataOutputImpl();
MetadataSerDeser.write(metadata, output);
byte[] metadataBytes = output.toByteArray();
Metadata readMetadata = MetadataSerDeser.read(new DataInputImpl(metadataBytes));
assertEquals("value", readMetadata.get("string"));
assertEquals(5, (int)readMetadata.getInt("int", null));
assertEquals(99999999999L, (long)readMetadata.getLong("long", null));
assertEquals(3.33f, readMetadata.getFloat("float", null), 0.001f);
assertEquals(6.66d, (double)readMetadata.getDouble("double", null), 0.001d);
assertEquals(true, readMetadata.getBoolean("boolean", null));
assertArrayEquals("foobar".getBytes(), readMetadata.getBytes("bytes").getBytes());
assertEquals(time ,readMetadata.getDateTime("date", null).toDateTime(DateTimeZone.getDefault()));
}