aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
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
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')
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
3 files changed, 73 insertions, 5 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
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f18d542..28d5bad 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1803,9 +1803,8 @@ namespace OpenSim.Region.Framework.Scenes
1803 1803
1804 if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) 1804 if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
1805 { 1805 {
1806 if (sceneObject.RootPart.Shape.State != 0) // Attchment 1806 if (sceneObject.RootPart.Shape.State != 0) // Attachment
1807 { 1807 {
1808
1809 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); 1808 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
1810 1809
1811 AddRestoredSceneObject(sceneObject, false, false); 1810 AddRestoredSceneObject(sceneObject, false, false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 71d4d33..f0309e3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -595,8 +595,10 @@ namespace OpenSim.Region.Framework.Scenes
595 m_rotationOffset = PhysActor.Orientation; 595 m_rotationOffset = PhysActor.Orientation;
596 } 596 }
597 } 597 }
598
598 return m_rotationOffset; 599 return m_rotationOffset;
599 } 600 }
601
600 set 602 set
601 { 603 {
602 StoreUndoState(); 604 StoreUndoState();