Package com.ngt.jopenmetaverse.shared.structureddata

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


  @Test
  public void DeserializeIntegers()
  {
    OSD theSD = null;
    OSDArray array = null;
    OSDInteger tempInt = null;

    String testSD = "<?xml version='1.0' encoding='UTF-8'?> \n" +
        "<llsd> \n" +
        "<array> \n" +
        "<integer>2147483647</integer> \n" +
        "<integer>-2147483648</integer> \n" +
        "<integer>0</integer> \n" +
        "<integer>013</integer> \n" +
        "<integer/> \n" +
        "</array> \n" +
        "</llsd>";
    //Deserialize the string
    byte[] bytes = Utils.stringToBytes(testSD);
    theSD =XmlLLSDOSDParser.DeserializeLLSDXml(bytes);

    Assert.assertTrue(theSD instanceof OSDArray);
    array = (OSDArray)theSD;

    Assert.assertEquals(OSDType.Integer, array.get(0).getType());
    tempInt = (OSDInteger)array.get(0);
    Assert.assertEquals(2147483647, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(1).getType());
    tempInt = (OSDInteger)array.get(1);
    Assert.assertEquals(-2147483648, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(2).getType());
    tempInt = (OSDInteger)array.get(2);
    Assert.assertEquals(0, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(3).getType());
    tempInt = (OSDInteger)array.get(3);
    Assert.assertEquals(13, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(4).getType());
    tempInt = (OSDInteger)array.get(4);
    Assert.assertEquals(0, tempInt.asInteger());
  }
View Full Code Here


        Assert.assertEquals(OSDType.Map, llsdMap.getType());
        Assert.assertEquals(2, llsdMap.count());

        OSDArray llsdNestedArray = (OSDArray)llsdMap.get("t0st");
        Assert.assertEquals(OSDType.Array, llsdNestedArray.getType());
        OSDInteger llsdNestedIntOne = (OSDInteger)llsdNestedArray.get(0);
        Assert.assertEquals(OSDType.Integer, llsdNestedIntOne.getType());
        Assert.assertEquals(1, llsdNestedIntOne.asInteger());
        OSDInteger llsdNestedIntTwo = (OSDInteger)llsdNestedArray.get(1);
        Assert.assertEquals(OSDType.Integer, llsdNestedIntTwo.getType());
        Assert.assertEquals(2, llsdNestedIntTwo.asInteger());

        OSDString llsdString = (OSDString)llsdMap.get("test");
        Assert.assertEquals(OSDType.String, llsdString.getType());
        Assert.assertEquals("what", llsdString.asString());

        OSDInteger llsdIntOne = (OSDInteger)llsdArray.get(1);
        Assert.assertEquals(OSDType.Integer, llsdIntOne.getType());
        Assert.assertEquals(124, llsdIntOne.asInteger());
        OSDInteger llsdIntTwo = (OSDInteger)llsdArray.get(2);
        Assert.assertEquals(OSDType.Integer, llsdIntTwo.getType());
        Assert.assertEquals(987, llsdIntTwo.asInteger());

    }
View Full Code Here

              String sArrayTwo = "[ i0 ]";
              OSDArray llsdArrayTwo = (OSDArray)NotationalLLSDOSDParser.DeserializeLLSDNotation(sArrayTwo);
              Assert.assertEquals(OSDType.Array, llsdArrayTwo.getType());
              Assert.assertEquals(1, llsdArrayTwo.count());
              OSDInteger llsdIntOne = (OSDInteger)llsdArrayTwo.get(0);
              Assert.assertEquals(OSDType.Integer, llsdIntOne.getType());
              Assert.assertEquals(0, llsdIntOne.asInteger());

              String sArrayThree = "[ i0, i1 ]";
              OSDArray llsdArrayThree = (OSDArray)NotationalLLSDOSDParser.DeserializeLLSDNotation(sArrayThree);
              Assert.assertEquals(OSDType.Array, llsdArrayThree.getType());
              Assert.assertEquals(2, llsdArrayThree.count());
              OSDInteger llsdIntTwo = (OSDInteger)llsdArrayThree.get(0);
              Assert.assertEquals(OSDType.Integer, llsdIntTwo.getType());
              Assert.assertEquals(0, llsdIntTwo.asInteger());
              OSDInteger llsdIntThree = (OSDInteger)llsdArrayThree.get(1);
              Assert.assertEquals(OSDType.Integer, llsdIntThree.getType());
              Assert.assertEquals(1, llsdIntThree.asInteger());

              String sArrayFour = " [ \"testtest\", \"aha\",t,f,i1, r1.2, [ i1] ] ";
//             System.out.println("Start Testing ...");
              OSDArray llsdArrayFour = (OSDArray)NotationalLLSDOSDParser.DeserializeLLSDNotation(sArrayFour);
//             System.out.println("Ending Testing ...");
View Full Code Here

  @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());
    tempInt = (OSDInteger)array.get(0);
    Assert.assertEquals(2147483647, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(1).getType());
    tempInt = (OSDInteger)array.get(1);
    Assert.assertEquals(-2147483648, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(2).getType());
    tempInt = (OSDInteger)array.get(2);
    Assert.assertEquals(0, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(3).getType());
    tempInt = (OSDInteger)array.get(3);
    Assert.assertEquals(13, tempInt.asInteger());

    Assert.assertEquals(OSDType.Integer, array.get(4).getType());
    tempInt = (OSDInteger)array.get(4);
    Assert.assertEquals(0, tempInt.asInteger());
  }
View Full Code Here

TOP

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

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.