From 715d6f2da1fa9fb770899a399ccbece2d35a2323 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 7 Feb 2013 23:52:28 +0000 Subject: Add testing for getting non-existing values and values from a non-existing datastore to TestJsonGetValue() --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 5484d8d..d341901 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -158,6 +158,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); Assert.That(value, Is.EqualTo("World")); + + // Test get of non-existing value + string fakeValueGet = (string)InvokeOp("JsonGetValue", storeId, "foo"); + Assert.That(fakeValueGet, Is.EqualTo("")); + + // Test get from non-existing store + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + string fakeStoreValueGet = (string)InvokeOp("JsonGetValue", fakeStoreId, "Hello"); + Assert.That(fakeStoreValueGet, Is.EqualTo("")); } // [Test] @@ -239,7 +248,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests public void TestJsonWriteReadNotecard() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// TestHelpers.EnableLogging(); string notecardName = "nc1"; -- cgit v1.1 From 75f1e0431580975e5588b63025c7c94aedafb050 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 7 Feb 2013 23:58:19 +0000 Subject: Add tests for removing fake values/from fake store in TestJsonRemoveValue() Again, need to check if returning true for removing a value that doesn't exist is most appropriate. --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index d341901..297c33c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -208,6 +208,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); Assert.That(returnValue2, Is.EqualTo("")); + + // Test remove of non-existing value + int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Hello"); + + // XXX: Is this the best response to removing a value that isn't there? + Assert.That(fakeValueRemove, Is.EqualTo(1)); + + // Test get from non-existing store + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello"); + Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); } [Test] -- cgit v1.1 From be982666fb403aa5ee254903cdae0231131c6d70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Feb 2013 00:01:06 +0000 Subject: Extend TestJsonTestPath() regression test with checks against fake values and fake stores --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 297c33c..f2de0af 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -231,6 +231,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); Assert.That(result, Is.EqualTo(1)); + + int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); + Assert.That(result2, Is.EqualTo(0)); + + // Test with fake store + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); + Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); } [Test] -- cgit v1.1 From bef8961578d060faea8900e3be4fb9a8a4fe783d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Feb 2013 00:04:05 +0000 Subject: Extend TestJsonSetValue() regressio ntes tto test against a fake store --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index f2de0af..73bc955 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -254,6 +254,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); Assert.That(value, Is.EqualTo("Times")); + + // Test with fake store + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + int fakeStoreValueSet = (int)InvokeOp("JsonSetValue", fakeStoreId, "Hello", "World"); + Assert.That(fakeStoreValueSet, Is.EqualTo(0)); } /// -- cgit v1.1 From 24bfdbfb804293362bbdc86dd5bb46e6add26bcb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Feb 2013 00:36:20 +0000 Subject: Extend TestJsonWriteNotecard() regression test for cases with fake paths and fake stores. Also separates out TestJsonWriteReadNotecard() into separate write and read tests --- .../JsonStore/Tests/JsonStoreScriptModuleTests.cs | 69 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 73bc955..ce586be 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -262,6 +262,65 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests } /// + /// Test for writing json to a notecard + /// + /// + /// TODO: Really needs to test correct receipt of the link_message event. Could do this by directly fetching + /// it via the MockScriptEngine or perhaps by a dummy script instance. + /// + [Test] + public void TestJsonWriteNotecard() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); + m_scene.AddSceneObject(so); + + UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); + + { + string notecardName = "nc1"; + + // Write notecard + UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); + Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); + + TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); + Assert.That(nc1Item, Is.Not.Null); + + // TODO: Should independently check the contents. + } + + { + // Try to write notecard against bad path + // In this case we do get a request id but no notecard is written. + string badPathNotecardName = "badPathNotecardName"; + + UUID writeNotecardBadPathRequestId + = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "flibble", badPathNotecardName); + Assert.That(writeNotecardBadPathRequestId, Is.Not.EqualTo(UUID.Zero)); + + TaskInventoryItem badPathItem = so.RootPart.Inventory.GetInventoryItem(badPathNotecardName); + Assert.That(badPathItem, Is.Null); + } + + { + // Test with fake store + // In this case we do get a request id but no notecard is written. + string fakeStoreNotecardName = "fakeStoreNotecardName"; + + UUID fakeStoreId = TestHelpers.ParseTail(0x500); + UUID fakeStoreWriteNotecardValue + = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, fakeStoreId, "/", fakeStoreNotecardName); + Assert.That(fakeStoreWriteNotecardValue, Is.Not.EqualTo(UUID.Zero)); + + TaskInventoryItem fakeStoreItem = so.RootPart.Inventory.GetInventoryItem(fakeStoreNotecardName); + Assert.That(fakeStoreItem, Is.Null); + } + } + + /// /// Test for reading and writing json to a notecard /// /// @@ -269,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests /// it via the MockScriptEngine or perhaps by a dummy script instance. /// [Test] - public void TestJsonWriteReadNotecard() + public void TestJsonReadNotecard() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); @@ -282,13 +341,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); // Write notecard - UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); - Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); - - TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); - Assert.That(nc1Item, Is.Not.Null); - - // TODO: Should probably independently check the contents. + InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); // Read notecard UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); -- cgit v1.1 From 9c9b48b29a97d97625330bbad7cddbe6d2dcd28d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 8 Feb 2013 00:38:30 +0000 Subject: Stop wrongly create a receiving store already populated with "Hello":"World" in TestJsonReadNotecard() --- .../Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index ce586be..6658e1e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs @@ -344,12 +344,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); // Read notecard - UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); + UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ }"); UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); Assert.That(value, Is.EqualTo("World")); + + } public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } -- cgit v1.1