aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordr scofield (aka dirk husemann)2009-10-01 15:03:16 +0200
committerdr scofield (aka dirk husemann)2009-10-01 15:03:16 +0200
commit133a4a9906e55b20ff8780ebe5f59df87d5523ee (patch)
treeead45aa414d6fcf61ace87f873512250ec4a3f20
parentfixing LandDataSerializer (yeah! for testcases) (diff)
downloadopensim-SC_OLD-133a4a9906e55b20ff8780ebe5f59df87d5523ee.zip
opensim-SC_OLD-133a4a9906e55b20ff8780ebe5f59df87d5523ee.tar.gz
opensim-SC_OLD-133a4a9906e55b20ff8780ebe5f59df87d5523ee.tar.bz2
opensim-SC_OLD-133a4a9906e55b20ff8780ebe5f59df87d5523ee.tar.xz
- adding new LandDataSerializer testcase to "test-xml" target as well
- adding another LandDataSerializer testcase
-rw-r--r--.nant/local.include5
-rw-r--r--OpenSim/Framework/Serialization/External/LandDataSerializer.cs22
-rw-r--r--OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs44
3 files changed, 57 insertions, 14 deletions
diff --git a/.nant/local.include b/.nant/local.include
index 8e233d0..f78c6a6 100644
--- a/.nant/local.include
+++ b/.nant/local.include
@@ -228,6 +228,11 @@
228 <arg value="-xml=test-results/OpenSim.Framework.Communications.Tests.dll-Results.xml" /> 228 <arg value="-xml=test-results/OpenSim.Framework.Communications.Tests.dll-Results.xml" />
229 </exec> 229 </exec>
230 230
231 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.serialization.tests">
232 <arg value="./bin/OpenSim.Framework.Serialization.Tests.dll" />
233 <arg value="-xml=test-results/OpenSim.Framework.Serialization.Tests.dll-Results.xml" />
234 </exec>
235
231 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.servers.tests"> 236 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.framework.servers.tests">
232 <arg value="./bin/OpenSim.Framework.Servers.Tests.dll" /> 237 <arg value="./bin/OpenSim.Framework.Servers.Tests.dll" />
233 <arg value="-xml=test-results/OpenSim.Framework.Servers.Tests.dll-Results.xml" /> 238 <arg value="-xml=test-results/OpenSim.Framework.Servers.Tests.dll-Results.xml" />
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
index e980945..a3bc5d1 100644
--- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs
@@ -99,7 +99,7 @@ namespace OpenSim.Framework.Serialization.External
99 { 99 {
100 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) 100 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
101 { 101 {
102 ParcelManager.ParcelAccessEntry pae; 102 ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry();
103 103
104 xtr.ReadStartElement("ParcelAccessEntry"); 104 xtr.ReadStartElement("ParcelAccessEntry");
105 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID")); 105 pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID"));
@@ -112,14 +112,14 @@ namespace OpenSim.Framework.Serialization.External
112 } 112 }
113 xtr.Read(); 113 xtr.Read();
114 114
115 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours")); 115 landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours"));
116 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice")); 116 landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice"));
117 landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); 117 landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice"));
118 landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID")); 118 landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID"));
119 landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation")); 119 landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation"));
120 landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt")); 120 landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt"));
121 landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell")); 121 landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell"));
122 landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime")); 122 landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime"));
123 123
124 xtr.ReadEndElement(); 124 xtr.ReadEndElement();
125 125
@@ -165,8 +165,8 @@ namespace OpenSim.Framework.Serialization.External
165 { 165 {
166 xtw.WriteStartElement("ParcelAccessEntry"); 166 xtw.WriteStartElement("ParcelAccessEntry");
167 xtw.WriteElementString("AgentID", pal.AgentID.ToString()); 167 xtw.WriteElementString("AgentID", pal.AgentID.ToString());
168 xtw.WriteElementString("Time", Convert.ToString(pal.Time)); 168 xtw.WriteElementString("Time", pal.Time.ToString("s"));
169 xtw.WriteElementString("AccessList", Convert.ToString(pal.Flags)); 169 xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags));
170 xtw.WriteEndElement(); 170 xtw.WriteEndElement();
171 } 171 }
172 xtw.WriteEndElement(); 172 xtw.WriteEndElement();
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
index 06ec047..14e0462 100644
--- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
+++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs
@@ -39,7 +39,13 @@ 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>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>"; 42 private LandData landWithParcelAccessList;
43
44 private static 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>";
45 private static string preSerializedWithParcelAccessList = "<?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 <ParcelAccessEntry>\n <AgentID>62d65d45-c91a-4f77-862c-46557d978b6c</AgentID>\n <Time>2009-10-01T00:00:00</Time>\n <AccessList>2</AccessList>\n </ParcelAccessEntry>\n <ParcelAccessEntry>\n <AgentID>ec2a8d18-2378-4fe0-8b68-2a31b57c481e</AgentID>\n <Time>2010-10-20T00:00:00</Time>\n <AccessList>1</AccessList>\n </ParcelAccessEntry>\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>";
46
47
48
43 49
44 [SetUp] 50 [SetUp]
45 public void setup() 51 public void setup()
@@ -67,27 +73,59 @@ namespace OpenSim.Framework.Serialization.Tests
67 this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7"); 73 this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7");
68 this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4"; 74 this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4";
69 this.land.OwnerID = new UUID("1b8eedf9-6d15-448b-8015-24286f1756bf"); 75 this.land.OwnerID = new UUID("1b8eedf9-6d15-448b-8015-24286f1756bf");
76
77 this.landWithParcelAccessList = this.land.Copy();
78 this.landWithParcelAccessList.ParcelAccessList.Clear();
79
80 ParcelManager.ParcelAccessEntry pae0 = new ParcelManager.ParcelAccessEntry();
81 pae0.AgentID = new UUID("62d65d45-c91a-4f77-862c-46557d978b6c");
82 pae0.Flags = AccessList.Ban;
83 pae0.Time = new DateTime(2009, 10, 01);
84 this.landWithParcelAccessList.ParcelAccessList.Add(pae0);
85
86 ParcelManager.ParcelAccessEntry pae1 = new ParcelManager.ParcelAccessEntry();
87 pae1.AgentID = new UUID("ec2a8d18-2378-4fe0-8b68-2a31b57c481e");
88 pae1.Flags = AccessList.Access;
89 pae1.Time = new DateTime(2010, 10, 20);
90 this.landWithParcelAccessList.ParcelAccessList.Add(pae1);
70 } 91 }
71 92
72 /// <summary> 93 /// <summary>
94 /// Test the LandDataSerializer.Serialize() method
73 /// </summary> 95 /// </summary>
74 [Test] 96 [Test]
75 public void LandDataSerializerSerializeTest() 97 public void LandDataSerializerSerializeTest()
76 { 98 {
77 string serialized = LandDataSerializer.Serialize(this.land); 99 string serialized = LandDataSerializer.Serialize(this.land);
78 Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string"); 100 Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string");
79 Assert.That(serialized == this.preSerialized, "result of Serialize(LandData) does not match expected result"); 101 Assert.That(serialized == LandDataSerializerTest.preSerialized,
102 "result of Serialize(LandData) does not match expected result");
103
104 string serializedWithParcelAccessList = LandDataSerializer.Serialize(this.landWithParcelAccessList);
105 Assert.That(serializedWithParcelAccessList.Length > 0,
106 "Serialize(LandData) returned empty string for LandData object with ParcelAccessList");
107 Assert.That(serializedWithParcelAccessList == LandDataSerializerTest.preSerializedWithParcelAccessList,
108 "result of Serialize(LandData) does not match expected result (pre-serialized with parcel access list");
80 } 109 }
81 110
82 /// <summary> 111 /// <summary>
112 /// Test the LandDataSerializer.Deserialize() method
83 /// </summary> 113 /// </summary>
84 [Test] 114 [Test]
85 public void TestLandDataSerializerDeserializeFromStringTest() 115 public void TestLandDataSerializerDeserializeFromStringTest()
86 { 116 {
87 LandData reifiedLandData = LandDataSerializer.Deserialize(this.preSerialized); 117 LandData reifiedLandData = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized);
88 Assert.That(reifiedLandData != null, "Deserialize(string) returned null"); 118 Assert.That(reifiedLandData != null, "Deserialize(string) returned null");
89 Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID"); 119 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"); 120 Assert.That(reifiedLandData.Name == this.land.Name, "Reified LandData.Name != original LandData.Name");
121
122 LandData reifiedLandDataWithParcelAccessList = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerializedWithParcelAccessList);
123 Assert.That(reifiedLandDataWithParcelAccessList != null,
124 "Deserialize(string) returned null (pre-serialized with parcel access list)");
125 Assert.That(reifiedLandDataWithParcelAccessList.GlobalID == this.landWithParcelAccessList.GlobalID,
126 "Reified LandData.GlobalID != original LandData.GlobalID (pre-serialized with parcel access list)");
127 Assert.That(reifiedLandDataWithParcelAccessList.Name == this.landWithParcelAccessList.Name,
128 "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)");
91 } 129 }
92 } 130 }
93} 131}