OSD theSD = null;
OSDMap map = null;
OSD tempSD = null;
OSDUUID tempUUID = null;
OSDString tempStr = null;
OSDReal tempReal = null;
String testSD = "<?xml version='1.0' encoding='UTF-8'?> \n" +
"<llsd> \n" +
"<map> \n" +
"<key>region_id</key> \n" +
"<uuid>67153d5b-3659-afb4-8510-adda2c034649</uuid> \n" +
"<key>scale</key> \n" +
"<string>one minute</string> \n" +
"<key>simulator statistics</key> \n" +
"<map> \n" +
"<key>time dilation</key> \n" +
"<real>0.9878624</real> \n" +
"<key>sim fps</key> \n" +
"<real>44.38898</real> \n" +
"<key>agent updates per second</key> \n" +
"<real>nan</real> \n" +
"<key>total task count</key> \n" +
"<real>4</real> \n" +
"<key>active task count</key> \n" +
"<real>0</real> \n" +
"<key>pending uploads</key> \n" +
"<real>0.0001096525</real> \n" +
"</map> \n" +
"</map> \n" +
"</llsd>";
//Deserialize the string
byte[] bytes = Utils.stringToBytes(testSD);
theSD =XmlLLSDOSDParser.DeserializeLLSDXml(bytes);
//Confirm the contents
Assert.assertNotNull(theSD);
Assert.assertTrue(theSD instanceof OSDMap);
System.out.println(theSD.getType().toString());
Assert.assertTrue(theSD.getType() == OSDType.Map);
map = (OSDMap)theSD;
tempSD = map.get("region_id");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDUUID);
Assert.assertTrue(tempSD.getType() == OSDType.UUID);
tempUUID = (OSDUUID)tempSD;
Assert.assertEquals(new UUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.asUUID());
tempSD = map.get("scale");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDString);
Assert.assertTrue(tempSD.getType() == OSDType.String);
tempStr = (OSDString)tempSD;
Assert.assertEquals("one minute", tempStr.asString());
tempSD = map.get("simulator statistics");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDMap);
Assert.assertTrue(tempSD.getType() == OSDType.Map);
map = (OSDMap)tempSD;
tempSD = map.get("time dilation");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(0.9878624d, tempReal.asReal(), 0);
//TODO - figure out any relevant rounding variability for 64 bit reals
tempSD = map.get("sim fps");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(44.38898d, tempReal.asReal(), 0);
tempSD = map.get("agent updates per second");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(Double.NaN, tempSD.asReal(), 0);
tempSD = map.get("total task count");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(4.0d, tempReal.asReal(), 0);
tempSD = map.get("active task count");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(0.0d, tempReal.asReal(), 0);
tempSD = map.get("pending uploads");
Assert.assertNotNull(tempSD);
Assert.assertTrue(tempSD instanceof OSDReal);
Assert.assertTrue(tempSD.getType() == OSDType.Real);
tempReal = (OSDReal)tempSD;
Assert.assertEquals(0.0001096525d, tempReal.asReal(), 0);
}