Package com.ngt.jopenmetaverse.shared.structureddata

Examples of com.ngt.jopenmetaverse.shared.structureddata.OSD


 
 
  @Test
  public void DeserializeLLSDSample()
  {
    OSD theSD = null;
    OSDMap map = null;
    OSD tempSD = null;
    OSDUUID tempUUID = null;
    OSDString tempStr = null;
    OSDReal tempReal = null;

    String testSD = "[ \n" +
        "{ \n" +
        "\"region_id\": \"67153d5b-3659-afb4-8510-adda2c034649\", \n" +
        "\"scale\": \"one minute\", \n" +
        "\"simulator statistics\": { \n" +
        "\"time dilation\": 0.9878624, \n" +
        "\"sim fps\": 44.38898, \n" +
//        "\"agent updates per second\": NaN, \n" +
        "\"total task count\": 4.0, \n" +
        "\"active task count\": 0.0, \n" +
        "\"pending uploads\": 0.0001096525 \n" +
        "}\n" +
        "}\n" +
        "]";

    //Deserialize the string
    System.out.println(testSD);
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =JsonLLSDOSDParser.DeserializeLLSDJson(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);

  }
View Full Code Here


  /// Test that various Real representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeReals()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDReal tempReal = null;

    String testSD ="[ \n" +
        "[ \n" +
View Full Code Here

  /// Test that various String representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeStrings()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDString tempStr = null;

    String testSD = "[ \n" +
        "[ \n" +
View Full Code Here

  /// it's understood if there was a design reason for the Int32.
  /// </summary>
  @Test
  public void DeserializeIntegers()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDInteger tempInt = null;

    String testSD ="[ \n" +
        "[ \n" +
        "2147483647, \n" +
        "-2147483648, \n" +
        "0, \n" +
        "013, \n" +
        "0 \n" +
        "] \n" +
        "]";
    //Deserialize the string
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =JsonLLSDOSDParser.DeserializeLLSDJson(bytes);

    System.out.println("=========" + theSD.getType().toString());
   
    Assert.assertTrue(theSD instanceof OSDArray);
    array = (OSDArray)theSD;

    Assert.assertEquals(OSDType.Integer, array.get(0).getType());
View Full Code Here

  /// Test that various UUID representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeUUID()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDUUID tempUUID = null;

    String testSD = "[ \n" +
        "[ \n" +
View Full Code Here

  /// Test that various date representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeDates()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDDate tempDate = null;
    Date[] testDate = new Date[1];

    String testSD = "[ \n" +
View Full Code Here

  /// Test that various Boolean representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeBoolean()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDBoolean tempBool = null;

    String testSD = "[ \n" +
        "[ \n" +
View Full Code Here

  /// Test that binary elements are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeBinary()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDBinary tempBinary = null;

    String str1 = "This is test String 1";
    byte[] bytes1 = Utils.stringToBytes(str1);
View Full Code Here

  /// current implementation generates an instance of SD
  /// </summary>
  @Test
  public void DeserializeUndef()
  {
    OSD theSD = null;

    String testSD = "[ \n" +
        "null \n" +
        "]";
    //Deserialize the string
View Full Code Here

  /// Test that various URI representations are parsed correctly.
  /// </summary>
  @Test
  public void DeserializeURI() throws URISyntaxException
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDUri tempURI = null;

    String testSD = "[ \n" +
        "[ \n" +
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.structureddata.OSD

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.