aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
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/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
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/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs159
1 files changed, 159 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
new file mode 100644
index 0000000..dd4a691
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/Caps/Tests/WebFetchInvDescModuleTests.cs
@@ -0,0 +1,159 @@
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.Collections;
30using System.Collections.Generic;
31using System.IO;
32using System.Net;
33using System.Text;
34using HttpServer;
35using log4net.Config;
36using Nini.Config;
37using NUnit.Framework;
38using OpenMetaverse;
39using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData;
41using OpenSim.Framework;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers;
44using OpenSim.Framework.Servers.HttpServer;
45using OpenSim.Region.ClientStack.Linden;
46using OpenSim.Region.CoreModules.Framework;
47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Services.Interfaces;
49using OpenSim.Tests.Common;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52
53namespace OpenSim.Region.ClientStack.Linden.Caps.Tests
54{
55 [TestFixture]
56 public class WebFetchInvDescModuleTests : OpenSimTestCase
57 {
58 [TestFixtureSetUp]
59 public void TestFixtureSetUp()
60 {
61 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
62 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
63 }
64
65 [TestFixtureTearDown]
66 public void TestFixureTearDown()
67 {
68 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
69 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
70 // tests really shouldn't).
71 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
72 }
73
74 [SetUp]
75 public override void SetUp()
76 {
77 base.SetUp();
78
79 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
80 // variables and the VM is not restarted between tests.
81 uint port = 9999;
82 MainServer.RemoveHttpServer(port);
83
84 BaseHttpServer server = new BaseHttpServer(port, false, 0, "");
85 MainServer.AddHttpServer(server);
86 MainServer.Instance = server;
87
88 server.Start(false);
89 }
90
91 [Test]
92 public void TestInventoryDescendentsFetch()
93 {
94 TestHelpers.InMethod();
95 TestHelpers.EnableLogging();
96
97 BaseHttpServer httpServer = MainServer.Instance;
98 Scene scene = new SceneHelpers().SetupScene();
99
100 CapabilitiesModule capsModule = new CapabilitiesModule();
101 WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false);
102
103 IConfigSource config = new IniConfigSource();
104 config.AddConfig("ClientStack.LindenCaps");
105 config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost");
106
107 SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule);
108
109 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
110
111 // We need a user present to have any capabilities set up
112 SceneHelpers.AddScenePresence(scene, ua.PrincipalID);
113
114 TestHttpRequest req = new TestHttpRequest();
115 OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
116 PollServiceEventArgs pseArgs;
117 userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
118 req.UriPath = pseArgs.Url;
119 req.Uri = new Uri("file://" + req.UriPath);
120
121 // Retrieve root folder details directly so that we can request
122 InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID);
123
124 OSDMap osdFolder = new OSDMap();
125 osdFolder["folder_id"] = folder.ID;
126 osdFolder["owner_id"] = ua.PrincipalID;
127 osdFolder["fetch_folders"] = true;
128 osdFolder["fetch_items"] = true;
129 osdFolder["sort_order"] = 0;
130
131 OSDArray osdFoldersArray = new OSDArray();
132 osdFoldersArray.Add(osdFolder);
133
134 OSDMap osdReqMap = new OSDMap();
135 osdReqMap["folders"] = osdFoldersArray;
136
137 req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap));
138
139 TestHttpClientContext context = new TestHttpClientContext(false);
140
141 // WARNING: This results in a caught exception, because queryString is null
142 MainServer.Instance.OnRequest(context, new RequestEventArgs(req));
143
144 // Drive processing of the queued inventory request synchronously.
145 wfidModule.WaitProcessQueuedInventoryRequest();
146 MainServer.Instance.PollServiceRequestManager.WaitPerformResponse();
147
148// System.Threading.Thread.Sleep(10000);
149
150 OSDMap responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
151 OSDArray foldersOsd = (OSDArray)responseOsd["folders"];
152 OSDMap folderOsd = (OSDMap)foldersOsd[0];
153
154 // A sanity check that the response has the expected number of descendents for a default inventory
155 // TODO: Need a more thorough check.
156 Assert.That((int)folderOsd["descendents"], Is.EqualTo(16));
157 }
158 }
159} \ No newline at end of file