From 5c42143a7b17b68c9a33df9d6da3780b58f31f43 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 2 Jun 2009 15:24:29 +0000 Subject: * Add simple original xml serialization test --- .../CoreModules/World/Archiver/AssetsRequest.cs | 10 +-- .../World/Serialiser/Tests/SerialiserTests.cs | 76 +++++++++++++++++++++- 2 files changed, 75 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 129d6d3..c459a66 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -101,7 +101,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } - private bool done = false; /// /// Called back by the asset cache when it has the asset /// @@ -127,14 +126,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired) { - if (done) - throw new Exception("AArgh"); - m_log.DebugFormat( - "[ARCHIVER]: Successfully added {0} assets ({1} assets missing)", + "[ARCHIVER]: Successfully added {0} assets ({1} assets notified missing)", m_foundAssetUuids.Count, m_notFoundAssetUuids.Count); - - done = true; // We want to stop using the asset cache thread asap // as we now need to do the work of producing the rest of the archive @@ -146,7 +140,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } catch (Exception e) { - m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e); + m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e); } } 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 - - "; + "; private string xml2 = @" @@ -243,7 +242,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests } [Test] - public void TestSerializeXml() + public void TestDeserializeXml() { TestHelper.InMethod(); //log4net.Config.XmlConfigurator.Configure(); @@ -256,6 +255,77 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide")); // TODO: Check other properties + } + + [Test] + public void TestSerializeXml() + { + TestHelper.InMethod(); + //log4net.Config.XmlConfigurator.Configure(); + + string rpName = "My Little Donkey"; + UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000964"); + UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000915"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); +// Vector3 groupPosition = new Vector3(10, 20, 30); +// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); +// Vector3 offsetPosition = new Vector3(5, 10, 15); + + SceneObjectPart rp = new SceneObjectPart(); + rp.UUID = rpUuid; + rp.Name = rpName; + rp.CreatorID = rpCreatorId; + rp.Shape = shape; + + SceneObjectGroup so = new SceneObjectGroup(rp); + + // Need to add the object to the scene so that the request to get script state succeeds + m_scene.AddSceneObject(so); + + string xml = SceneObjectSerializer.ToOriginalXmlFormat(so); + + XmlTextReader xtr = new XmlTextReader(new StringReader(xml)); + xtr.ReadStartElement("SceneObjectGroup"); + xtr.ReadStartElement("RootPart"); + xtr.ReadStartElement("SceneObjectPart"); + + UUID uuid = UUID.Zero; + string name = null; + UUID creatorId = UUID.Zero; + + while (xtr.Read() && xtr.Name != "SceneObjectPart") + { + if (xtr.NodeType != XmlNodeType.Element) + continue; + + switch (xtr.Name) + { + case "UUID": + xtr.ReadStartElement("UUID"); + uuid = UUID.Parse(xtr.ReadElementString("Guid")); + xtr.ReadEndElement(); + break; + case "Name": + name = xtr.ReadElementContentAsString(); + break; + case "CreatorID": + xtr.ReadStartElement("CreatorID"); + creatorId = UUID.Parse(xtr.ReadElementString("Guid")); + xtr.ReadEndElement(); + break; + } + } + + xtr.ReadEndElement(); + xtr.ReadEndElement(); + xtr.ReadStartElement("OtherParts"); + xtr.ReadEndElement(); + xtr.Close(); + + // TODO: More checks + Assert.That(uuid, Is.EqualTo(rpUuid)); + Assert.That(name, Is.EqualTo(rpName)); + Assert.That(creatorId, Is.EqualTo(rpCreatorId)); } [Test] -- cgit v1.1