diff options
author | Melanie | 2013-01-26 01:56:23 +0000 |
---|---|---|
committer | Melanie | 2013-01-26 01:56:23 +0000 |
commit | e28c042dce141954477baa1a3babad9ce2a80e58 (patch) | |
tree | 000f7091deb70abb6b8574d4107e91e259255f40 /OpenSim/Region/OptionalModules/Scripting | |
parent | Merge branch 'master' into careminster (diff) | |
parent | * This adds llVolumeDetect functionality to the C# implementation of BulletSim. (diff) | |
download | opensim-SC_OLD-e28c042dce141954477baa1a3babad9ce2a80e58.zip opensim-SC_OLD-e28c042dce141954477baa1a3babad9ce2a80e58.tar.gz opensim-SC_OLD-e28c042dce141954477baa1a3babad9ce2a80e58.tar.bz2 opensim-SC_OLD-e28c042dce141954477baa1a3babad9ce2a80e58.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | 52 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 145 |
2 files changed, 171 insertions, 26 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 0c175ca..b9dcfea 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -92,12 +92,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
92 | } | 92 | } |
93 | catch (Exception e) | 93 | catch (Exception e) |
94 | { | 94 | { |
95 | m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message); | 95 | m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | if (m_enabled) | 99 | if (m_enabled) |
100 | m_log.DebugFormat("[JsonStoreScripts] module is enabled"); | 100 | m_log.DebugFormat("[JsonStoreScripts]: module is enabled"); |
101 | } | 101 | } |
102 | 102 | ||
103 | // ----------------------------------------------------------------- | 103 | // ----------------------------------------------------------------- |
@@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); | 150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); |
151 | if (m_comms == null) | 151 | if (m_comms == null) |
152 | { | 152 | { |
153 | m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined"); | 153 | m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined"); |
154 | m_enabled = false; | 154 | m_enabled = false; |
155 | return; | 155 | return; |
156 | } | 156 | } |
@@ -158,40 +158,40 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); | 158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); |
159 | if (m_store == null) | 159 | if (m_store == null) |
160 | { | 160 | { |
161 | m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined"); | 161 | m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined"); |
162 | m_enabled = false; | 162 | m_enabled = false; |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | try | 166 | try |
167 | { | 167 | { |
168 | m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); | 168 | m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); |
169 | m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); | 169 | m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); |
170 | 170 | ||
171 | m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); | 171 | m_comms.RegisterScriptInvocation(this, "JsonReadNotecard"); |
172 | m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); | 172 | m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard"); |
173 | 173 | ||
174 | m_comms.RegisterScriptInvocation(this,"JsonTestPath"); | 174 | m_comms.RegisterScriptInvocation(this, "JsonTestPath"); |
175 | m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); | 175 | m_comms.RegisterScriptInvocation(this, "JsonTestPathJson"); |
176 | 176 | ||
177 | m_comms.RegisterScriptInvocation(this,"JsonGetValue"); | 177 | m_comms.RegisterScriptInvocation(this, "JsonGetValue"); |
178 | m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); | 178 | m_comms.RegisterScriptInvocation(this, "JsonGetValueJson"); |
179 | 179 | ||
180 | m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); | 180 | m_comms.RegisterScriptInvocation(this, "JsonTakeValue"); |
181 | m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); | 181 | m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson"); |
182 | 182 | ||
183 | m_comms.RegisterScriptInvocation(this,"JsonReadValue"); | 183 | m_comms.RegisterScriptInvocation(this, "JsonReadValue"); |
184 | m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); | 184 | m_comms.RegisterScriptInvocation(this, "JsonReadValueJson"); |
185 | 185 | ||
186 | m_comms.RegisterScriptInvocation(this,"JsonSetValue"); | 186 | m_comms.RegisterScriptInvocation(this, "JsonSetValue"); |
187 | m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); | 187 | m_comms.RegisterScriptInvocation(this, "JsonSetValueJson"); |
188 | 188 | ||
189 | m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); | 189 | m_comms.RegisterScriptInvocation(this, "JsonRemoveValue"); |
190 | } | 190 | } |
191 | catch (Exception e) | 191 | catch (Exception e) |
192 | { | 192 | { |
193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information | 193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information |
194 | m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); | 194 | m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message); |
195 | m_enabled = false; | 195 | m_enabled = false; |
196 | } | 196 | } |
197 | } | 197 | } |
@@ -354,7 +354,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
354 | } | 354 | } |
355 | catch (Exception e) | 355 | catch (Exception e) |
356 | { | 356 | { |
357 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 357 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
358 | } | 358 | } |
359 | 359 | ||
360 | DispatchValue(scriptID,reqID,String.Empty); | 360 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -389,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
389 | } | 389 | } |
390 | catch (Exception e) | 390 | catch (Exception e) |
391 | { | 391 | { |
392 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | 392 | m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); |
393 | } | 393 | } |
394 | 394 | ||
395 | DispatchValue(scriptID,reqID,String.Empty); | 395 | DispatchValue(scriptID,reqID,String.Empty); |
@@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
421 | if (a.Type != (sbyte)AssetType.Notecard) | 421 | if (a.Type != (sbyte)AssetType.Notecard) |
422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); | 422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); |
423 | 423 | ||
424 | m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID); | 424 | m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); |
425 | 425 | ||
426 | try | 426 | try |
427 | { | 427 | { |
@@ -432,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
432 | } | 432 | } |
433 | catch (Exception e) | 433 | catch (Exception e) |
434 | { | 434 | { |
435 | m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message); | 435 | m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message); |
436 | } | 436 | } |
437 | 437 | ||
438 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); | 438 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); |
@@ -495,4 +495,4 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
495 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); | 495 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs new file mode 100644 index 0000000..397dd93 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | |||
@@ -0,0 +1,145 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | ||
43 | using OpenSim.Tests.Common.Mock; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Tests for inventory functions in LSL | ||
49 | /// </summary> | ||
50 | [TestFixture] | ||
51 | public class LSL_ApiInventoryTests : OpenSimTestCase | ||
52 | { | ||
53 | private Scene m_scene; | ||
54 | private MockScriptEngine m_engine; | ||
55 | private ScriptModuleCommsModule m_smcm; | ||
56 | |||
57 | [SetUp] | ||
58 | public override void SetUp() | ||
59 | { | ||
60 | base.SetUp(); | ||
61 | |||
62 | TestHelpers.EnableLogging(); | ||
63 | |||
64 | IConfigSource configSource = new IniConfigSource(); | ||
65 | IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); | ||
66 | jsonStoreConfig.Set("Enabled", "true"); | ||
67 | |||
68 | m_engine = new MockScriptEngine(); | ||
69 | m_smcm = new ScriptModuleCommsModule(); | ||
70 | JsonStoreModule jsm = new JsonStoreModule(); | ||
71 | JsonStoreScriptModule jssm = new JsonStoreScriptModule(); | ||
72 | |||
73 | m_scene = new SceneHelpers().SetupScene(); | ||
74 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); | ||
75 | } | ||
76 | |||
77 | // [Test] | ||
78 | public void TestJsonCreateStore() | ||
79 | { | ||
80 | TestHelpers.InMethod(); | ||
81 | // TestHelpers.EnableLogging(); | ||
82 | |||
83 | UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); | ||
84 | |||
85 | Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); | ||
86 | } | ||
87 | |||
88 | // [Test] | ||
89 | public void TestJsonGetValue() | ||
90 | { | ||
91 | TestHelpers.InMethod(); | ||
92 | // TestHelpers.EnableLogging(); | ||
93 | |||
94 | UUID storeId | ||
95 | = (UUID)m_smcm.InvokeOperation( | ||
96 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); | ||
97 | |||
98 | string value | ||
99 | = (string)m_smcm.InvokeOperation( | ||
100 | UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); | ||
101 | |||
102 | Assert.That(value, Is.EqualTo("World")); | ||
103 | } | ||
104 | |||
105 | // [Test] | ||
106 | public void TestJsonTestPath() | ||
107 | { | ||
108 | TestHelpers.InMethod(); | ||
109 | // TestHelpers.EnableLogging(); | ||
110 | |||
111 | UUID storeId | ||
112 | = (UUID)m_smcm.InvokeOperation( | ||
113 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); | ||
114 | |||
115 | int result | ||
116 | = (int)m_smcm.InvokeOperation( | ||
117 | UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" }); | ||
118 | |||
119 | Assert.That(result, Is.EqualTo(1)); | ||
120 | } | ||
121 | |||
122 | // [Test] | ||
123 | public void TestJsonSetValue() | ||
124 | { | ||
125 | TestHelpers.InMethod(); | ||
126 | // TestHelpers.EnableLogging(); | ||
127 | |||
128 | UUID storeId | ||
129 | = (UUID)m_smcm.InvokeOperation( | ||
130 | UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" }); | ||
131 | |||
132 | int result | ||
133 | = (int)m_smcm.InvokeOperation( | ||
134 | UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" }); | ||
135 | |||
136 | Assert.That(result, Is.EqualTo(1)); | ||
137 | |||
138 | string value | ||
139 | = (string)m_smcm.InvokeOperation( | ||
140 | UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" }); | ||
141 | |||
142 | Assert.That(value, Is.EqualTo("World")); | ||
143 | } | ||
144 | } | ||
145 | } \ No newline at end of file | ||