diff options
author | Melanie | 2013-02-08 00:48:37 +0000 |
---|---|---|
committer | Melanie | 2013-02-08 00:48:37 +0000 |
commit | 8a2604f17ea2b28309922528ad90c31b522d4f9b (patch) | |
tree | bc93aabb2872b5add3943937d04476858c3b3931 /OpenSim | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Stop wrongly create a receiving store already populated with "Hello":"World" ... (diff) | |
download | opensim-SC_OLD-8a2604f17ea2b28309922528ad90c31b522d4f9b.zip opensim-SC_OLD-8a2604f17ea2b28309922528ad90c31b522d4f9b.tar.gz opensim-SC_OLD-8a2604f17ea2b28309922528ad90c31b522d4f9b.tar.bz2 opensim-SC_OLD-8a2604f17ea2b28309922528ad90c31b522d4f9b.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs | 108 |
1 files changed, 98 insertions, 10 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs index 5484d8d..6658e1e 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 | |||
158 | 158 | ||
159 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | 159 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); |
160 | Assert.That(value, Is.EqualTo("World")); | 160 | Assert.That(value, Is.EqualTo("World")); |
161 | |||
162 | // Test get of non-existing value | ||
163 | string fakeValueGet = (string)InvokeOp("JsonGetValue", storeId, "foo"); | ||
164 | Assert.That(fakeValueGet, Is.EqualTo("")); | ||
165 | |||
166 | // Test get from non-existing store | ||
167 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
168 | string fakeStoreValueGet = (string)InvokeOp("JsonGetValue", fakeStoreId, "Hello"); | ||
169 | Assert.That(fakeStoreValueGet, Is.EqualTo("")); | ||
161 | } | 170 | } |
162 | 171 | ||
163 | // [Test] | 172 | // [Test] |
@@ -199,6 +208,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
199 | 208 | ||
200 | string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | 209 | string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); |
201 | Assert.That(returnValue2, Is.EqualTo("")); | 210 | Assert.That(returnValue2, Is.EqualTo("")); |
211 | |||
212 | // Test remove of non-existing value | ||
213 | int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Hello"); | ||
214 | |||
215 | // XXX: Is this the best response to removing a value that isn't there? | ||
216 | Assert.That(fakeValueRemove, Is.EqualTo(1)); | ||
217 | |||
218 | // Test get from non-existing store | ||
219 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
220 | int fakeStoreValueRemove = (int)InvokeOp("JsonRemoveValue", fakeStoreId, "Hello"); | ||
221 | Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | ||
202 | } | 222 | } |
203 | 223 | ||
204 | [Test] | 224 | [Test] |
@@ -211,6 +231,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
211 | 231 | ||
212 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); | 232 | int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); |
213 | Assert.That(result, Is.EqualTo(1)); | 233 | Assert.That(result, Is.EqualTo(1)); |
234 | |||
235 | int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); | ||
236 | Assert.That(result2, Is.EqualTo(0)); | ||
237 | |||
238 | // Test with fake store | ||
239 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
240 | int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); | ||
241 | Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); | ||
214 | } | 242 | } |
215 | 243 | ||
216 | [Test] | 244 | [Test] |
@@ -226,6 +254,70 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
226 | 254 | ||
227 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); | 255 | string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); |
228 | Assert.That(value, Is.EqualTo("Times")); | 256 | Assert.That(value, Is.EqualTo("Times")); |
257 | |||
258 | // Test with fake store | ||
259 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
260 | int fakeStoreValueSet = (int)InvokeOp("JsonSetValue", fakeStoreId, "Hello", "World"); | ||
261 | Assert.That(fakeStoreValueSet, Is.EqualTo(0)); | ||
262 | } | ||
263 | |||
264 | /// <summary> | ||
265 | /// Test for writing json to a notecard | ||
266 | /// </summary> | ||
267 | /// <remarks> | ||
268 | /// TODO: Really needs to test correct receipt of the link_message event. Could do this by directly fetching | ||
269 | /// it via the MockScriptEngine or perhaps by a dummy script instance. | ||
270 | /// </remarks> | ||
271 | [Test] | ||
272 | public void TestJsonWriteNotecard() | ||
273 | { | ||
274 | TestHelpers.InMethod(); | ||
275 | // TestHelpers.EnableLogging(); | ||
276 | |||
277 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
278 | m_scene.AddSceneObject(so); | ||
279 | |||
280 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); | ||
281 | |||
282 | { | ||
283 | string notecardName = "nc1"; | ||
284 | |||
285 | // Write notecard | ||
286 | UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); | ||
287 | Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); | ||
288 | |||
289 | TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); | ||
290 | Assert.That(nc1Item, Is.Not.Null); | ||
291 | |||
292 | // TODO: Should independently check the contents. | ||
293 | } | ||
294 | |||
295 | { | ||
296 | // Try to write notecard against bad path | ||
297 | // In this case we do get a request id but no notecard is written. | ||
298 | string badPathNotecardName = "badPathNotecardName"; | ||
299 | |||
300 | UUID writeNotecardBadPathRequestId | ||
301 | = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "flibble", badPathNotecardName); | ||
302 | Assert.That(writeNotecardBadPathRequestId, Is.Not.EqualTo(UUID.Zero)); | ||
303 | |||
304 | TaskInventoryItem badPathItem = so.RootPart.Inventory.GetInventoryItem(badPathNotecardName); | ||
305 | Assert.That(badPathItem, Is.Null); | ||
306 | } | ||
307 | |||
308 | { | ||
309 | // Test with fake store | ||
310 | // In this case we do get a request id but no notecard is written. | ||
311 | string fakeStoreNotecardName = "fakeStoreNotecardName"; | ||
312 | |||
313 | UUID fakeStoreId = TestHelpers.ParseTail(0x500); | ||
314 | UUID fakeStoreWriteNotecardValue | ||
315 | = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, fakeStoreId, "/", fakeStoreNotecardName); | ||
316 | Assert.That(fakeStoreWriteNotecardValue, Is.Not.EqualTo(UUID.Zero)); | ||
317 | |||
318 | TaskInventoryItem fakeStoreItem = so.RootPart.Inventory.GetInventoryItem(fakeStoreNotecardName); | ||
319 | Assert.That(fakeStoreItem, Is.Null); | ||
320 | } | ||
229 | } | 321 | } |
230 | 322 | ||
231 | /// <summary> | 323 | /// <summary> |
@@ -236,10 +328,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
236 | /// it via the MockScriptEngine or perhaps by a dummy script instance. | 328 | /// it via the MockScriptEngine or perhaps by a dummy script instance. |
237 | /// </remarks> | 329 | /// </remarks> |
238 | [Test] | 330 | [Test] |
239 | public void TestJsonWriteReadNotecard() | 331 | public void TestJsonReadNotecard() |
240 | { | 332 | { |
241 | TestHelpers.InMethod(); | 333 | TestHelpers.InMethod(); |
242 | TestHelpers.EnableLogging(); | 334 | // TestHelpers.EnableLogging(); |
243 | 335 | ||
244 | string notecardName = "nc1"; | 336 | string notecardName = "nc1"; |
245 | 337 | ||
@@ -249,21 +341,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests | |||
249 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); | 341 | UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); |
250 | 342 | ||
251 | // Write notecard | 343 | // Write notecard |
252 | UUID writeNotecardRequestId = (UUID)InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); | 344 | InvokeOpOnHost("JsonWriteNotecard", so.UUID, storeId, "/", notecardName); |
253 | Assert.That(writeNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); | ||
254 | |||
255 | TaskInventoryItem nc1Item = so.RootPart.Inventory.GetInventoryItem(notecardName); | ||
256 | Assert.That(nc1Item, Is.Not.Null); | ||
257 | |||
258 | // TODO: Should probably independently check the contents. | ||
259 | 345 | ||
260 | // Read notecard | 346 | // Read notecard |
261 | UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); | 347 | UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ }"); |
262 | UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); | 348 | UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); |
263 | Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); | 349 | Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); |
264 | 350 | ||
265 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); | 351 | string value = (string)InvokeOp("JsonGetValue", storeId, "Hello"); |
266 | Assert.That(value, Is.EqualTo("World")); | 352 | Assert.That(value, Is.EqualTo("World")); |
353 | |||
354 | |||
267 | } | 355 | } |
268 | 356 | ||
269 | public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } | 357 | public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; } |