diff options
author | Melanie | 2013-02-15 21:42:16 +0000 |
---|---|---|
committer | Melanie | 2013-02-15 21:42:16 +0000 |
commit | ea8c5ba707f0c6afd98968b68d13ab03b151b75b (patch) | |
tree | 9b67be5dd03a8012fb832590b05c550f869601fa /OpenSim/Region/OptionalModules | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of git://opensimulator.org/git/opensim (diff) | |
download | opensim-SC_OLD-ea8c5ba707f0c6afd98968b68d13ab03b151b75b.zip opensim-SC_OLD-ea8c5ba707f0c6afd98968b68d13ab03b151b75b.tar.gz opensim-SC_OLD-ea8c5ba707f0c6afd98968b68d13ab03b151b75b.tar.bz2 opensim-SC_OLD-ea8c5ba707f0c6afd98968b68d13ab03b151b75b.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules')
3 files changed, 170 insertions, 69 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index eec86ef..fb35068 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
270 | /// | 270 | /// |
271 | /// </summary> | 271 | /// </summary> |
272 | // ----------------------------------------------------------------- | 272 | // ----------------------------------------------------------------- |
273 | public JsonStoreNodeType PathType(UUID storeID, string path) | 273 | public JsonStoreNodeType GetPathType(UUID storeID, string path) |
274 | { | 274 | { |
275 | if (! m_enabled) return JsonStoreNodeType.Undefined; | 275 | if (! m_enabled) return JsonStoreNodeType.Undefined; |
276 | 276 | ||
@@ -407,7 +407,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
407 | /// | 407 | /// |
408 | /// </summary> | 408 | /// </summary> |
409 | // ----------------------------------------------------------------- | 409 | // ----------------------------------------------------------------- |
410 | public int ArrayLength(UUID storeID, string path) | 410 | public int GetArrayLength(UUID storeID, string path) |
411 | { | 411 | { |
412 | if (! m_enabled) return -1; | 412 | if (! m_enabled) return -1; |
413 | 413 | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 3955bff..ef08c05 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -215,19 +215,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
215 | 215 | ||
216 | #endregion | 216 | #endregion |
217 | 217 | ||
218 | #region ScriptConstantInteface | 218 | #region ScriptConstantsInterface |
219 | 219 | ||
220 | [ScriptConstant] | 220 | [ScriptConstant] |
221 | public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined; | 221 | public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined; |
222 | 222 | ||
223 | [ScriptConstant] | 223 | [ScriptConstant] |
224 | public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object; | 224 | public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object; |
225 | 225 | ||
226 | [ScriptConstant] | 226 | [ScriptConstant] |
227 | public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array; | 227 | public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array; |
228 | 228 | ||
229 | [ScriptConstant] | 229 | [ScriptConstant] |
230 | public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value; | 230 | public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value; |
231 | 231 | ||
232 | #endregion | 232 | #endregion |
233 | 233 | ||
@@ -336,9 +336,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
336 | /// </summary> | 336 | /// </summary> |
337 | // ----------------------------------------------------------------- | 337 | // ----------------------------------------------------------------- |
338 | [ScriptInvocation] | 338 | [ScriptInvocation] |
339 | public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path) | 339 | public int JsonGetPathType(UUID hostID, UUID scriptID, UUID storeID, string path) |
340 | { | 340 | { |
341 | return (int)m_store.PathType(storeID,path); | 341 | return (int)m_store.GetPathType(storeID,path); |
342 | } | 342 | } |
343 | 343 | ||
344 | [ScriptInvocation] | 344 | [ScriptInvocation] |
@@ -365,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
365 | } | 365 | } |
366 | 366 | ||
367 | [ScriptInvocation] | 367 | [ScriptInvocation] |
368 | public int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value) | 368 | public int JsonSetJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value) |
369 | { | 369 | { |
370 | return m_store.SetValue(storeID,path,value,true) ? 1 : 0; | 370 | return m_store.SetValue(storeID,path,value,true) ? 1 : 0; |
371 | } | 371 | } |
@@ -387,9 +387,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
387 | /// </summary> | 387 | /// </summary> |
388 | // ----------------------------------------------------------------- | 388 | // ----------------------------------------------------------------- |
389 | [ScriptInvocation] | 389 | [ScriptInvocation] |
390 | public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path) | 390 | public int JsonGetArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path) |
391 | { | 391 | { |
392 | return m_store.ArrayLength(storeID,path); | 392 | return m_store.GetArrayLength(storeID,path); |
393 | } | 393 | } |
394 | 394 | ||
395 | // ----------------------------------------------------------------- | 395 | // ----------------------------------------------------------------- |
@@ -406,7 +406,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
406 | } | 406 | } |
407 | 407 | ||
408 | [ScriptInvocation] | 408 | [ScriptInvocation] |
409 | public string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path) | 409 | public string JsonGetJson(UUID hostID, UUID scriptID, UUID storeID, string path) |
410 | { | 410 | { |
411 | string value = String.Empty; | 411 | string value = String.Empty; |
412 | m_store.GetValue(storeID,path,true, out value); | 412 | m_store.GetValue(storeID,path,true, out value); |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index f25f290..3d9ad16 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | |||
@@ -53,6 +53,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
53 | private Scene m_scene; | 53 | private Scene m_scene; |
54 | private MockScriptEngine m_engine; | 54 | private MockScriptEngine m_engine; |
55 | private ScriptModuleCommsModule m_smcm; | 55 | private ScriptModuleCommsModule m_smcm; |
56 | private JsonStoreScriptModule m_jssm; | ||
56 | 57 | ||
57 | [TestFixtureSetUp] | 58 | [TestFixtureSetUp] |
58 | public void FixtureInit() | 59 | public void FixtureInit() |
@@ -82,10 +83,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
82 | m_engine = new MockScriptEngine(); | 83 | m_engine = new MockScriptEngine(); |
83 | m_smcm = new ScriptModuleCommsModule(); | 84 | m_smcm = new ScriptModuleCommsModule(); |
84 | JsonStoreModule jsm = new JsonStoreModule(); | 85 | JsonStoreModule jsm = new JsonStoreModule(); |
85 | JsonStoreScriptModule jssm = new JsonStoreScriptModule(); | 86 | m_jssm = new JsonStoreScriptModule(); |
86 | 87 | ||
87 | m_scene = new SceneHelpers().SetupScene(); | 88 | m_scene = new SceneHelpers().SetupScene(); |
88 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); | 89 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, m_jssm); |
89 | 90 | ||
90 | try | 91 | try |
91 | { | 92 | { |
@@ -208,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
208 | } | 209 | } |
209 | 210 | ||
210 | [Test] | 211 | [Test] |
211 | public void TestJsonGetValueJson() | 212 | public void TestJsonGetJson() |
212 | { | 213 | { |
213 | TestHelpers.InMethod(); | 214 | TestHelpers.InMethod(); |
214 | // TestHelpers.EnableLogging(); | 215 | // TestHelpers.EnableLogging(); |
@@ -216,26 +217,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
216 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); | 217 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); |
217 | 218 | ||
218 | { | 219 | { |
219 | string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello.World"); | 220 | string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World"); |
220 | Assert.That(value, Is.EqualTo("'Two'")); | 221 | Assert.That(value, Is.EqualTo("'Two'")); |
221 | } | 222 | } |
222 | 223 | ||
223 | // Test get of path section instead of leaf | 224 | // Test get of path section instead of leaf |
224 | { | 225 | { |
225 | string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); | 226 | string value = (string)InvokeOp("JsonGetJson", storeId, "Hello"); |
226 | Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}")); | 227 | Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}")); |
227 | } | 228 | } |
228 | 229 | ||
229 | // Test get of non-existing value | 230 | // Test get of non-existing value |
230 | { | 231 | { |
231 | string fakeValueGet = (string)InvokeOp("JsonGetValueJson", storeId, "foo"); | 232 | string fakeValueGet = (string)InvokeOp("JsonGetJson", storeId, "foo"); |
232 | Assert.That(fakeValueGet, Is.EqualTo("")); | 233 | Assert.That(fakeValueGet, Is.EqualTo("")); |
233 | } | 234 | } |
234 | 235 | ||
235 | // Test get from non-existing store | 236 | // Test get from non-existing store |
236 | { | 237 | { |
237 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | 238 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); |
238 | string fakeStoreValueGet = (string)InvokeOp("JsonGetValueJson", fakeStoreId, "Hello"); | 239 | string fakeStoreValueGet = (string)InvokeOp("JsonGetJson", fakeStoreId, "Hello"); |
239 | Assert.That(fakeStoreValueGet, Is.EqualTo("")); | 240 | Assert.That(fakeStoreValueGet, Is.EqualTo("")); |
240 | } | 241 | } |
241 | } | 242 | } |
@@ -293,7 +294,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
293 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | 294 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); |
294 | Assert.That(result, Is.EqualTo(0)); | 295 | Assert.That(result, Is.EqualTo(0)); |
295 | 296 | ||
296 | string returnValue2 = (string)InvokeOp("JsonGetValueJson", storeId, "Hello"); | 297 | string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello"); |
297 | Assert.That(returnValue2, Is.EqualTo("")); | 298 | Assert.That(returnValue2, Is.EqualTo("")); |
298 | } | 299 | } |
299 | 300 | ||
@@ -314,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
314 | string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); | 315 | string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); |
315 | Assert.That(stringReturnValue, Is.EqualTo("value2")); | 316 | Assert.That(stringReturnValue, Is.EqualTo("value2")); |
316 | 317 | ||
317 | stringReturnValue = (string)InvokeOp("JsonGetValueJson", storeId, "Hello[1]"); | 318 | stringReturnValue = (string)InvokeOp("JsonGetJson", storeId, "Hello[1]"); |
318 | Assert.That(stringReturnValue, Is.EqualTo("")); | 319 | Assert.That(stringReturnValue, Is.EqualTo("")); |
319 | } | 320 | } |
320 | 321 | ||
@@ -334,67 +335,171 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
334 | } | 335 | } |
335 | } | 336 | } |
336 | 337 | ||
338 | // [Test] | ||
339 | // public void TestJsonTestPath() | ||
340 | // { | ||
341 | // TestHelpers.InMethod(); | ||
342 | //// TestHelpers.EnableLogging(); | ||
343 | // | ||
344 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); | ||
345 | // | ||
346 | // { | ||
347 | // int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); | ||
348 | // Assert.That(result, Is.EqualTo(1)); | ||
349 | // } | ||
350 | // | ||
351 | // // Test for path which does not resolve to a value. | ||
352 | // { | ||
353 | // int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | ||
354 | // Assert.That(result, Is.EqualTo(0)); | ||
355 | // } | ||
356 | // | ||
357 | // { | ||
358 | // int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); | ||
359 | // Assert.That(result2, Is.EqualTo(0)); | ||
360 | // } | ||
361 | // | ||
362 | // // Test with fake store | ||
363 | // { | ||
364 | // UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
365 | // int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); | ||
366 | // Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | ||
367 | // } | ||
368 | // } | ||
369 | |||
370 | // [Test] | ||
371 | // public void TestJsonTestPathJson() | ||
372 | // { | ||
373 | // TestHelpers.InMethod(); | ||
374 | //// TestHelpers.EnableLogging(); | ||
375 | // | ||
376 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); | ||
377 | // | ||
378 | // { | ||
379 | // int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); | ||
380 | // Assert.That(result, Is.EqualTo(1)); | ||
381 | // } | ||
382 | // | ||
383 | // // Test for path which does not resolve to a value. | ||
384 | // { | ||
385 | // int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello"); | ||
386 | // Assert.That(result, Is.EqualTo(1)); | ||
387 | // } | ||
388 | // | ||
389 | // { | ||
390 | // int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo"); | ||
391 | // Assert.That(result2, Is.EqualTo(0)); | ||
392 | // } | ||
393 | // | ||
394 | // // Test with fake store | ||
395 | // { | ||
396 | // UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
397 | // int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); | ||
398 | // Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | ||
399 | // } | ||
400 | // } | ||
401 | |||
337 | [Test] | 402 | [Test] |
338 | public void TestJsonTestPath() | 403 | public void TestGetArrayLength() |
339 | { | 404 | { |
340 | TestHelpers.InMethod(); | 405 | TestHelpers.InMethod(); |
341 | // TestHelpers.EnableLogging(); | 406 | // TestHelpers.EnableLogging(); |
342 | 407 | ||
343 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); | 408 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); |
344 | 409 | ||
345 | { | 410 | { |
346 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); | 411 | int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello.World"); |
347 | Assert.That(result, Is.EqualTo(1)); | 412 | Assert.That(result, Is.EqualTo(2)); |
348 | } | 413 | } |
349 | 414 | ||
350 | // Test for path which does not resolve to a value. | 415 | // Test path which is not an array |
351 | { | 416 | { |
352 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | 417 | int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello"); |
353 | Assert.That(result, Is.EqualTo(0)); | 418 | Assert.That(result, Is.EqualTo(-1)); |
354 | } | 419 | } |
355 | 420 | ||
421 | // Test fake path | ||
356 | { | 422 | { |
357 | int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); | 423 | int result = (int)InvokeOp("JsonGetArrayLength", storeId, "foo"); |
358 | Assert.That(result2, Is.EqualTo(0)); | 424 | Assert.That(result, Is.EqualTo(-1)); |
359 | } | 425 | } |
360 | 426 | ||
361 | // Test with fake store | 427 | // Test fake store |
362 | { | 428 | { |
363 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | 429 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); |
364 | int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); | 430 | int result = (int)InvokeOp("JsonGetArrayLength", fakeStoreId, "Hello.World"); |
365 | Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | 431 | Assert.That(result, Is.EqualTo(-1)); |
366 | } | 432 | } |
367 | } | 433 | } |
368 | 434 | ||
369 | [Test] | 435 | [Test] |
370 | public void TestJsonTestPathJson() | 436 | public void TestJsonGetPathType() |
371 | { | 437 | { |
372 | TestHelpers.InMethod(); | 438 | TestHelpers.InMethod(); |
373 | // TestHelpers.EnableLogging(); | 439 | // TestHelpers.EnableLogging(); |
374 | 440 | ||
375 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); | 441 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); |
376 | 442 | ||
377 | { | 443 | { |
378 | int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); | 444 | int result = (int)InvokeOp("JsonGetPathType", storeId, "."); |
379 | Assert.That(result, Is.EqualTo(1)); | 445 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); |
380 | } | 446 | } |
381 | 447 | ||
382 | // Test for path which does not resolve to a value. | ||
383 | { | 448 | { |
384 | int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello"); | 449 | int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); |
385 | Assert.That(result, Is.EqualTo(1)); | 450 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); |
386 | } | 451 | } |
387 | 452 | ||
388 | { | 453 | { |
389 | int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo"); | 454 | int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World"); |
390 | Assert.That(result2, Is.EqualTo(0)); | 455 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY)); |
391 | } | 456 | } |
392 | 457 | ||
393 | // Test with fake store | 458 | { |
459 | int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]"); | ||
460 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); | ||
461 | } | ||
462 | |||
463 | { | ||
464 | int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]"); | ||
465 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); | ||
466 | } | ||
467 | |||
468 | // Test for non-existant path | ||
469 | { | ||
470 | int result = (int)InvokeOp("JsonGetPathType", storeId, "foo"); | ||
471 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); | ||
472 | } | ||
473 | |||
474 | // Test for non-existant store | ||
394 | { | 475 | { |
395 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | 476 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); |
396 | int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); | 477 | int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, "."); |
397 | Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | 478 | Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); |
479 | } | ||
480 | } | ||
481 | |||
482 | [Test] | ||
483 | public void TestJsonList2Path() | ||
484 | { | ||
485 | TestHelpers.InMethod(); | ||
486 | // TestHelpers.EnableLogging(); | ||
487 | |||
488 | // Invoking these methods directly since I just couldn't get comms module invocation to work for some reason | ||
489 | // - some confusion with the methods that take a params object[] invocation. | ||
490 | { | ||
491 | string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo" }); | ||
492 | Assert.That(result, Is.EqualTo("{foo}")); | ||
493 | } | ||
494 | |||
495 | { | ||
496 | string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", "bar" }); | ||
497 | Assert.That(result, Is.EqualTo("{foo}.{bar}")); | ||
498 | } | ||
499 | |||
500 | { | ||
501 | string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", 1, "bar" }); | ||
502 | Assert.That(result, Is.EqualTo("{foo}.[1].{bar}")); | ||
398 | } | 503 | } |
399 | } | 504 | } |
400 | 505 | ||
@@ -414,17 +519,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
414 | Assert.That(value, Is.EqualTo("Times")); | 519 | Assert.That(value, Is.EqualTo("Times")); |
415 | } | 520 | } |
416 | 521 | ||
417 | // Commented out as this currently unexpectedly fails. | ||
418 | // Test setting a key containing periods with delineation | 522 | // Test setting a key containing periods with delineation |
419 | // { | 523 | { |
420 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); | 524 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); |
421 | // | 525 | |
422 | // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); | 526 | int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); |
423 | // Assert.That(result, Is.EqualTo(1)); | 527 | Assert.That(result, Is.EqualTo(1)); |
424 | // | 528 | |
425 | // string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); | 529 | string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); |
426 | // Assert.That(value, Is.EqualTo("Times")); | 530 | Assert.That(value, Is.EqualTo("Times")); |
427 | // } | 531 | } |
428 | 532 | ||
429 | // *** Test [] *** | 533 | // *** Test [] *** |
430 | 534 | ||
@@ -494,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
494 | Assert.That(value, Is.EqualTo("Times")); | 598 | Assert.That(value, Is.EqualTo("Times")); |
495 | } | 599 | } |
496 | 600 | ||
497 | // Commented out as this currently unexpectedly fails. | 601 | // // Commented out as this currently unexpectedly fails. |
498 | // // Test setting a key containing brackets around an integer with delineation | 602 | // // Test setting a key containing brackets around an integer with delineation |
499 | // { | 603 | // { |
500 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); | 604 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); |
@@ -502,7 +606,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
502 | // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); | 606 | // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); |
503 | // Assert.That(result, Is.EqualTo(1)); | 607 | // Assert.That(result, Is.EqualTo(1)); |
504 | // | 608 | // |
505 | // string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}"); | 609 | // string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[0]Circus}"); |
506 | // Assert.That(value, Is.EqualTo("Times")); | 610 | // Assert.That(value, Is.EqualTo("Times")); |
507 | // } | 611 | // } |
508 | 612 | ||
@@ -530,16 +634,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
530 | Assert.That(value, Is.EqualTo("")); | 634 | Assert.That(value, Is.EqualTo("")); |
531 | } | 635 | } |
532 | 636 | ||
533 | // Commented out as this currently unexpectedly fails. | 637 | // // Commented out as this currently unexpectedly fails. |
534 | // // Test setting a key containing unbalanced } | 638 | // // Test setting a key containing unbalanced } |
535 | // { | 639 | // { |
536 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); | 640 | // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); |
537 | // | 641 | // |
538 | // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); | 642 | // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); |
539 | // Assert.That(result, Is.EqualTo(1)); | 643 | // Assert.That(result, Is.EqualTo(0)); |
540 | // | ||
541 | // string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}"); | ||
542 | // Assert.That(value, Is.EqualTo("Times")); | ||
543 | // } | 644 | // } |
544 | 645 | ||
545 | // Test setting a key containing unbalanced { with delineation | 646 | // Test setting a key containing unbalanced { with delineation |
@@ -584,7 +685,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
584 | } | 685 | } |
585 | 686 | ||
586 | [Test] | 687 | [Test] |
587 | public void TestJsonSetValueJson() | 688 | public void TestJsonSetJson() |
588 | { | 689 | { |
589 | TestHelpers.InMethod(); | 690 | TestHelpers.InMethod(); |
590 | // TestHelpers.EnableLogging(); | 691 | // TestHelpers.EnableLogging(); |
@@ -593,7 +694,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
593 | { | 694 | { |
594 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); | 695 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); |
595 | 696 | ||
596 | int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'"); | 697 | int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'"); |
597 | Assert.That(result, Is.EqualTo(1)); | 698 | Assert.That(result, Is.EqualTo(1)); |
598 | 699 | ||
599 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); | 700 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); |
@@ -604,7 +705,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
604 | { | 705 | { |
605 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); | 706 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); |
606 | 707 | ||
607 | int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); | 708 | int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); |
608 | Assert.That(result, Is.EqualTo(1)); | 709 | Assert.That(result, Is.EqualTo(1)); |
609 | 710 | ||
610 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled"); | 711 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled"); |
@@ -615,7 +716,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
615 | { | 716 | { |
616 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); | 717 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); |
617 | 718 | ||
618 | int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "Times"); | 719 | int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times"); |
619 | Assert.That(result, Is.EqualTo(0)); | 720 | Assert.That(result, Is.EqualTo(0)); |
620 | 721 | ||
621 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); | 722 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); |
@@ -626,7 +727,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
626 | { | 727 | { |
627 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); | 728 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); |
628 | 729 | ||
629 | int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun.Circus", "'Times'"); | 730 | int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'"); |
630 | Assert.That(result, Is.EqualTo(0)); | 731 | Assert.That(result, Is.EqualTo(0)); |
631 | 732 | ||
632 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus"); | 733 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus"); |
@@ -636,7 +737,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
636 | // Test with fake store | 737 | // Test with fake store |
637 | { | 738 | { |
638 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | 739 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); |
639 | int fakeStoreValueSet = (int)InvokeOp("JsonSetValueJson", fakeStoreId, "Hello", "'World'"); | 740 | int fakeStoreValueSet = (int)InvokeOp("JsonSetJson", fakeStoreId, "Hello", "'World'"); |
640 | Assert.That(fakeStoreValueSet, Is.EqualTo(0)); | 741 | Assert.That(fakeStoreValueSet, Is.EqualTo(0)); |
641 | } | 742 | } |
642 | } | 743 | } |