diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs | 77 |
2 files changed, 79 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index 8b09b3e..75f0774 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -199,11 +199,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
199 | 199 | ||
200 | while (reader.Read()) | 200 | while (reader.Read()) |
201 | { | 201 | { |
202 | //Console.WriteLine("Depth: {0}", reader.Depth); | 202 | // Console.WriteLine("Depth: {0}, name {1}", reader.Depth, reader.Name); |
203 | 203 | ||
204 | switch (reader.NodeType) | 204 | switch (reader.NodeType) |
205 | { | 205 | { |
206 | case XmlNodeType.Attribute: | 206 | case XmlNodeType.Attribute: |
207 | // Console.WriteLine("FOUND ATTRIBUTE {0}", reader.Name); | ||
207 | writer.WriteAttributeString(reader.Prefix, reader.Name, reader.NamespaceURI, reader.Value); | 208 | writer.WriteAttributeString(reader.Prefix, reader.Name, reader.NamespaceURI, reader.Value); |
208 | break; | 209 | break; |
209 | 210 | ||
@@ -224,6 +225,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
224 | 225 | ||
225 | writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); | 226 | writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI); |
226 | 227 | ||
228 | if (reader.HasAttributes) | ||
229 | { | ||
230 | while (reader.MoveToNextAttribute()) | ||
231 | writer.WriteAttributeString(reader.Prefix, reader.Name, reader.NamespaceURI, reader.Value); | ||
232 | |||
233 | reader.MoveToElement(); | ||
234 | } | ||
235 | |||
227 | if (reader.LocalName == "SceneObjectPart") | 236 | if (reader.LocalName == "SceneObjectPart") |
228 | { | 237 | { |
229 | if (sopDepth < 0) | 238 | if (sopDepth < 0) |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs index 779da43..007ff63 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs | |||
@@ -26,12 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Threading; | ||
29 | using System.Xml; | 30 | using System.Xml; |
31 | using Nini.Config; | ||
30 | using NUnit.Framework; | 32 | using NUnit.Framework; |
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
33 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | 35 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
34 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Region.ScriptEngine.XEngine; | ||
35 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
36 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
37 | 40 | ||
@@ -46,30 +49,54 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
46 | TestHelpers.InMethod(); | 49 | TestHelpers.InMethod(); |
47 | // TestHelpers.EnableLogging(); | 50 | // TestHelpers.EnableLogging(); |
48 | 51 | ||
52 | XEngine xengine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); | ||
53 | xengine.DebugLevel = 1; | ||
54 | |||
55 | IniConfigSource configSource = new IniConfigSource(); | ||
56 | |||
57 | IConfig startupConfig = configSource.AddConfig("Startup"); | ||
58 | startupConfig.Set("DefaultScriptEngine", "XEngine"); | ||
59 | |||
60 | IConfig xEngineConfig = configSource.AddConfig("XEngine"); | ||
61 | xEngineConfig.Set("Enabled", "true"); | ||
62 | xEngineConfig.Set("StartDelay", "0"); | ||
63 | xEngineConfig.Set("AppDomainLoading", "false"); | ||
64 | |||
49 | string homeUrl = "http://hg.HomeTestPostAssetRewriteGrid.com"; | 65 | string homeUrl = "http://hg.HomeTestPostAssetRewriteGrid.com"; |
50 | string foreignUrl = "http://hg.ForeignTestPostAssetRewriteGrid.com"; | 66 | string foreignUrl = "http://hg.ForeignTestPostAssetRewriteGrid.com"; |
51 | UUID assetId = TestHelpers.ParseTail(0x1); | 67 | int soIdTail = 0x1; |
52 | UUID userId = TestHelpers.ParseTail(0x10); | 68 | UUID assetId = TestHelpers.ParseTail(0x10); |
69 | UUID userId = TestHelpers.ParseTail(0x100); | ||
70 | UUID sceneId = TestHelpers.ParseTail(0x1000); | ||
53 | string userFirstName = "TestPostAsset"; | 71 | string userFirstName = "TestPostAsset"; |
54 | string userLastName = "Rewrite"; | 72 | string userLastName = "Rewrite"; |
55 | int soPartsCount = 3; | 73 | int soPartsCount = 3; |
56 | 74 | ||
57 | Scene scene = new SceneHelpers().SetupScene(); | 75 | Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource); |
76 | SceneHelpers.SetupSceneModules(scene, configSource, xengine); | ||
77 | scene.StartScripts(); | ||
78 | |||
58 | HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl); | 79 | HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl); |
59 | UserAccount ua | 80 | UserAccount ua |
60 | = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password"); | 81 | = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password"); |
61 | 82 | ||
62 | //AssetBase ncAssetSet = AssetHelpers.CreateNotecardAsset(assetId, "TestPostAssetRewriteNotecard"); | 83 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail); |
63 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(soPartsCount, ua.PrincipalID); | 84 | RezScript( |
64 | AssetBase ncAssetSet = AssetHelpers.CreateAsset(assetId, so); | 85 | scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID); |
65 | ncAssetSet.CreatorID = foreignUrl; | ||
66 | hgam.PostAsset(foreignUrl, ncAssetSet); | ||
67 | 86 | ||
87 | AssetBase asset = AssetHelpers.CreateAsset(assetId, so); | ||
88 | asset.CreatorID = foreignUrl; | ||
89 | hgam.PostAsset(foreignUrl, asset); | ||
90 | |||
91 | // Check transformed asset. | ||
68 | AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString()); | 92 | AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString()); |
69 | Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID); | 93 | Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID); |
70 | string xmlData = Utils.BytesToString(ncAssetGet.Data); | 94 | string xmlData = Utils.BytesToString(ncAssetGet.Data); |
71 | XmlDocument ncAssetGetXmlDoc = new XmlDocument(); | 95 | XmlDocument ncAssetGetXmlDoc = new XmlDocument(); |
72 | ncAssetGetXmlDoc.LoadXml(xmlData); | 96 | ncAssetGetXmlDoc.LoadXml(xmlData); |
97 | |||
98 | // Console.WriteLine(ncAssetGetXmlDoc.OuterXml); | ||
99 | |||
73 | XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData"); | 100 | XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData"); |
74 | 101 | ||
75 | Assert.AreEqual(soPartsCount, creatorDataNodes.Count); | 102 | Assert.AreEqual(soPartsCount, creatorDataNodes.Count); |
@@ -80,6 +107,40 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
80 | Assert.AreEqual( | 107 | Assert.AreEqual( |
81 | string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText); | 108 | string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText); |
82 | } | 109 | } |
110 | |||
111 | // Check that saved script nodes have attributes | ||
112 | XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName("SavedScriptState"); | ||
113 | |||
114 | Assert.AreEqual(1, savedScriptStateNodes.Count); | ||
115 | Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count); | ||
116 | XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID"); | ||
117 | Assert.NotNull(uuidAttribute); | ||
118 | // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task | ||
119 | // item created earlier. | ||
120 | } | ||
121 | |||
122 | private void RezScript(Scene scene, UUID soId, string script, string itemName, UUID userId) | ||
123 | { | ||
124 | InventoryItemBase itemTemplate = new InventoryItemBase(); | ||
125 | // itemTemplate.ID = itemId; | ||
126 | itemTemplate.Name = itemName; | ||
127 | itemTemplate.Folder = soId; | ||
128 | itemTemplate.InvType = (int)InventoryType.LSL; | ||
129 | |||
130 | // XXX: Ultimately it would be better to be able to directly manipulate the script engine to rez a script | ||
131 | // immediately for tests rather than chunter through it's threaded mechanisms. | ||
132 | AutoResetEvent chatEvent = new AutoResetEvent(false); | ||
133 | |||
134 | scene.EventManager.OnChatFromWorld += (s, c) => | ||
135 | { | ||
136 | // Console.WriteLine("Got chat [{0}]", c.Message); | ||
137 | chatEvent.Set(); | ||
138 | }; | ||
139 | |||
140 | scene.RezNewScript(userId, itemTemplate, script); | ||
141 | |||
142 | // Console.WriteLine("HERE"); | ||
143 | Assert.IsTrue(chatEvent.WaitOne(60000), "Chat event in HGAssetMapperTests.RezScript not received"); | ||
83 | } | 144 | } |
84 | } | 145 | } |
85 | } \ No newline at end of file | 146 | } \ No newline at end of file |