aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-29 20:20:47 +0000
committerJustin Clarke Casey2009-05-29 20:20:47 +0000
commit6eb191c87b982a96c71fe17f42fd6f52093acf41 (patch)
tree74348d07ee672f1d381821652ab6ef6196d7588a /OpenSim/Region/CoreModules
parent* minor: move common serialization test code into fixture setup (diff)
downloadopensim-SC_OLD-6eb191c87b982a96c71fe17f42fd6f52093acf41.zip
opensim-SC_OLD-6eb191c87b982a96c71fe17f42fd6f52093acf41.tar.gz
opensim-SC_OLD-6eb191c87b982a96c71fe17f42fd6f52093acf41.tar.bz2
opensim-SC_OLD-6eb191c87b982a96c71fe17f42fd6f52093acf41.tar.xz
* Add save xml2 serialization test
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs73
1 files changed, 70 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index ad9d301..1c7cd7e 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -29,9 +29,12 @@ using log4net.Config;
29using NUnit.Framework; 29using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers; 30using NUnit.Framework.SyntaxHelpers;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using OpenSim.Tests.Common; 34using OpenSim.Tests.Common;
34using OpenSim.Tests.Common.Setup; 35using OpenSim.Tests.Common.Setup;
36using System.IO;
37using System.Xml;
35 38
36namespace OpenSim.Region.CoreModules.World.Serialiser.Tests 39namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
37{ 40{
@@ -119,13 +122,15 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
119 <OtherParts /> 122 <OtherParts />
120 </SceneObjectGroup>"; 123 </SceneObjectGroup>";
121 124
125 protected Scene m_scene;
122 protected SerialiserModule m_serialiserModule; 126 protected SerialiserModule m_serialiserModule;
123 127
124 [TestFixtureSetUp] 128 [TestFixtureSetUp]
125 public void Init() 129 public void Init()
126 { 130 {
127 m_serialiserModule = new SerialiserModule(); 131 m_serialiserModule = new SerialiserModule();
128 SceneSetupHelpers.SetupSceneModules(SceneSetupHelpers.SetupScene(false), m_serialiserModule); 132 m_scene = SceneSetupHelpers.SetupScene(false);
133 SceneSetupHelpers.SetupSceneModules(m_scene, m_serialiserModule);
129 } 134 }
130 135
131 [Test] 136 [Test]
@@ -144,11 +149,73 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
144 // TODO: Check other properties 149 // TODO: Check other properties
145 } 150 }
146 151
147 //[Test] 152 [Test]
148 public void TestSaveXml2() 153 public void TestSaveXml2()
149 { 154 {
150 TestHelper.InMethod(); 155 TestHelper.InMethod();
151 //log4net.Config.XmlConfigurator.Configure(); 156 //log4net.Config.XmlConfigurator.Configure();
157
158 string rpName = "My Little Pony";
159 UUID rpUuid = UUID.Parse("00000000-0000-0000-0000-000000000064");
160 UUID rpCreatorId = UUID.Parse("00000000-0000-0000-0000-000000000015");
161 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
162// Vector3 groupPosition = new Vector3(10, 20, 30);
163// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
164// Vector3 offsetPosition = new Vector3(5, 10, 15);
165
166 SceneObjectPart rp = new SceneObjectPart();
167 rp.UUID = rpUuid;
168 rp.Name = rpName;
169 rp.CreatorID = rpCreatorId;
170 rp.Shape = shape;
171
172 SceneObjectGroup so = new SceneObjectGroup(rp);
173
174 // Need to add the object to the scene so that the request to get script state succeeds
175 m_scene.AddSceneObject(UUID.Zero, so);
176
177 string xml2 = m_serialiserModule.SaveGroupToXml2(so);
178
179 XmlTextReader xtr = new XmlTextReader(new StringReader(xml2));
180 xtr.ReadStartElement("SceneObjectGroup");
181 xtr.ReadStartElement("SceneObjectPart");
182
183 UUID uuid = UUID.Zero;
184 string name = null;
185 UUID creatorId = UUID.Zero;
186
187 while (xtr.Read() && xtr.Name != "SceneObjectPart")
188 {
189 if (xtr.NodeType != XmlNodeType.Element)
190 continue;
191
192 switch (xtr.Name)
193 {
194 case "UUID":
195 xtr.ReadStartElement("UUID");
196 uuid = UUID.Parse(xtr.ReadElementString("Guid"));
197 xtr.ReadEndElement();
198 break;
199 case "Name":
200 name = xtr.ReadElementContentAsString();
201 break;
202 case "CreatorID":
203 xtr.ReadStartElement("CreatorID");
204 creatorId = UUID.Parse(xtr.ReadElementString("Guid"));
205 xtr.ReadEndElement();
206 break;
207 }
208 }
209
210 xtr.ReadEndElement();
211 xtr.ReadStartElement("OtherParts");
212 xtr.ReadEndElement();
213 xtr.Close();
214
215 // TODO: More checks
216 Assert.That(uuid, Is.EqualTo(rpUuid));
217 Assert.That(name, Is.EqualTo(rpName));
218 Assert.That(creatorId, Is.EqualTo(rpCreatorId));
152 } 219 }
153 } 220 }
154} \ No newline at end of file 221} \ No newline at end of file