aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs146
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs7
2 files changed, 149 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs
new file mode 100644
index 0000000..007ff63
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/HGAssetMapperTests.cs
@@ -0,0 +1,146 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Threading;
30using System.Xml;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.CoreModules.Framework.InventoryAccess;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.XEngine;
38using OpenSim.Services.Interfaces;
39using OpenSim.Tests.Common;
40
41namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
42{
43 [TestFixture]
44 public class HGAssetMapperTests : OpenSimTestCase
45 {
46 [Test]
47 public void TestPostAssetRewrite()
48 {
49 TestHelpers.InMethod();
50// TestHelpers.EnableLogging();
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
65 string homeUrl = "http://hg.HomeTestPostAssetRewriteGrid.com";
66 string foreignUrl = "http://hg.ForeignTestPostAssetRewriteGrid.com";
67 int soIdTail = 0x1;
68 UUID assetId = TestHelpers.ParseTail(0x10);
69 UUID userId = TestHelpers.ParseTail(0x100);
70 UUID sceneId = TestHelpers.ParseTail(0x1000);
71 string userFirstName = "TestPostAsset";
72 string userLastName = "Rewrite";
73 int soPartsCount = 3;
74
75 Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource);
76 SceneHelpers.SetupSceneModules(scene, configSource, xengine);
77 scene.StartScripts();
78
79 HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl);
80 UserAccount ua
81 = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password");
82
83 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail);
84 RezScript(
85 scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID);
86
87 AssetBase asset = AssetHelpers.CreateAsset(assetId, so);
88 asset.CreatorID = foreignUrl;
89 hgam.PostAsset(foreignUrl, asset);
90
91 // Check transformed asset.
92 AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString());
93 Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID);
94 string xmlData = Utils.BytesToString(ncAssetGet.Data);
95 XmlDocument ncAssetGetXmlDoc = new XmlDocument();
96 ncAssetGetXmlDoc.LoadXml(xmlData);
97
98// Console.WriteLine(ncAssetGetXmlDoc.OuterXml);
99
100 XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData");
101
102 Assert.AreEqual(soPartsCount, creatorDataNodes.Count);
103 //Console.WriteLine("creatorDataNodes {0}", creatorDataNodes.Count);
104
105 foreach (XmlNode creatorDataNode in creatorDataNodes)
106 {
107 Assert.AreEqual(
108 string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText);
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");
144 }
145 }
146} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
index ac25a93..1d91165 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
@@ -37,14 +37,12 @@ using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
42using OpenSim.Region.CoreModules.Framework.InventoryAccess; 41using OpenSim.Region.CoreModules.Framework.InventoryAccess;
43using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization; 43using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Services.Interfaces; 44using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48 46
49namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests 47namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
50{ 48{
@@ -109,8 +107,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
109 item1.AssetID = asset1.FullID; 107 item1.AssetID = asset1.FullID;
110 item1.ID = item1Id; 108 item1.ID = item1Id;
111 InventoryFolderBase objsFolder 109 InventoryFolderBase objsFolder
112 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0]; 110 = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0];
113 item1.Folder = objsFolder.ID; 111 item1.Folder = objsFolder.ID;
112 item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems;
114 m_scene.AddInventoryItem(item1); 113 m_scene.AddInventoryItem(item1);
115 114
116 SceneObjectGroup so 115 SceneObjectGroup so
@@ -159,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
159 item1.AssetID = asset1.FullID; 158 item1.AssetID = asset1.FullID;
160 item1.ID = item1Id; 159 item1.ID = item1Id;
161 InventoryFolderBase objsFolder 160 InventoryFolderBase objsFolder
162 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0]; 161 = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0];
163 item1.Folder = objsFolder.ID; 162 item1.Folder = objsFolder.ID;
164 m_scene.AddInventoryItem(item1); 163 m_scene.AddInventoryItem(item1);
165 164