diff options
author | Justin Clarke Casey | 2009-06-02 15:24:29 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-06-02 15:24:29 +0000 |
commit | 5c42143a7b17b68c9a33df9d6da3780b58f31f43 (patch) | |
tree | f112835614efeef7faeb65a42fc8227a66ac21fe /OpenSim/Region/CoreModules/World/Serialiser | |
parent | Explicitly set the changed status of the prim groups affected in a delink (diff) | |
download | opensim-SC-5c42143a7b17b68c9a33df9d6da3780b58f31f43.zip opensim-SC-5c42143a7b17b68c9a33df9d6da3780b58f31f43.tar.gz opensim-SC-5c42143a7b17b68c9a33df9d6da3780b58f31f43.tar.bz2 opensim-SC-5c42143a7b17b68c9a33df9d6da3780b58f31f43.tar.xz |
* Add simple original xml serialization test
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Serialiser')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index d028360..c894d8e 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -147,8 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
147 | </SceneObjectPart> | 147 | </SceneObjectPart> |
148 | </RootPart> | 148 | </RootPart> |
149 | <OtherParts /> | 149 | <OtherParts /> |
150 | </SceneObjectGroup> | 150 | </SceneObjectGroup>"; |
151 | "; | ||
152 | 151 | ||
153 | private string xml2 = @" | 152 | private string xml2 = @" |
154 | <SceneObjectGroup> | 153 | <SceneObjectGroup> |
@@ -243,7 +242,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
243 | } | 242 | } |
244 | 243 | ||
245 | [Test] | 244 | [Test] |
246 | public void TestSerializeXml() | 245 | public void TestDeserializeXml() |
247 | { | 246 | { |
248 | TestHelper.InMethod(); | 247 | TestHelper.InMethod(); |
249 | //log4net.Config.XmlConfigurator.Configure(); | 248 | //log4net.Config.XmlConfigurator.Configure(); |
@@ -256,6 +255,77 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
256 | Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide")); | 255 | Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide")); |
257 | 256 | ||
258 | // TODO: Check other properties | 257 | // TODO: Check other properties |
258 | } | ||
259 | |||
260 | [Test] | ||
261 | public void TestSerializeXml() | ||
262 | { | ||
263 | TestHelper.InMethod(); | ||
264 | //log4net.Config.XmlConfigurator.Configure(); | ||
265 | |||
266 | string rpName = "My Little Donkey"; | ||
267 | UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000964"); | ||
268 | UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000915"); | ||
269 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
270 | // Vector3 groupPosition = new Vector3(10, 20, 30); | ||
271 | // Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
272 | // Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
273 | |||
274 | SceneObjectPart rp = new SceneObjectPart(); | ||
275 | rp.UUID = rpUuid; | ||
276 | rp.Name = rpName; | ||
277 | rp.CreatorID = rpCreatorId; | ||
278 | rp.Shape = shape; | ||
279 | |||
280 | SceneObjectGroup so = new SceneObjectGroup(rp); | ||
281 | |||
282 | // Need to add the object to the scene so that the request to get script state succeeds | ||
283 | m_scene.AddSceneObject(so); | ||
284 | |||
285 | string xml = SceneObjectSerializer.ToOriginalXmlFormat(so); | ||
286 | |||
287 | XmlTextReader xtr = new XmlTextReader(new StringReader(xml)); | ||
288 | xtr.ReadStartElement("SceneObjectGroup"); | ||
289 | xtr.ReadStartElement("RootPart"); | ||
290 | xtr.ReadStartElement("SceneObjectPart"); | ||
291 | |||
292 | UUID uuid = UUID.Zero; | ||
293 | string name = null; | ||
294 | UUID creatorId = UUID.Zero; | ||
295 | |||
296 | while (xtr.Read() && xtr.Name != "SceneObjectPart") | ||
297 | { | ||
298 | if (xtr.NodeType != XmlNodeType.Element) | ||
299 | continue; | ||
300 | |||
301 | switch (xtr.Name) | ||
302 | { | ||
303 | case "UUID": | ||
304 | xtr.ReadStartElement("UUID"); | ||
305 | uuid = UUID.Parse(xtr.ReadElementString("Guid")); | ||
306 | xtr.ReadEndElement(); | ||
307 | break; | ||
308 | case "Name": | ||
309 | name = xtr.ReadElementContentAsString(); | ||
310 | break; | ||
311 | case "CreatorID": | ||
312 | xtr.ReadStartElement("CreatorID"); | ||
313 | creatorId = UUID.Parse(xtr.ReadElementString("Guid")); | ||
314 | xtr.ReadEndElement(); | ||
315 | break; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | xtr.ReadEndElement(); | ||
320 | xtr.ReadEndElement(); | ||
321 | xtr.ReadStartElement("OtherParts"); | ||
322 | xtr.ReadEndElement(); | ||
323 | xtr.Close(); | ||
324 | |||
325 | // TODO: More checks | ||
326 | Assert.That(uuid, Is.EqualTo(rpUuid)); | ||
327 | Assert.That(name, Is.EqualTo(rpName)); | ||
328 | Assert.That(creatorId, Is.EqualTo(rpCreatorId)); | ||
259 | } | 329 | } |
260 | 330 | ||
261 | [Test] | 331 | [Test] |