Package com.ngt.jopenmetaverse.shared.structureddata

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


          }

          @Test
          public void SerializeUUID() throws IOException, OSDException
          {
              OSD llsdOne = OSD.FromUUID(new UUID("97f4aeca-88a1-42a1-b385-b97b18abb255"));
              String sOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSD llsdOneDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.UUID, llsdOneDS.getType());
              Assert.assertEquals("97f4aeca-88a1-42a1-b385-b97b18abb255", llsdOneDS.asString());

              OSD llsdTwo = OSD.FromUUID(new UUID("00000000-0000-0000-0000-000000000000"));
              String sTwo = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdTwo);
              OSD llsdTwoDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sTwo);
              Assert.assertEquals(OSDType.UUID, llsdTwoDS.getType());
              Assert.assertEquals("00000000-0000-0000-0000-000000000000", llsdTwoDS.asString());
          }
View Full Code Here


          }

          public void DeserializeString() throws OSDException, IOException
          {
              String sOne = "''";
              OSD llsdOne = NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.String, llsdOne.getType());
              Assert.assertEquals("", llsdOne.asString());

              // This is double escaping. Once for the encoding, and once for csharp. 
              String sTwo = "'test\\'\"test'";
              OSD llsdTwo = NotationalLLSDOSDParser.DeserializeLLSDNotation(sTwo);
              Assert.assertEquals(OSDType.String, llsdTwo.getType());
              Assert.assertEquals("test'\"test", llsdTwo.asString());

              // "test \\lest"
              char[] cThree = { (char)0x27, (char)0x74, (char)0x65, (char)0x73, (char)0x74, (char)0x20, (char)0x5c,
                                  (char)0x5c, (char)0x6c, (char)0x65, (char)0x73, (char)0x74, (char)0x27 };
              String sThree = new String(cThree);

              OSD llsdThree = NotationalLLSDOSDParser.DeserializeLLSDNotation(sThree);
              Assert.assertEquals(OSDType.String, llsdThree.getType());
              Assert.assertEquals("test \\lest", llsdThree.asString());

              String sFour = "'aa\t la'";
              OSD llsdFour = NotationalLLSDOSDParser.DeserializeLLSDNotation(sFour);
              Assert.assertEquals(OSDType.String, llsdFour.getType());
              Assert.assertEquals("aa\t la", llsdFour.asString());

              char[] cFive = { (char)0x27, (char)0x5c, (char)0x5c, (char)0x27 };
              String sFive = new String(cFive);
              OSD llsdFive = NotationalLLSDOSDParser.DeserializeLLSDNotation(sFive);
              Assert.assertEquals(OSDType.String, llsdFive.getType());
              Assert.assertEquals("\\", llsdFive.asString());


              String sSix = "s(10)\"1234567890\"";
              OSD llsdSix = NotationalLLSDOSDParser.DeserializeLLSDNotation(sSix);
              Assert.assertEquals(OSDType.String, llsdSix.getType());
              Assert.assertEquals("1234567890", llsdSix.asString());

              String sSeven = "s(5)\"\\\\\\\\\\\"";
              OSD llsdSeven = NotationalLLSDOSDParser.DeserializeLLSDNotation(sSeven);
              Assert.assertEquals(OSDType.String, llsdSeven.getType());
              Assert.assertEquals("\\\\\\\\\\", llsdSeven.asString());

              String sEight = "\"aouAOUhsdjklfghskldjfghqeiurtzwieortzaslxfjkgh\"";
              OSD llsdEight = NotationalLLSDOSDParser.DeserializeLLSDNotation(sEight);
              Assert.assertEquals(OSDType.String, llsdEight.getType());
              Assert.assertEquals("aouAOUhsdjklfghskldjfghqeiurtzwieortzaslxfjkgh", llsdEight.asString());



          }
View Full Code Here

          }

          public void DoSomeStringSerializingActionsAndAsserts(String s) throws IOException, OSDException
          {
              OSD llsdOne = OSD.FromString(s);
              String sOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSD llsdOneDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.String, llsdOne.getType());
              Assert.assertEquals(s, llsdOneDS.asString());
          }
View Full Code Here

          @Test
          public void DeserializeURI() throws OSDException, IOException
          {
              String sUriOne = "l\"http://test.com/test test>\\\"/&yes\"";
              OSD llsdOne = NotationalLLSDOSDParser.DeserializeLLSDNotation(sUriOne);
              Assert.assertEquals(OSDType.URI, llsdOne.getType());
              Assert.assertEquals("http://test.com/test%20test%3E%22/&yes", llsdOne.asString());

              String sUriTwo = "l\"test/test/test?test=1&toast=2\"";
              OSD llsdTwo = NotationalLLSDOSDParser.DeserializeLLSDNotation(sUriTwo);
              Assert.assertEquals(OSDType.URI, llsdTwo.getType());
              Assert.assertEquals("test/test/test?test=1&toast=2", llsdTwo.asString());
          }
