diff options
Diffstat (limited to 'OpenSim/Framework/Serialization')
4 files changed, 327 insertions, 5 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs new file mode 100644 index 0000000..a3bc5d1 --- /dev/null +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Text; | ||
32 | using System.Xml; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | |||
36 | namespace OpenSim.Framework.Serialization.External | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Serialize and deserialize LandData as an external format. | ||
40 | /// </summary> | ||
41 | public class LandDataSerializer | ||
42 | { | ||
43 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); | ||
44 | |||
45 | /// <summary> | ||
46 | /// Reify/deserialize landData | ||
47 | /// </summary> | ||
48 | /// <param name="serializedLandData"></param> | ||
49 | /// <returns></returns> | ||
50 | /// <exception cref="System.Xml.XmlException"></exception> | ||
51 | public static LandData Deserialize(byte[] serializedLandData) | ||
52 | { | ||
53 | return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length)); | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Reify/deserialize landData | ||
58 | /// </summary> | ||
59 | /// <param name="serializedLandData"></param> | ||
60 | /// <returns></returns> | ||
61 | /// <exception cref="System.Xml.XmlException"></exception> | ||
62 | public static LandData Deserialize(string serializedLandData) | ||
63 | { | ||
64 | LandData landData = new LandData(); | ||
65 | |||
66 | StringReader sr = new StringReader(serializedLandData); | ||
67 | XmlTextReader xtr = new XmlTextReader(sr); | ||
68 | |||
69 | xtr.ReadStartElement("LandData"); | ||
70 | |||
71 | landData.Area = Convert.ToInt32( xtr.ReadElementString("Area")); | ||
72 | landData.AuctionID = Convert.ToUInt32( xtr.ReadElementString("AuctionID")); | ||
73 | landData.AuthBuyerID = UUID.Parse( xtr.ReadElementString("AuthBuyerID")); | ||
74 | landData.Category = (ParcelCategory)Convert.ToSByte( xtr.ReadElementString("Category")); | ||
75 | landData.ClaimDate = Convert.ToInt32( xtr.ReadElementString("ClaimDate")); | ||
76 | landData.ClaimPrice = Convert.ToInt32( xtr.ReadElementString("ClaimPrice")); | ||
77 | landData.GlobalID = UUID.Parse( xtr.ReadElementString("GlobalID")); | ||
78 | landData.GroupID = UUID.Parse( xtr.ReadElementString("GroupID")); | ||
79 | landData.IsGroupOwned = Convert.ToBoolean( xtr.ReadElementString("IsGroupOwned")); | ||
80 | landData.Bitmap = Convert.FromBase64String( xtr.ReadElementString("Bitmap")); | ||
81 | landData.Description = xtr.ReadElementString("Description"); | ||
82 | landData.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags")); | ||
83 | landData.LandingType = Convert.ToByte( xtr.ReadElementString("LandingType")); | ||
84 | landData.Name = xtr.ReadElementString("Name"); | ||
85 | landData.Status = (ParcelStatus)Convert.ToSByte( xtr.ReadElementString("Status")); | ||
86 | landData.LocalID = Convert.ToInt32( xtr.ReadElementString("LocalID")); | ||
87 | landData.MediaAutoScale = Convert.ToByte( xtr.ReadElementString("MediaAutoScale")); | ||
88 | landData.MediaID = UUID.Parse( xtr.ReadElementString("MediaID")); | ||
89 | landData.MediaURL = xtr.ReadElementString("MediaURL"); | ||
90 | landData.MusicURL = xtr.ReadElementString("MusicURL"); | ||
91 | landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID")); | ||
92 | |||
93 | landData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); | ||
94 | xtr.Read(); | ||
95 | if (xtr.Name != "ParcelAccessList") | ||
96 | throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name)); | ||
97 | |||
98 | if (!xtr.IsEmptyElement) | ||
99 | { | ||
100 | while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) | ||
101 | { | ||
102 | ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry(); | ||
103 | |||
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 | } | ||
112 | } | ||
113 | xtr.Read(); | ||
114 | |||
115 | landData.PassHours = Convert.ToSingle( xtr.ReadElementString("PassHours")); | ||
116 | landData.PassPrice = Convert.ToInt32( xtr.ReadElementString("PassPrice")); | ||
117 | landData.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); | ||
118 | landData.SnapshotID = UUID.Parse( xtr.ReadElementString("SnapshotID")); | ||
119 | landData.UserLocation = Vector3.Parse( xtr.ReadElementString("UserLocation")); | ||
120 | landData.UserLookAt = Vector3.Parse( xtr.ReadElementString("UserLookAt")); | ||
121 | landData.Dwell = Convert.ToInt32( xtr.ReadElementString("Dwell")); | ||
122 | landData.OtherCleanTime = Convert.ToInt32( xtr.ReadElementString("OtherCleanTime")); | ||
123 | |||
124 | xtr.ReadEndElement(); | ||
125 | |||
126 | xtr.Close(); | ||
127 | sr.Close(); | ||
128 | |||
129 | return landData; | ||
130 | } | ||
131 | |||
132 | public static string Serialize(LandData landData) | ||
133 | { | ||
134 | StringWriter sw = new StringWriter(); | ||
135 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
136 | xtw.Formatting = Formatting.Indented; | ||
137 | |||
138 | xtw.WriteStartDocument(); | ||
139 | xtw.WriteStartElement("LandData"); | ||
140 | |||
141 | xtw.WriteElementString("Area", Convert.ToString(landData.Area)); | ||
142 | xtw.WriteElementString("AuctionID", Convert.ToString(landData.AuctionID)); | ||
143 | xtw.WriteElementString("AuthBuyerID", landData.AuthBuyerID.ToString()); | ||
144 | xtw.WriteElementString("Category", Convert.ToString((sbyte)landData.Category)); | ||
145 | xtw.WriteElementString("ClaimDate", Convert.ToString(landData.ClaimDate)); | ||
146 | xtw.WriteElementString("ClaimPrice", Convert.ToString(landData.ClaimPrice)); | ||
147 | xtw.WriteElementString("GlobalID", landData.GlobalID.ToString()); | ||
148 | xtw.WriteElementString("GroupID", landData.GroupID.ToString()); | ||
149 | xtw.WriteElementString("IsGroupOwned", Convert.ToString(landData.IsGroupOwned)); | ||
150 | xtw.WriteElementString("Bitmap", Convert.ToBase64String(landData.Bitmap)); | ||
151 | xtw.WriteElementString("Description", landData.Description); | ||
152 | xtw.WriteElementString("Flags", Convert.ToString((uint)landData.Flags)); | ||
153 | xtw.WriteElementString("LandingType", Convert.ToString((byte)landData.LandingType)); | ||
154 | xtw.WriteElementString("Name", landData.Name); | ||
155 | xtw.WriteElementString("Status", Convert.ToString((sbyte)landData.Status)); | ||
156 | xtw.WriteElementString("LocalID", landData.LocalID.ToString()); | ||
157 | xtw.WriteElementString("MediaAutoScale", Convert.ToString(landData.MediaAutoScale)); | ||
158 | xtw.WriteElementString("MediaID", landData.MediaID.ToString()); | ||
159 | xtw.WriteElementString("MediaURL", landData.MediaURL); | ||
160 | xtw.WriteElementString("MusicURL", landData.MusicURL); | ||
161 | xtw.WriteElementString("OwnerID", landData.OwnerID.ToString()); | ||
162 | |||
163 | xtw.WriteStartElement("ParcelAccessList"); | ||
164 | foreach (ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList) | ||
165 | { | ||
166 | xtw.WriteStartElement("ParcelAccessEntry"); | ||
167 | xtw.WriteElementString("AgentID", pal.AgentID.ToString()); | ||
168 | xtw.WriteElementString("Time", pal.Time.ToString("s")); | ||
169 | xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags)); | ||
170 | xtw.WriteEndElement(); | ||
171 | } | ||
172 | xtw.WriteEndElement(); | ||
173 | |||
174 | xtw.WriteElementString("PassHours", Convert.ToString(landData.PassHours)); | ||
175 | xtw.WriteElementString("PassPrice", Convert.ToString(landData.PassPrice)); | ||
176 | xtw.WriteElementString("SalePrice", Convert.ToString(landData.SalePrice)); | ||
177 | xtw.WriteElementString("SnapshotID", landData.SnapshotID.ToString()); | ||
178 | xtw.WriteElementString("UserLocation", landData.UserLocation.ToString()); | ||
179 | xtw.WriteElementString("UserLookAt", landData.UserLookAt.ToString()); | ||
180 | xtw.WriteElementString("Dwell", Convert.ToString(landData.Dwell)); | ||
181 | xtw.WriteElementString("OtherCleanTime", Convert.ToString(landData.OtherCleanTime)); | ||
182 | |||
183 | xtw.WriteEndElement(); | ||
184 | |||
185 | xtw.Close(); | ||
186 | sw.Close(); | ||
187 | |||
188 | return sw.ToString(); | ||
189 | } | ||
190 | } | ||
191 | } | ||
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs index 274f41f..b5901e1 100644 --- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs +++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Framework.Serialization.External | |||
158 | settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString()); | 158 | settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString()); |
159 | break; | 159 | break; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | xtr.ReadEndElement(); | 163 | xtr.ReadEndElement(); |
164 | xtr.ReadStartElement("Terrain"); | 164 | xtr.ReadStartElement("Terrain"); |
@@ -200,8 +200,8 @@ namespace OpenSim.Framework.Serialization.External | |||
200 | 200 | ||
201 | xtw.WriteStartElement("RegionSettings"); | 201 | xtw.WriteStartElement("RegionSettings"); |
202 | 202 | ||
203 | xtw.WriteStartElement("General"); | 203 | xtw.WriteStartElement("General"); |
204 | xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString()); | 204 | xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString()); |
205 | xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString()); | 205 | xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString()); |
206 | xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString()); | 206 | xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString()); |
207 | xtw.WriteElementString("BlockFly", settings.BlockFly.ToString()); | 207 | xtw.WriteElementString("BlockFly", settings.BlockFly.ToString()); |
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs index eb77e65..fb269b7 100644 --- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Serialization.External | |||
36 | /// Serialize and deserialize region settings as an external format. | 36 | /// Serialize and deserialize region settings as an external format. |
37 | /// </summary> | 37 | /// </summary> |
38 | public class UserProfileSerializer | 38 | public class UserProfileSerializer |
39 | { | 39 | { |
40 | public const int MAJOR_VERSION = 0; | 40 | public const int MAJOR_VERSION = 0; |
41 | public const int MINOR_VERSION = 1; | 41 | public const int MINOR_VERSION = 1; |
42 | 42 | ||
@@ -65,6 +65,6 @@ namespace OpenSim.Framework.Serialization.External | |||
65 | sw.Close(); | 65 | sw.Close(); |
66 | 66 | ||
67 | return sw.ToString(); | 67 | return sw.ToString(); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } \ No newline at end of file | 70 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs new file mode 100644 index 0000000..14e0462 --- /dev/null +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Framework.Serialization.External; | ||
32 | using OpenMetaverse; | ||
33 | using OpenMetaverse.StructuredData; | ||
34 | using NUnit.Framework; | ||
35 | |||
36 | namespace OpenSim.Framework.Serialization.Tests | ||
37 | { | ||
38 | [TestFixture] | ||
39 | public class LandDataSerializerTest | ||
40 | { | ||
41 | private LandData land; | ||
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><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></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><0, 0, 0></UserLocation>\n <UserLookAt><0, 0, 0></UserLookAt>\n <Dwell>0</Dwell>\n <OtherCleanTime>0</OtherCleanTime>\n</LandData>"; | ||
46 | |||
47 | |||
48 | |||
49 | |||
50 | [SetUp] | ||
51 | public void setup() | ||
52 | { | ||
53 | // setup LandData object | ||
54 | this.land = new LandData(); | ||
55 | this.land.AABBMax = new Vector3(0, 0, 0); | ||
56 | this.land.AABBMin = new Vector3(128, 128, 128); | ||
57 | this.land.Area = 128; | ||
58 | this.land.AuctionID = 0; | ||
59 | this.land.AuthBuyerID = new UUID(); | ||
60 | this.land.Category = ParcelCategory.Residential; | ||
61 | this.land.ClaimDate = 0; | ||
62 | this.land.ClaimPrice = 0; | ||
63 | this.land.GlobalID = new UUID("54ff9641-dd40-4a2c-b1f1-47dd3af24e50"); | ||
64 | this.land.GroupID = new UUID("d740204e-bbbf-44aa-949d-02c7d739f6a5"); | ||
65 | this.land.GroupPrims = 0; | ||
66 | this.land.Description = "land data to test LandDataSerializer"; | ||
67 | this.land.Flags = (uint)(ParcelFlags.AllowDamage | ParcelFlags.AllowVoiceChat); | ||
68 | this.land.LandingType = (byte)LandingType.Direct; | ||
69 | this.land.Name = "LandDataSerializerTest Land"; | ||
70 | this.land.Status = ParcelStatus.Leased; | ||
71 | this.land.LocalID = 0; | ||
72 | this.land.MediaAutoScale = (byte)0x01; | ||
73 | this.land.MediaID = new UUID("d4452578-2f25-4b97-a81b-819af559cfd7"); | ||
74 | this.land.MediaURL = "http://videos.opensimulator.org/bumblebee.mp4"; | ||
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); | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
94 | /// Test the LandDataSerializer.Serialize() method | ||
95 | /// </summary> | ||
96 | [Test] | ||
97 | public void LandDataSerializerSerializeTest() | ||
98 | { | ||
99 | string serialized = LandDataSerializer.Serialize(this.land); | ||
100 | Assert.That(serialized.Length > 0, "Serialize(LandData) returned empty string"); | ||
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"); | ||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// Test the LandDataSerializer.Deserialize() method | ||
113 | /// </summary> | ||
114 | [Test] | ||
115 | public void TestLandDataSerializerDeserializeFromStringTest() | ||
116 | { | ||
117 | LandData reifiedLandData = LandDataSerializer.Deserialize(LandDataSerializerTest.preSerialized); | ||
118 | Assert.That(reifiedLandData != null, "Deserialize(string) returned null"); | ||
119 | Assert.That(reifiedLandData.GlobalID == this.land.GlobalID, "Reified LandData.GlobalID != original LandData.GlobalID"); | ||
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)"); | ||
129 | } | ||
130 | } | ||
131 | } | ||