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(-)
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