View Full Code Here

          public void SerializeURI() throws URISyntaxException, OSDException, IOException
          {
            URI uriOne[] = new URI[1];
    
              Utils.tryParseUri("http://test.org/test test>\\\"/&yes\"", uriOne);
              OSD llsdOne = OSD.FromUri(uriOne[0]);
              String sUriOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
//              System.out.println("sUriOne: " + sUriOne);
              OSD llsdOneDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sUriOne);
              Assert.assertEquals(OSDType.URI, llsdOneDS.getType());
              Assert.assertEquals(uriOne[0], llsdOneDS.asUri());

            URI uriTwo[] = new URI[1];

            Utils.tryParseUri("test/test/near/the/end?test=1", uriTwo);
              OSD llsdTwo = OSD.FromUri(uriTwo[0]);
              String sUriTwo = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdTwo);
              OSD llsdTwoDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sUriTwo);
              Assert.assertEquals(OSDType.URI, llsdTwoDS.getType());
              Assert.assertEquals(uriTwo[0], llsdTwoDS.asUri());
          }
View Full Code Here

          @Test
          public void DeserializeDate() throws OSDException, IOException
          {
              String sDateOne = "d\"2007-12-31T20:49:10Z\"";
              OSD llsdOne = NotationalLLSDOSDParser.DeserializeLLSDNotation(sDateOne);
              Assert.assertEquals(OSDType.Date, llsdOne.getType());
             
               Calendar cal = Calendar.getInstance();
            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
              cal.set(Calendar.MILLISECOND, 0);
             
              cal.set(2007, 11, 31, 20, 49, 10);
              Date dt = cal.getTime();
              Date dtDS = llsdOne.asDate();
              Assert.assertEquals(dt, dtDS);
          }
View Full Code Here

            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
              cal.set(Calendar.MILLISECOND, 0);
             
              cal.set(2005, 7, 10, 11, 23, 4);
              Date dtOne = cal.getTime();
              OSD llsdOne = OSD.FromDate(dtOne);
              String sDtOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSD llsdOneDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sDtOne);
              Assert.assertEquals(OSDType.Date, llsdOneDS.getType());
              Date dtOneDS = llsdOneDS.asDate();
              Assert.assertEquals(dtOne, dtOneDS);

              cal.set(2010, 9, 11, 23, 00, 10);
              cal.set(Calendar.MILLISECOND, 100);
              Date dtTwo = cal.getTime();
             
              OSD llsdTwo = OSD.FromDate(dtTwo);
              String sDtTwo = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdTwo);
              OSD llsdTwoDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sDtTwo);
              Assert.assertEquals(OSDType.Date, llsdTwoDS.getType());
              Date dtTwoDS = llsdTwoDS.asDate();
//              System.out.println(dtTwo.getTime() + " : " + dtTwoDS.getTime());
              Assert.assertEquals(dtTwo, dtTwoDS);

              // check if a *local* time can be serialized and deserialized
              cal.set(2009, 12, 30, 8, 25, 10);
              cal.set(Calendar.MILLISECOND, 0);
             
              Date dtThree = cal.getTime();
              OSD llsdDateThree = OSD.FromDate(dtThree);
              String sDateThreeSerialized = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdDateThree);
              OSD llsdDateThreeDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sDateThreeSerialized);
              Assert.assertEquals(OSDType.Date, llsdDateThreeDS.getType());
              Assert.assertEquals(dtThree, llsdDateThreeDS.asDate());
          }
View Full Code Here

          public void SerializeBinary() throws OSDException, IOException
          {
              byte[] binary = { 0x0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0b,
                                  0x0b, 0x0c, 0x0d, 0x0e, 0x0f };

              OSD llsdBinary = OSD.FromBinary(binary);
              String sBinarySerialized = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdBinary);
              OSD llsdBinaryDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sBinarySerialized);
              Assert.assertEquals(OSDType.Binary, llsdBinaryDS.getType());
              Assert.assertArrayEquals(binary, llsdBinaryDS.asBinary());
          }
View Full Code Here

              String sOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSDArray llsdOneDS = (OSDArray)NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.Array, llsdOneDS.getType());
              Assert.assertEquals(0, llsdOneDS.count());

              OSD llsdTwo = OSD.FromInteger(123234);
              OSD llsdThree = OSD.FromString("asedkfjhaqweiurohzasdf");
              OSDArray llsdFour = new OSDArray();
              llsdFour.add(llsdTwo);
              llsdFour.add(llsdThree);

              llsdOne.add(llsdTwo);
View Full Code Here

              String sOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSDMap llsdOneDS = (OSDMap)NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.Map, llsdOneDS.getType());
              Assert.assertEquals(0, llsdOneDS.count());

              OSD llsdTwo = OSD.FromInteger(123234);
              OSD llsdThree = OSD.FromString("asedkfjhaqweiurohzasdf");
              OSDMap llsdFour = new OSDMap();
              llsdFour.put("test0", llsdTwo);
              llsdFour.put("test1", llsdThree);

              llsdOne.put("test0", llsdTwo);
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.