diff options
author | Justin Clark-Casey (justincc) | 2013-02-07 02:19:26 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-02-07 02:19:26 +0000 |
commit | 3657a08844731e5a24eeda3195c23f417b4570a5 (patch) | |
tree | 700129646d59f942cd6ff85481d401f355789a5d | |
parent | Make json store tests operate on a single thread to ensure we don't run into ... (diff) | |
download | opensim-SC_OLD-3657a08844731e5a24eeda3195c23f417b4570a5.zip opensim-SC_OLD-3657a08844731e5a24eeda3195c23f417b4570a5.tar.gz opensim-SC_OLD-3657a08844731e5a24eeda3195c23f417b4570a5.tar.bz2 opensim-SC_OLD-3657a08844731e5a24eeda3195c23f417b4570a5.tar.xz |
Add TestJsonWriteReadNotecard() regression test
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 45 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 2 |
2 files changed, 45 insertions, 2 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 34422b4..98b5624 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | |||
@@ -101,7 +101,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
101 | 101 | ||
102 | private object InvokeOp(string name, params object[] args) | 102 | private object InvokeOp(string name, params object[] args) |
103 | { | 103 | { |
104 | return m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, name, args); | 104 | return InvokeOpOnHost(name, UUID.Zero, args); |
105 | } | ||
106 | |||
107 | private object InvokeOpOnHost(string name, UUID hostId, params object[] args) | ||
108 | { | ||
109 | return m_smcm.InvokeOperation(hostId, UUID.Zero, name, args); | ||
105 | } | 110 | } |
106 | 111 | ||
107 | [Test] | 112 | [Test] |
@@ -209,6 +214,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
209 | Assert.That(value, Is.EqualTo("World")); | 214 | Assert.That(value, Is.EqualTo("World")); |
210 | } | 215 | } |
211 | 216 | ||
217 | /// <summary> | ||
218 | /// Test for reading and writing json to a notecard | ||
219 | /// </summary> | ||
220 | /// <remarks> | ||
221 | /// TODO: Really needs to test correct receipt of the link_message event. Could do this by directly fetching | ||
222 | /// it via the MockScriptEngine or perhaps by a dummy script instance. | ||
223 | /// </remarks> | ||
224 | [Test] | ||
225 | public void TestJsonWriteReadNotecard() | ||
226 | { | ||
227 | TestHelpers.InMethod(); | ||
228 | TestHelpers.EnableLogging(); | ||
229 | |||
230 | string notecardName = "nc1"; | ||
231 | |||
232 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
233 | m_scene.AddSceneObject(so); | ||
234 | |||
235 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); | ||
236 | |||
237 | // Write notecard | ||
238 | UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); | ||
239 | Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); | ||
240 | |||
241 | TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); | ||
242 | Assert.That(nc1Item, Is.Not.Null); | ||
243 | |||
244 | // TODO: Should probably independently check the contents. | ||
245 | |||
246 | // Read notecard | ||
247 | UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); | ||
248 | UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); | ||
249 | Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); | ||
250 | |||
251 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | ||
252 | Assert.That(value, Is.EqualTo("World")); | ||
253 | } | ||
254 | |||
212 | public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } | 255 | public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } |
213 | } | 256 | } |
214 | } \ No newline at end of file | 257 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs index 51f2712..78bab5b 100644 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Tests.Common | |||
85 | 85 | ||
86 | public bool PostScriptEvent(UUID itemID, string name, object[] args) | 86 | public bool PostScriptEvent(UUID itemID, string name, object[] args) |
87 | { | 87 | { |
88 | throw new System.NotImplementedException (); | 88 | return false; |
89 | } | 89 | } |
90 | 90 | ||
91 | public bool PostObjectEvent(UUID itemID, string name, object[] args) | 91 | public bool PostObjectEvent(UUID itemID, string name, object[] args) |