diff options
author | Melanie | 2013-02-28 21:20:07 +0000 |
---|---|---|
committer | Melanie | 2013-02-28 21:20:07 +0000 |
commit | eb9458fd7e3a9098712f501cdcf05d71f741ec14 (patch) | |
tree | 1a719b0d89f22cefd04866db162694d0eb724d8d /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Fix potential concurrency issue since the LSL notecard cache was not being ch... (diff) | |
download | opensim-SC-eb9458fd7e3a9098712f501cdcf05d71f741ec14.zip opensim-SC-eb9458fd7e3a9098712f501cdcf05d71f741ec14.tar.gz opensim-SC-eb9458fd7e3a9098712f501cdcf05d71f741ec14.tar.bz2 opensim-SC-eb9458fd7e3a9098712f501cdcf05d71f741ec14.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneManager.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
6 files changed, 301 insertions, 25 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b67db20..29476b9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -11728,14 +11728,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11728 | return UUID.Zero.ToString(); | 11728 | return UUID.Zero.ToString(); |
11729 | } | 11729 | } |
11730 | 11730 | ||
11731 | string reqIdentifier = UUID.Random().ToString(); | ||
11732 | |||
11731 | // was: UUID tid = tid = AsyncCommands. | 11733 | // was: UUID tid = tid = AsyncCommands. |
11732 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); | 11734 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, reqIdentifier); |
11733 | 11735 | ||
11734 | if (NotecardCache.IsCached(assetID)) | 11736 | if (NotecardCache.IsCached(assetID)) |
11735 | { | 11737 | { |
11736 | AsyncCommands. | 11738 | AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(assetID).ToString()); |
11737 | DataserverPlugin.DataserverReply(assetID.ToString(), | 11739 | |
11738 | NotecardCache.GetLines(assetID).ToString()); | ||
11739 | ScriptSleep(100); | 11740 | ScriptSleep(100); |
11740 | return tid.ToString(); | 11741 | return tid.ToString(); |
11741 | } | 11742 | } |
@@ -11751,9 +11752,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11751 | string data = Encoding.UTF8.GetString(a.Data); | 11752 | string data = Encoding.UTF8.GetString(a.Data); |
11752 | //m_log.Debug(data); | 11753 | //m_log.Debug(data); |
11753 | NotecardCache.Cache(id, data); | 11754 | NotecardCache.Cache(id, data); |
11754 | AsyncCommands. | 11755 | AsyncCommands.DataserverPlugin.DataserverReply(reqIdentifier, NotecardCache.GetLines(id).ToString()); |
11755 | DataserverPlugin.DataserverReply(id.ToString(), | ||
11756 | NotecardCache.GetLines(id).ToString()); | ||
11757 | }); | 11756 | }); |
11758 | 11757 | ||
11759 | ScriptSleep(100); | 11758 | ScriptSleep(100); |
@@ -11782,13 +11781,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11782 | return UUID.Zero.ToString(); | 11781 | return UUID.Zero.ToString(); |
11783 | } | 11782 | } |
11784 | 11783 | ||
11784 | string reqIdentifier = UUID.Random().ToString(); | ||
11785 | |||
11785 | // was: UUID tid = tid = AsyncCommands. | 11786 | // was: UUID tid = tid = AsyncCommands. |
11786 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString()); | 11787 | UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, reqIdentifier); |
11787 | 11788 | ||
11788 | if (NotecardCache.IsCached(assetID)) | 11789 | if (NotecardCache.IsCached(assetID)) |
11789 | { | 11790 | { |
11790 | AsyncCommands.DataserverPlugin.DataserverReply(assetID.ToString(), | 11791 | AsyncCommands.DataserverPlugin.DataserverReply( |
11791 | NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); | 11792 | reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); |
11793 | |||
11792 | ScriptSleep(100); | 11794 | ScriptSleep(100); |
11793 | return tid.ToString(); | 11795 | return tid.ToString(); |
11794 | } | 11796 | } |
@@ -11804,8 +11806,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11804 | string data = Encoding.UTF8.GetString(a.Data); | 11806 | string data = Encoding.UTF8.GetString(a.Data); |
11805 | //m_log.Debug(data); | 11807 | //m_log.Debug(data); |
11806 | NotecardCache.Cache(id, data); | 11808 | NotecardCache.Cache(id, data); |
11807 | AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), | 11809 | AsyncCommands.DataserverPlugin.DataserverReply( |
11808 | NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax)); | 11810 | reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax)); |
11809 | }); | 11811 | }); |
11810 | 11812 | ||
11811 | ScriptSleep(100); | 11813 | ScriptSleep(100); |
@@ -13287,7 +13289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13287 | 13289 | ||
13288 | public static void Cache(UUID assetID, string text) | 13290 | public static void Cache(UUID assetID, string text) |
13289 | { | 13291 | { |
13290 | CacheCheck(); | 13292 | CheckCache(); |
13291 | 13293 | ||
13292 | lock (m_Notecards) | 13294 | lock (m_Notecards) |
13293 | { | 13295 | { |
@@ -13372,14 +13374,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13372 | return line; | 13374 | return line; |
13373 | } | 13375 | } |
13374 | 13376 | ||
13375 | public static void CacheCheck() | 13377 | public static void CheckCache() |
13376 | { | 13378 | { |
13377 | foreach (UUID key in new List<UUID>(m_Notecards.Keys)) | 13379 | lock (m_Notecards) |
13378 | { | 13380 | { |
13379 | Notecard nc = m_Notecards[key]; | 13381 | foreach (UUID key in new List<UUID>(m_Notecards.Keys)) |
13380 | if (nc.lastRef.AddSeconds(30) < DateTime.Now) | 13382 | { |
13381 | m_Notecards.Remove(key); | 13383 | Notecard nc = m_Notecards[key]; |
13384 | if (nc.lastRef.AddSeconds(30) < DateTime.Now) | ||
13385 | m_Notecards.Remove(key); | ||
13386 | } | ||
13382 | } | 13387 | } |
13383 | } | 13388 | } |
13384 | } | 13389 | } |
13385 | } | 13390 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 2fe6948..d0922aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | ||
33 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
34 | using System.Threading; | 33 | using System.Threading; |
35 | using log4net; | 34 | using log4net; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 4c018d4..4a7f68b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2173,7 +2173,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2173 | m_host.AddScriptLPS(1); | 2173 | m_host.AddScriptLPS(1); |
2174 | 2174 | ||
2175 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2175 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2176 | string HomeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", new string[]{"Startup"}); | 2176 | string HomeURI = Util.GetConfigVarFromSections<string>(config, "HomeURI", |
2177 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
2177 | 2178 | ||
2178 | if (!string.IsNullOrEmpty(HomeURI)) | 2179 | if (!string.IsNullOrEmpty(HomeURI)) |
2179 | return HomeURI; | 2180 | return HomeURI; |
@@ -2194,7 +2195,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2194 | m_host.AddScriptLPS(1); | 2195 | m_host.AddScriptLPS(1); |
2195 | 2196 | ||
2196 | IConfigSource config = m_ScriptEngine.ConfigSource; | 2197 | IConfigSource config = m_ScriptEngine.ConfigSource; |
2197 | string gatekeeperURI = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", new string[] {"Startup"}); | 2198 | string gatekeeperURI = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", |
2199 | new string[] { "Startup", "Hypergrid" }, String.Empty); | ||
2198 | 2200 | ||
2199 | if (!string.IsNullOrEmpty(gatekeeperURI)) | 2201 | if (!string.IsNullOrEmpty(gatekeeperURI)) |
2200 | return gatekeeperURI; | 2202 | return gatekeeperURI; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index 5b57bbe..ac9f93b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
93 | // FIXME: This should really be a script item (with accompanying script) | 93 | // FIXME: This should really be a script item (with accompanying script) |
94 | TaskInventoryItem grp1Item | 94 | TaskInventoryItem grp1Item |
95 | = TaskInventoryHelpers.AddNotecard( | 95 | = TaskInventoryHelpers.AddNotecard( |
96 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | 96 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
97 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 97 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
98 | 98 | ||
99 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); | 99 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); |
@@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
127 | // FIXME: This should really be a script item (with accompanying script) | 127 | // FIXME: This should really be a script item (with accompanying script) |
128 | TaskInventoryItem grp1Item | 128 | TaskInventoryItem grp1Item |
129 | = TaskInventoryHelpers.AddNotecard( | 129 | = TaskInventoryHelpers.AddNotecard( |
130 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); | 130 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
131 | 131 | ||
132 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 132 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
133 | 133 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs new file mode 100644 index 0000000..c92bcdb --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs | |||
@@ -0,0 +1,270 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | using System.Text; | ||
7 | using log4net; | ||
8 | using Nini.Config; | ||
9 | using NUnit.Framework; | ||
10 | using OpenMetaverse; | ||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Framework.Servers; | ||
13 | using OpenSim.Framework.Servers.HttpServer; | ||
14 | using OpenSim.Region.CoreModules.Scripting.LSLHttp; | ||
15 | using OpenSim.Region.Framework.Scenes; | ||
16 | using OpenSim.Region.ScriptEngine.Shared; | ||
17 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
18 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
19 | using OpenSim.Services.Interfaces; | ||
20 | using OpenSim.Tests.Common; | ||
21 | using OpenSim.Tests.Common.Mock; | ||
22 | |||
23 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
24 | { | ||
25 | /// <summary> | ||
26 | /// Tests for notecard related functions in LSL | ||
27 | /// </summary> | ||
28 | [TestFixture] | ||
29 | public class LSL_ApiNotecardTests : OpenSimTestCase | ||
30 | { | ||
31 | private Scene m_scene; | ||
32 | private MockScriptEngine m_engine; | ||
33 | |||
34 | private SceneObjectGroup m_so; | ||
35 | private TaskInventoryItem m_scriptItem; | ||
36 | private LSL_Api m_lslApi; | ||
37 | |||
38 | [TestFixtureSetUp] | ||
39 | public void TestFixtureSetUp() | ||
40 | { | ||
41 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
42 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; | ||
43 | } | ||
44 | |||
45 | [TestFixtureTearDown] | ||
46 | public void TestFixureTearDown() | ||
47 | { | ||
48 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
49 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
50 | // tests really shouldn't). | ||
51 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
52 | } | ||
53 | |||
54 | [SetUp] | ||
55 | public override void SetUp() | ||
56 | { | ||
57 | base.SetUp(); | ||
58 | |||
59 | m_engine = new MockScriptEngine(); | ||
60 | |||
61 | m_scene = new SceneHelpers().SetupScene(); | ||
62 | SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine); | ||
63 | |||
64 | m_so = SceneHelpers.AddSceneObject(m_scene); | ||
65 | m_scriptItem = TaskInventoryHelpers.AddScript(m_scene, m_so.RootPart); | ||
66 | |||
67 | // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. | ||
68 | // Possibly this could be done and we could obtain it directly from the MockScriptEngine. | ||
69 | m_lslApi = new LSL_Api(); | ||
70 | m_lslApi.Initialize(m_engine, m_so.RootPart, m_scriptItem, null); | ||
71 | } | ||
72 | |||
73 | [Test] | ||
74 | public void TestLlGetNotecardLine() | ||
75 | { | ||
76 | TestHelpers.InMethod(); | ||
77 | |||
78 | string[] ncLines = { "One", "Two", "Three" }; | ||
79 | |||
80 | TaskInventoryItem ncItem | ||
81 | = TaskInventoryHelpers.AddNotecard(m_scene, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines)); | ||
82 | |||
83 | AssertValidNotecardLine(ncItem.Name, 0, ncLines[0]); | ||
84 | AssertValidNotecardLine(ncItem.Name, 2, ncLines[2]); | ||
85 | AssertValidNotecardLine(ncItem.Name, 3, ScriptBaseClass.EOF); | ||
86 | AssertValidNotecardLine(ncItem.Name, 4, ScriptBaseClass.EOF); | ||
87 | |||
88 | // XXX: Is this correct or do we really expect no dataserver event to fire at all? | ||
89 | AssertValidNotecardLine(ncItem.Name, -1, ""); | ||
90 | AssertValidNotecardLine(ncItem.Name, -2, ""); | ||
91 | } | ||
92 | |||
93 | [Test] | ||
94 | public void TestLlGetNotecardLine_NoNotecard() | ||
95 | { | ||
96 | TestHelpers.InMethod(); | ||
97 | |||
98 | AssertInValidNotecardLine("nc", 0); | ||
99 | } | ||
100 | |||
101 | [Test] | ||
102 | public void TestLlGetNotecardLine_NotANotecard() | ||
103 | { | ||
104 | TestHelpers.InMethod(); | ||
105 | |||
106 | TaskInventoryItem ncItem = TaskInventoryHelpers.AddScript(m_scene, m_so.RootPart, "nc1", "Not important"); | ||
107 | |||
108 | AssertInValidNotecardLine(ncItem.Name, 0); | ||
109 | } | ||
110 | |||
111 | private void AssertValidNotecardLine(string ncName, int lineNumber, string assertLine) | ||
112 | { | ||
113 | string key = m_lslApi.llGetNotecardLine(ncName, lineNumber); | ||
114 | Assert.That(key, Is.Not.EqualTo(UUID.Zero.ToString())); | ||
115 | |||
116 | Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(1)); | ||
117 | Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); | ||
118 | |||
119 | List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID]; | ||
120 | Assert.That(events.Count, Is.EqualTo(1)); | ||
121 | EventParams eventParams = events[0]; | ||
122 | |||
123 | Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); | ||
124 | Assert.That(eventParams.Params[0].ToString(), Is.EqualTo(key)); | ||
125 | Assert.That(eventParams.Params[1].ToString(), Is.EqualTo(assertLine)); | ||
126 | |||
127 | m_engine.ClearPostedEvents(); | ||
128 | } | ||
129 | |||
130 | private void AssertInValidNotecardLine(string ncName, int lineNumber) | ||
131 | { | ||
132 | string key = m_lslApi.llGetNotecardLine(ncName, lineNumber); | ||
133 | Assert.That(key, Is.EqualTo(UUID.Zero.ToString())); | ||
134 | |||
135 | Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(0)); | ||
136 | } | ||
137 | |||
138 | // [Test] | ||
139 | // public void TestLlReleaseUrl() | ||
140 | // { | ||
141 | // TestHelpers.InMethod(); | ||
142 | // | ||
143 | // m_lslApi.llRequestURL(); | ||
144 | // string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString(); | ||
145 | // | ||
146 | // { | ||
147 | // // Check that the initial number of URLs is correct | ||
148 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); | ||
149 | // } | ||
150 | // | ||
151 | // { | ||
152 | // // Check releasing a non-url | ||
153 | // m_lslApi.llReleaseURL("GARBAGE"); | ||
154 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); | ||
155 | // } | ||
156 | // | ||
157 | // { | ||
158 | // // Check releasing a non-existing url | ||
159 | // m_lslApi.llReleaseURL("http://example.com"); | ||
160 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); | ||
161 | // } | ||
162 | // | ||
163 | // { | ||
164 | // // Check URL release | ||
165 | // m_lslApi.llReleaseURL(returnedUri); | ||
166 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); | ||
167 | // | ||
168 | // HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); | ||
169 | // | ||
170 | // bool gotExpectedException = false; | ||
171 | // | ||
172 | // try | ||
173 | // { | ||
174 | // using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) | ||
175 | // {} | ||
176 | // } | ||
177 | // catch (WebException e) | ||
178 | // { | ||
179 | // using (HttpWebResponse response = (HttpWebResponse)e.Response) | ||
180 | // gotExpectedException = response.StatusCode == HttpStatusCode.NotFound; | ||
181 | // } | ||
182 | // | ||
183 | // Assert.That(gotExpectedException, Is.True); | ||
184 | // } | ||
185 | // | ||
186 | // { | ||
187 | // // Check releasing the same URL again | ||
188 | // m_lslApi.llReleaseURL(returnedUri); | ||
189 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls)); | ||
190 | // } | ||
191 | // } | ||
192 | // | ||
193 | // [Test] | ||
194 | // public void TestLlRequestUrl() | ||
195 | // { | ||
196 | // TestHelpers.InMethod(); | ||
197 | // | ||
198 | // string requestId = m_lslApi.llRequestURL(); | ||
199 | // Assert.That(requestId, Is.Not.EqualTo(UUID.Zero.ToString())); | ||
200 | // string returnedUri; | ||
201 | // | ||
202 | // { | ||
203 | // // Check that URL is correctly set up | ||
204 | // Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1)); | ||
205 | // | ||
206 | // Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); | ||
207 | // | ||
208 | // List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID]; | ||
209 | // Assert.That(events.Count, Is.EqualTo(1)); | ||
210 | // EventParams eventParams = events[0]; | ||
211 | // Assert.That(eventParams.EventName, Is.EqualTo("http_request")); | ||
212 | // | ||
213 | // UUID returnKey; | ||
214 | // string rawReturnKey = eventParams.Params[0].ToString(); | ||
215 | // string method = eventParams.Params[1].ToString(); | ||
216 | // returnedUri = eventParams.Params[2].ToString(); | ||
217 | // | ||
218 | // Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); | ||
219 | // Assert.That(method, Is.EqualTo(ScriptBaseClass.URL_REQUEST_GRANTED)); | ||
220 | // Assert.That(Uri.IsWellFormedUriString(returnedUri, UriKind.Absolute), Is.True); | ||
221 | // } | ||
222 | // | ||
223 | // { | ||
224 | // // Check that request to URL works. | ||
225 | // string testResponse = "Hello World"; | ||
226 | // | ||
227 | // m_engine.ClearPostedEvents(); | ||
228 | // m_engine.PostEventHook | ||
229 | // += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse); | ||
230 | // | ||
231 | //// Console.WriteLine("Trying {0}", returnedUri); | ||
232 | // HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri); | ||
233 | // | ||
234 | // AssertHttpResponse(returnedUri, testResponse); | ||
235 | // | ||
236 | // Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID)); | ||
237 | // | ||
238 | // List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID]; | ||
239 | // Assert.That(events.Count, Is.EqualTo(1)); | ||
240 | // EventParams eventParams = events[0]; | ||
241 | // Assert.That(eventParams.EventName, Is.EqualTo("http_request")); | ||
242 | // | ||
243 | // UUID returnKey; | ||
244 | // string rawReturnKey = eventParams.Params[0].ToString(); | ||
245 | // string method = eventParams.Params[1].ToString(); | ||
246 | // string body = eventParams.Params[2].ToString(); | ||
247 | // | ||
248 | // Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True); | ||
249 | // Assert.That(method, Is.EqualTo("GET")); | ||
250 | // Assert.That(body, Is.EqualTo("")); | ||
251 | // } | ||
252 | // } | ||
253 | // | ||
254 | // private void AssertHttpResponse(string uri, string expectedResponse) | ||
255 | // { | ||
256 | // HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
257 | // | ||
258 | // using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse()) | ||
259 | // { | ||
260 | // using (Stream stream = webResponse.GetResponseStream()) | ||
261 | // { | ||
262 | // using (StreamReader reader = new StreamReader(stream)) | ||
263 | // { | ||
264 | // Assert.That(reader.ReadToEnd(), Is.EqualTo(expectedResponse)); | ||
265 | // } | ||
266 | // } | ||
267 | // } | ||
268 | // } | ||
269 | } | ||
270 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs index b2803a1..e422f5b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs | |||
@@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
151 | 151 | ||
152 | // Create an object embedded inside the first | 152 | // Create an object embedded inside the first |
153 | TaskInventoryHelpers.AddNotecard( | 153 | TaskInventoryHelpers.AddNotecard( |
154 | m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900)); | 154 | m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!"); |
155 | 155 | ||
156 | bool exceptionCaught = false; | 156 | bool exceptionCaught = false; |
157 | 157 | ||