@Test
public void testSerialize() throws JVoiceXMLEvent {

    final DataModel model = new EcmaScriptDataModel();
    model.createScope(Scope.SESSION);
    model.evaluateExpression("var A = new Object();", Object.class);
    model.evaluateExpression("A.B = 'test';", Object.class);
    model.evaluateExpression("A.C = new Object();", Object.class);
    model.evaluateExpression("A.C.D = 42.0;", Object.class);
    model.evaluateExpression("A.C.E = null;", Object.class);
    final DataModelObjectSerializer serializer = new KeyValueSerializer();
    final Object object = model.readVariable("A", Object.class);
    final Collection<KeyValuePair> pairs = serializer.serialize(model, "A",
            object);
    Assert.assertEquals(2, pairs.size());
    final Iterator<KeyValuePair> iterator = pairs.iterator();
    final KeyValuePair pair1 = iterator.next();
    Assert.assertEquals("A.B", pair1.getKey());
    Assert.assertEquals("test", pair1.getValue());
    final KeyValuePair pair2 = iterator.next();
    Assert.assertEquals("A.C.D", pair2.getKey());
    Assert.assertEquals("42", pair2.getValue());
}