aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Serialization
diff options
context:
space:
mode:
authordr scofield (aka dirk husemann)2009-10-01 12:01:41 +0200
committerdr scofield (aka dirk husemann)2009-10-01 12:01:41 +0200
commit05da73c300b8ed2105febb8de8f2d302b8dbe599 (patch)
treefb6d09bac70d77d0f6dfb0ef4f5933587b7622a0 /OpenSim/Framework/Serialization
parentMerge branch 'oar-parcel' into x-opensim (diff)
downloadopensim-SC_OLD-05da73c300b8ed2105febb8de8f2d302b8dbe599.zip
opensim-SC_OLD-05da73c300b8ed2105febb8de8f2d302b8dbe599.tar.gz
opensim-SC_OLD-05da73c300b8ed2105febb8de8f2d302b8dbe599.tar.bz2
opensim-SC_OLD-05da73c300b8ed2105febb8de8f2d302b8dbe599.tar.xz
fixing LandDataSerializer (yeah! for testcases)
Diffstat (limited to 'OpenSim/Framework/Serialization')
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs36
-rw-r--r--OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs12
2 files changed, 29 insertions, 19 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
index e9af2ca..e980945 100644
--- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -91,20 +91,26 @@ namespace OpenSim.Framework.Serialization.External
91 landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID")); 91 landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID"));
92 92
93 landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); 93 landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
94 xtr.ReadStartElement("ParcelAccessList"); 94 xtr.Read();
95 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 95 if (xtr.Name != "ParcelAccessList")
96 { 96 throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name));
97 ParcelManager.ParcelAccessEntry pae;
98 97
99 xtr.ReadStartElement("ParcelAccessEntry"); 98 if (!xtr.IsEmptyElement)
100 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID")); 99 {
101 pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time")); 100 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
102 pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList")); 101 {
103 xtr.ReadEndElement(); 102 ParcelManager.ParcelAccessEntry pae;
104 103
105 landData.ParcelAccessList.Add(pae); 104 xtr.ReadStartElement("ParcelAccessEntry");
105 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
106 pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time"));
107 pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList"));
108 xtr.ReadEndElement();
109
110 landData.ParcelAccessList.Add(pae);
111 }
106 } 112 }
107 xtr.ReadEndElement(); 113 xtr.Read();
108 114
109 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours")); 115 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
110 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice")); 116 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
@@ -135,7 +141,7 @@ namespace OpenSim.Framework.Serialization.External
135 xtw.WriteElementString("Area", Convert.ToString(landData.Area)); 141 xtw.WriteElementString("Area", Convert.ToString(landData.Area));
136 xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID)); 142 xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID));
137 xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString()); 143 xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString());
138 xtw.WriteElementString("Category", Convert.ToString(landData.Category)); 144 xtw.WriteElementString("Category", Convert.ToString((sbyte)landData.Category));
139 xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate)); 145 xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate));
140 xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice)); 146 xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice));
141 xtw.WriteElementString("GlobalID", landData.GlobalID.ToString()); 147 xtw.WriteElementString("GlobalID", landData.GlobalID.ToString());
@@ -143,10 +149,10 @@ namespace OpenSim.Framework.Serialization.External
143 xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned)); 149 xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned));
144 xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap)); 150 xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap));
145 xtw.WriteElementString("Description", landData.Description); 151 xtw.WriteElementString("Description", landData.Description);
146 xtw.WriteElementString("Flags", Convert.ToString(landData.Flags)); 152 xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags));
147 xtw.WriteElementString("LandingType", Convert.ToString(landData.LandingType)); 153 xtw.WriteElementString("LandingType", Convert.ToString((byte)landData.LandingType));
148 xtw.WriteElementString("Name", landData.Name); 154 xtw.WriteElementString("Name", landData.Name);
149 xtw.WriteElementString("Status", Convert.ToString(landData.Status)); 155 xtw.WriteElementString("Status", Convert.ToString((sbyte)landData.Status));
150 xtw.WriteElementString("LocalID", landData.LocalID.ToString()); 156 xtw.WriteElementString("LocalID", landData.LocalID.ToString());
151 xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale)); 157 xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale));
152 xtw.WriteElementString("MediaID", landData.MediaID.ToString()); 158 xtw.WriteElementString("MediaID", landData.MediaID.ToString());
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
index d0e3fc8..06ec047 100644
--- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
+++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Serialization.Tests
39 public class LandDataSerializerTest 39 public class LandDataSerializerTest
40 { 40 {
41 private LandData land; 41 private LandData land;
42 private string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>Residential</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>Leased</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>"; 42 private string preSerialized = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<LandData>\n <Area>128</Area>\n <AuctionID>0</AuctionID>\n <AuthBuyerID>00000000-0000-0000-0000-000000000000</AuthBuyerID>\n <Category>10</Category>\n <ClaimDate>0</ClaimDate>\n <ClaimPrice>0</ClaimPrice>\n <GlobalID>54ff9641-dd40-4a2c-b1f1-47dd3af24e50</GlobalID>\n <GroupID>d740204e-bbbf-44aa-949d-02c7d739f6a5</GroupID>\n <IsGroupOwned>False</IsGroupOwned>\n <Bitmap>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</Bitmap>\n <Description>land data to test LandDataSerializer</Description>\n <Flags>536870944</Flags>\n <LandingType>2</LandingType>\n <Name>LandDataSerializerTest Land</Name>\n <Status>0</Status>\n <LocalID>0</LocalID>\n <MediaAutoScale>1</MediaAutoScale>\n <MediaID>d4452578-2f25-4b97-a81b-819af559cfd7</MediaID>\n <MediaURL>http://videos.opensimulator.org/bumblebee.mp4</MediaURL>\n <MusicURL />\n <OwnerID>1b8eedf9-6d15-448b-8015-24286f1756bf</OwnerID>\n <ParcelAccessList />\n <PassHours>0</PassHours>\n <PassPrice>0</PassPrice>\n <SalePrice>0</SalePrice>\n <SnapshotID>00000000-0000-0000-0000-000000000000</SnapshotID>\n <UserLocation>&lt;0, 0, 0&gt;</UserLocation>\n <UserLookAt>&lt;0, 0, 0&gt;</UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>";
43 43
44 [SetUp] 44 [SetUp]
45 public void setup() 45 public void setup()
@@ -75,15 +75,19 @@ namespace OpenSim.Framework.Serialization.Tests
75 public void LandDataSerializerSerializeTest() 75 public void LandDataSerializerSerializeTest()
76 { 76 {
77 string serialized = LandDataSerializer.Serialize(this.land); 77 string serialized = LandDataSerializer.Serialize(this.land);
78 Assert.That(serialized.Length > 0); 78 Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
79 Assert.That(serialized == this.preSerialized); 79 Assert.That(serialized == this.preSerialized, "result of Serialize(LandData) does not match expected result");
80 } 80 }
81 81
82 /// <summary> 82 /// <summary>
83 /// </summary> 83 /// </summary>
84 [Test] 84 [Test]
85 public void TestLandDataSerializerDeserializeTest() 85 public void TestLandDataSerializerDeserializeFromStringTest()
86 { 86 {
87 LandData reifiedLandData = LandDataSerializer.Deserialize(this.preSerialized);
88 Assert.That(reifiedLandData != null, "Deserialize(string) returned null");
89 Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID");
90 Assert.That(reifiedLandData.Name == this.land.Name, "Reified LandData.Name != original LandData.Name");
87 } 91 }
88 } 92 }
89} 93}