Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
avinationmerge
Melanie 2013-02-15 21:42:16 +00:00
commit ea8c5ba707
13 changed files with 270 additions and 106 deletions

View File

@ -359,11 +359,11 @@ Asset service request failures: {3}" + Environment.NewLine,
inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
Dictionary<string, Dictionary<string, Stat>> sceneStats;
SortedDictionary<string, SortedDictionary<string, Stat>> sceneStats;
if (StatsManager.TryGetStats("scene", out sceneStats))
{
foreach (KeyValuePair<string, Dictionary<string, Stat>> kvp in sceneStats)
foreach (KeyValuePair<string, SortedDictionary<string, Stat>> kvp in sceneStats)
{
foreach (Stat stat in kvp.Value.Values)
{

View File

@ -51,8 +51,8 @@ namespace OpenSim.Framework.Monitoring
/// <remarks>
/// Do not add or remove directly from this dictionary.
/// </remarks>
public static Dictionary<string, Dictionary<string, Dictionary<string, Stat>>> RegisteredStats
= new Dictionary<string, Dictionary<string, Dictionary<string, Stat>>>();
public static SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>> RegisteredStats
= new SortedDictionary<string, SortedDictionary<string, SortedDictionary<string, Stat>>>();
private static AssetStatsCollector assetStats;
private static UserStatsCollector userStats;
@ -101,7 +101,7 @@ namespace OpenSim.Framework.Monitoring
}
else
{
Dictionary<string, Dictionary<string, Stat>> category;
SortedDictionary<string, SortedDictionary<string, Stat>> category;
if (!RegisteredStats.TryGetValue(categoryName, out category))
{
con.OutputFormat("No such category as {0}", categoryName);
@ -120,7 +120,7 @@ namespace OpenSim.Framework.Monitoring
}
private static void OutputCategoryStatsToConsole(
ICommandConsole con, Dictionary<string, Dictionary<string, Stat>> category)
ICommandConsole con, SortedDictionary<string, SortedDictionary<string, Stat>> category)
{
foreach (var container in category.Values)
{
@ -160,8 +160,8 @@ namespace OpenSim.Framework.Monitoring
/// <returns></returns>
public static bool RegisterStat(Stat stat)
{
Dictionary<string, Dictionary<string, Stat>> category = null, newCategory;
Dictionary<string, Stat> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
SortedDictionary<string, Stat> container = null, newContainer;
lock (RegisteredStats)
{
@ -175,14 +175,14 @@ namespace OpenSim.Framework.Monitoring
// This means that we don't need to lock or copy them on iteration, which will be a much more
// common operation after startup.
if (container != null)
newContainer = new Dictionary<string, Stat>(container);
newContainer = new SortedDictionary<string, Stat>(container);
else
newContainer = new Dictionary<string, Stat>();
newContainer = new SortedDictionary<string, Stat>();
if (category != null)
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
else
newCategory = new Dictionary<string, Dictionary<string, Stat>>();
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>();
newContainer[stat.ShortName] = stat;
newCategory[stat.Container] = newContainer;
@ -196,21 +196,21 @@ namespace OpenSim.Framework.Monitoring
/// Deregister a statistic
/// </summary>>
/// <param name='stat'></param>
/// <returns></returns
/// <returns></returns>
public static bool DeregisterStat(Stat stat)
{
Dictionary<string, Dictionary<string, Stat>> category = null, newCategory;
Dictionary<string, Stat> container = null, newContainer;
SortedDictionary<string, SortedDictionary<string, Stat>> category = null, newCategory;
SortedDictionary<string, Stat> container = null, newContainer;
lock (RegisteredStats)
{
if (!TryGetStat(stat, out category, out container))
return false;
newContainer = new Dictionary<string, Stat>(container);
newContainer = new SortedDictionary<string, Stat>(container);
newContainer.Remove(stat.ShortName);
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
newCategory = new SortedDictionary<string, SortedDictionary<string, Stat>>(category);
newCategory.Remove(stat.Container);
newCategory[stat.Container] = newContainer;
@ -220,15 +220,15 @@ namespace OpenSim.Framework.Monitoring
}
}
public static bool TryGetStats(string category, out Dictionary<string, Dictionary<string, Stat>> stats)
public static bool TryGetStats(string category, out SortedDictionary<string, SortedDictionary<string, Stat>> stats)
{
return RegisteredStats.TryGetValue(category, out stats);
}
public static bool TryGetStat(
Stat stat,
out Dictionary<string, Dictionary<string, Stat>> category,
out Dictionary<string, Stat> container)
out SortedDictionary<string, SortedDictionary<string, Stat>> category,
out SortedDictionary<string, Stat> container)
{
category = null;
container = null;
@ -252,9 +252,9 @@ namespace OpenSim.Framework.Monitoring
{
lock (RegisteredStats)
{
foreach (Dictionary<string, Dictionary<string, Stat>> category in RegisteredStats.Values)
foreach (SortedDictionary<string, SortedDictionary<string, Stat>> category in RegisteredStats.Values)
{
foreach (Dictionary<string, Stat> container in category.Values)
foreach (SortedDictionary<string, Stat> container in category.Values)
{
foreach (Stat stat in container.Values)
{

View File

@ -535,6 +535,8 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <param name="message"></param>
public void Close(string message)
{
if (_networkContext == null)
return;
if (_networkContext.Stream != null)
{
if (_networkContext.Stream.CanWrite)

View File

@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
public class AssetTransactionModule : INonSharedRegionModule,
IAgentAssetTransactions
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_Scene;
private bool m_dumpAssetsToFile = false;

View File

@ -44,7 +44,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly bool ENABLED = false; // enable for testing

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging
try
{
IConfig statConfig = source.Configs["Statistics.Binary"];
if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled"))
if (statConfig != null && statConfig.Contains("enabled") && statConfig.GetBoolean("enabled"))
{
if (statConfig.Contains("collect_region_stats"))
{

View File

@ -111,7 +111,8 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
m_rpcPending = new Dictionary<UUID, RPCRequestInfo>();
m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>();
m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>();
if (config.Configs["XMLRPC"] != null)
{
try
{
m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort);
@ -120,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
{
}
}
}
public void PostInitialise()
{

View File

@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Interfaces
bool CreateStore(string value, ref UUID result);
bool DestroyStore(UUID storeID);
JsonStoreNodeType PathType(UUID storeID, string path);
JsonStoreNodeType GetPathType(UUID storeID, string path);
bool TestStore(UUID storeID);
bool TestPath(UUID storeID, string path, bool useJson);
@ -60,6 +60,6 @@ namespace OpenSim.Region.Framework.Interfaces
void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
int ArrayLength(UUID storeID, string path);
int GetArrayLength(UUID storeID, string path);
}
}

View File

@ -791,6 +791,19 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="obj">The object being removed from the scene</param>
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
/// <summary>
/// Triggered when an object is placed into the physical scene (PhysicsActor created).
/// </summary>
public event Action<SceneObjectPart> OnObjectAddedToPhysicalScene;
/// <summary>
/// Triggered when an object is removed from the physical scene (PhysicsActor destroyed).
/// </summary>
/// <remarks>
/// Note: this is triggered just before the PhysicsActor is removed from the
/// physics engine so the receiver can do any necessary cleanup before its destruction.
/// </remarks>
public event Action<SceneObjectPart> OnObjectRemovedFromPhysicalScene;
/// <summary>
/// Triggered when an object is removed from the scene.
/// </summary>
@ -1541,6 +1554,48 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void TriggerObjectAddedToPhysicalScene(SceneObjectPart obj)
{
Action<SceneObjectPart> handler = OnObjectAddedToPhysicalScene;
if (handler != null)
{
foreach (Action<SceneObjectPart> d in handler.GetInvocationList())
{
try
{
d(obj);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerObjectAddedToPhysicalScene failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
public void TriggerObjectRemovedFromPhysicalScene(SceneObjectPart obj)
{
Action<SceneObjectPart> handler = OnObjectRemovedFromPhysicalScene;
if (handler != null)
{
foreach (Action<SceneObjectPart> d in handler.GetInvocationList())
{
try
{
d(obj);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerObjectRemovedFromPhysicalScene failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
public void TriggerShutdown()
{
Action handlerShutdown = OnShutdown;

View File

@ -4738,6 +4738,8 @@ namespace OpenSim.Region.Framework.Scenes
}
PhysActor = pa;
ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this);
}
/// <summary>
@ -4757,6 +4759,8 @@ namespace OpenSim.Region.Framework.Scenes
pa.OnOutOfBounds -= PhysicsOutOfBounds;
ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
}
PhysActor = null;
}

View File

@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreNodeType PathType(UUID storeID, string path)
public JsonStoreNodeType GetPathType(UUID storeID, string path)
{
if (! m_enabled) return JsonStoreNodeType.Undefined;
@ -407,7 +407,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
///
/// </summary>
// -----------------------------------------------------------------
public int ArrayLength(UUID storeID, string path)
public int GetArrayLength(UUID storeID, string path)
{
if (! m_enabled) return -1;

View File

@ -215,19 +215,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#endregion
#region ScriptConstantInteface
#region ScriptConstantsInterface
[ScriptConstant]
public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined;
public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
[ScriptConstant]
public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object;
public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object;
[ScriptConstant]
public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array;
public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array;
[ScriptConstant]
public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value;
public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value;
#endregion
@ -336,9 +336,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public int JsonPathType(UUID hostID, UUID scriptID, UUID storeID, string path)
public int JsonGetPathType(UUID hostID, UUID scriptID, UUID storeID, string path)
{
return (int)m_store.PathType(storeID,path);
return (int)m_store.GetPathType(storeID,path);
}
[ScriptInvocation]
@ -365,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
[ScriptInvocation]
public int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
public int JsonSetJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
{
return m_store.SetValue(storeID,path,value,true) ? 1 : 0;
}
@ -387,9 +387,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public int JsonArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path)
public int JsonGetArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path)
{
return m_store.ArrayLength(storeID,path);
return m_store.GetArrayLength(storeID,path);
}
// -----------------------------------------------------------------
@ -406,7 +406,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
[ScriptInvocation]
public string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
public string JsonGetJson(UUID hostID, UUID scriptID, UUID storeID, string path)
{
string value = String.Empty;
m_store.GetValue(storeID,path,true, out value);

View File

@ -53,6 +53,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
private Scene m_scene;
private MockScriptEngine m_engine;
private ScriptModuleCommsModule m_smcm;
private JsonStoreScriptModule m_jssm;
[TestFixtureSetUp]
public void FixtureInit()
@ -82,10 +83,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
m_engine = new MockScriptEngine();
m_smcm = new ScriptModuleCommsModule();
JsonStoreModule jsm = new JsonStoreModule();
JsonStoreScriptModule jssm = new JsonStoreScriptModule();
m_jssm = new JsonStoreScriptModule();
m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm);
SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, m_jssm);
try
{
@ -208,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
}
[Test]
public void TestJsonGetValueJson()
public void TestJsonGetJson()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
@ -216,26 +217,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }");
{
string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello.World");
string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World");
Assert.That(value, Is.EqualTo("'Two'"));
}
// Test get of path section instead of leaf
{
string value = (string)InvokeOp("JsonGetValueJson", storeId, "Hello");
string value = (string)InvokeOp("JsonGetJson", storeId, "Hello");
Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}"));
}
// Test get of non-existing value
{
string fakeValueGet = (string)InvokeOp("JsonGetValueJson", storeId, "foo");
string fakeValueGet = (string)InvokeOp("JsonGetJson", storeId, "foo");
Assert.That(fakeValueGet, Is.EqualTo(""));
}
// Test get from non-existing store
{
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
string fakeStoreValueGet = (string)InvokeOp("JsonGetValueJson", fakeStoreId, "Hello");
string fakeStoreValueGet = (string)InvokeOp("JsonGetJson", fakeStoreId, "Hello");
Assert.That(fakeStoreValueGet, Is.EqualTo(""));
}
}
@ -293,7 +294,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
Assert.That(result, Is.EqualTo(0));
string returnValue2 = (string)InvokeOp("JsonGetValueJson", storeId, "Hello");
string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello");
Assert.That(returnValue2, Is.EqualTo(""));
}
@ -314,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
Assert.That(stringReturnValue, Is.EqualTo("value2"));
stringReturnValue = (string)InvokeOp("JsonGetValueJson", storeId, "Hello[1]");
stringReturnValue = (string)InvokeOp("JsonGetJson", storeId, "Hello[1]");
Assert.That(stringReturnValue, Is.EqualTo(""));
}
@ -334,67 +335,171 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
}
}
// [Test]
// public void TestJsonTestPath()
// {
// TestHelpers.InMethod();
//// TestHelpers.EnableLogging();
//
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
//
// {
// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World");
// Assert.That(result, Is.EqualTo(1));
// }
//
// // Test for path which does not resolve to a value.
// {
// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
// Assert.That(result, Is.EqualTo(0));
// }
//
// {
// 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]
// public void TestJsonTestPathJson()
// {
// TestHelpers.InMethod();
//// TestHelpers.EnableLogging();
//
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
//
// {
// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World");
// Assert.That(result, Is.EqualTo(1));
// }
//
// // Test for path which does not resolve to a value.
// {
// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello");
// Assert.That(result, Is.EqualTo(1));
// }
//
// {
// int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo");
// Assert.That(result2, Is.EqualTo(0));
// }
//
// // Test with fake store
// {
// UUID fakeStoreId = TestHelpers.ParseTail(0x500);
// int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello");
// Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
// }
// }
[Test]
public void TestJsonTestPath()
public void TestGetArrayLength()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
{
int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(2));
}
// Test for path which does not resolve to a value.
// Test path which is not an array
{
int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
Assert.That(result, Is.EqualTo(0));
int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello");
Assert.That(result, Is.EqualTo(-1));
}
// Test fake path
{
int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo");
Assert.That(result2, Is.EqualTo(0));
int result = (int)InvokeOp("JsonGetArrayLength", storeId, "foo");
Assert.That(result, Is.EqualTo(-1));
}
// Test with fake store
// Test fake store
{
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello");
Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
int result = (int)InvokeOp("JsonGetArrayLength", fakeStoreId, "Hello.World");
Assert.That(result, Is.EqualTo(-1));
}
}
[Test]
public void TestJsonTestPathJson()
public void TestJsonGetPathType()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
{
int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(1));
}
// Test for path which does not resolve to a value.
{
int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello");
Assert.That(result, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
}
{
int result2 = (int)InvokeOp("JsonTestPathJson", storeId, "foo");
Assert.That(result2, Is.EqualTo(0));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
}
// Test with fake store
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
}
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE));
}
// Test for non-existant path
{
int result = (int)InvokeOp("JsonGetPathType", storeId, "foo");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
}
// Test for non-existant store
{
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello");
Assert.That(fakeStoreValueRemove, Is.EqualTo(0));
int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF));
}
}
[Test]
public void TestJsonList2Path()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
// Invoking these methods directly since I just couldn't get comms module invocation to work for some reason
// - some confusion with the methods that take a params object[] invocation.
{
string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo" });
Assert.That(result, Is.EqualTo("{foo}"));
}
{
string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", "bar" });
Assert.That(result, Is.EqualTo("{foo}.{bar}"));
}
{
string result = m_jssm.JsonList2Path(UUID.Zero, UUID.Zero, new object[] { "foo", 1, "bar" });
Assert.That(result, Is.EqualTo("{foo}.[1].{bar}"));
}
}
@ -414,17 +519,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo("Times"));
}
// Commented out as this currently unexpectedly fails.
// Test setting a key containing periods with delineation
// {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
//
// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times");
// Assert.That(result, Is.EqualTo(1));
//
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}");
// Assert.That(value, Is.EqualTo("Times"));
// }
{
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times");
Assert.That(result, Is.EqualTo(1));
string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}");
Assert.That(value, Is.EqualTo("Times"));
}
// *** Test [] ***
@ -494,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo("Times"));
}
// Commented out as this currently unexpectedly fails.
// // Commented out as this currently unexpectedly fails.
// // Test setting a key containing brackets around an integer with delineation
// {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
@ -502,7 +606,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times");
// Assert.That(result, Is.EqualTo(1));
//
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[]Circus}");
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun[0]Circus}");
// Assert.That(value, Is.EqualTo("Times"));
// }
@ -530,16 +634,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo(""));
}
// Commented out as this currently unexpectedly fails.
// // Commented out as this currently unexpectedly fails.
// // Test setting a key containing unbalanced }
// {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
//
// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times");
// Assert.That(result, Is.EqualTo(1));
//
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}");
// Assert.That(value, Is.EqualTo("Times"));
// Assert.That(result, Is.EqualTo(0));
// }
// Test setting a key containing unbalanced { with delineation
@ -584,7 +685,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
}
[Test]
public void TestJsonSetValueJson()
public void TestJsonSetJson()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
@ -593,7 +694,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "'Times'");
int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'");
Assert.That(result, Is.EqualTo(1));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
@ -604,7 +705,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "{ 'Filled' : 'Times' }");
int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }");
Assert.That(result, Is.EqualTo(1));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled");
@ -615,7 +716,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun", "Times");
int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times");
Assert.That(result, Is.EqualTo(0));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
@ -626,7 +727,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
int result = (int)InvokeOp("JsonSetValueJson", storeId, "Fun.Circus", "'Times'");
int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'");
Assert.That(result, Is.EqualTo(0));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus");
@ -636,7 +737,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
// Test with fake store
{
UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int fakeStoreValueSet = (int)InvokeOp("JsonSetValueJson", fakeStoreId, "Hello", "'World'");
int fakeStoreValueSet = (int)InvokeOp("JsonSetJson", fakeStoreId, "Hello", "'World'");
Assert.That(fakeStoreValueSet, Is.EqualTo(0));
}
}