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, inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime,
netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime));
Dictionary<string, Dictionary<string, Stat>> sceneStats; SortedDictionary<string, SortedDictionary<string, Stat>> sceneStats;
if (StatsManager.TryGetStats("scene", out 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) foreach (Stat stat in kvp.Value.Values)
{ {

View File

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

View File

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

View File

@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
public class AssetTransactionModule : INonSharedRegionModule, public class AssetTransactionModule : INonSharedRegionModule,
IAgentAssetTransactions 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; protected Scene m_Scene;
private bool m_dumpAssetsToFile = false; 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")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule 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 private static readonly bool ENABLED = false; // enable for testing

View File

@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Framework.Statistics.Logging
try try
{ {
IConfig statConfig = source.Configs["Statistics.Binary"]; 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")) 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_rpcPending = new Dictionary<UUID, RPCRequestInfo>();
m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>(); m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>();
m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>(); m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>();
if (config.Configs["XMLRPC"] != null)
{
try try
{ {
m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort);
@ -120,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
{ {
} }
} }
}
public void PostInitialise() public void PostInitialise()
{ {

View File

@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Interfaces
bool CreateStore(string value, ref UUID result); bool CreateStore(string value, ref UUID result);
bool DestroyStore(UUID storeID); bool DestroyStore(UUID storeID);
JsonStoreNodeType PathType(UUID storeID, string path); JsonStoreNodeType GetPathType(UUID storeID, string path);
bool TestStore(UUID storeID); bool TestStore(UUID storeID);
bool TestPath(UUID storeID, string path, bool useJson); 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 TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback);
void ReadValue(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> /// <param name="obj">The object being removed from the scene</param>
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 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> /// <summary>
/// Triggered when an object is removed from the scene. /// Triggered when an object is removed from the scene.
/// </summary> /// </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() public void TriggerShutdown()
{ {
Action handlerShutdown = OnShutdown; Action handlerShutdown = OnShutdown;

View File

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

View File

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

View File

@ -215,19 +215,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#endregion #endregion
#region ScriptConstantInteface #region ScriptConstantsInterface
[ScriptConstant] [ScriptConstant]
public static readonly int JSONTYPEUNDEF = (int)JsonStoreNodeType.Undefined; public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
[ScriptConstant] [ScriptConstant]
public static readonly int JSONTYPEOBJECT = (int)JsonStoreNodeType.Object; public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object;
[ScriptConstant] [ScriptConstant]
public static readonly int JSONTYPEARRAY = (int)JsonStoreNodeType.Array; public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array;
[ScriptConstant] [ScriptConstant]
public static readonly int JSONTYPEVALUE = (int)JsonStoreNodeType.Value; public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value;
#endregion #endregion
@ -336,9 +336,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
[ScriptInvocation] [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] [ScriptInvocation]
@ -365,7 +365,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
} }
[ScriptInvocation] [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; return m_store.SetValue(storeID,path,value,true) ? 1 : 0;
} }
@ -387,9 +387,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
[ScriptInvocation] [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] [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; string value = String.Empty;
m_store.GetValue(storeID,path,true, out value); 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 Scene m_scene;
private MockScriptEngine m_engine; private MockScriptEngine m_engine;
private ScriptModuleCommsModule m_smcm; private ScriptModuleCommsModule m_smcm;
private JsonStoreScriptModule m_jssm;
[TestFixtureSetUp] [TestFixtureSetUp]
public void FixtureInit() public void FixtureInit()
@ -82,10 +83,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
m_engine = new MockScriptEngine(); m_engine = new MockScriptEngine();
m_smcm = new ScriptModuleCommsModule(); m_smcm = new ScriptModuleCommsModule();
JsonStoreModule jsm = new JsonStoreModule(); JsonStoreModule jsm = new JsonStoreModule();
JsonStoreScriptModule jssm = new JsonStoreScriptModule(); m_jssm = new JsonStoreScriptModule();
m_scene = new SceneHelpers().SetupScene(); 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 try
{ {
@ -208,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
} }
[Test] [Test]
public void TestJsonGetValueJson() public void TestJsonGetJson()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// TestHelpers.EnableLogging(); // TestHelpers.EnableLogging();
@ -216,26 +217,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); 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'")); Assert.That(value, Is.EqualTo("'Two'"));
} }
// Test get of path section instead of leaf // 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\"}")); Assert.That(value, Is.EqualTo("{\"World\":\"Two\"}"));
} }
// Test get of non-existing value // 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("")); Assert.That(fakeValueGet, Is.EqualTo(""));
} }
// Test get from non-existing store // Test get from non-existing store
{ {
UUID fakeStoreId = TestHelpers.ParseTail(0x500); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
string fakeStoreValueGet = (string)InvokeOp("JsonGetValueJson", fakeStoreId, "Hello"); string fakeStoreValueGet = (string)InvokeOp("JsonGetJson", fakeStoreId, "Hello");
Assert.That(fakeStoreValueGet, Is.EqualTo("")); Assert.That(fakeStoreValueGet, Is.EqualTo(""));
} }
} }
@ -293,7 +294,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int result = (int)InvokeOp("JsonTestPath", storeId, "Hello"); int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
Assert.That(result, Is.EqualTo(0)); 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("")); Assert.That(returnValue2, Is.EqualTo(""));
} }
@ -314,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
Assert.That(stringReturnValue, Is.EqualTo("value2")); 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("")); 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] [Test]
public void TestJsonTestPath() public void TestGetArrayLength()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// TestHelpers.EnableLogging(); // 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"); int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(1)); 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"); int result = (int)InvokeOp("JsonGetArrayLength", storeId, "Hello");
Assert.That(result, Is.EqualTo(0)); Assert.That(result, Is.EqualTo(-1));
} }
// Test fake path
{ {
int result2 = (int)InvokeOp("JsonTestPath", storeId, "foo"); int result = (int)InvokeOp("JsonGetArrayLength", storeId, "foo");
Assert.That(result2, Is.EqualTo(0)); Assert.That(result, Is.EqualTo(-1));
} }
// Test with fake store // Test fake store
{ {
UUID fakeStoreId = TestHelpers.ParseTail(0x500); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int fakeStoreValueRemove = (int)InvokeOp("JsonTestPath", fakeStoreId, "Hello"); int result = (int)InvokeOp("JsonGetArrayLength", fakeStoreId, "Hello.World");
Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); Assert.That(result, Is.EqualTo(-1));
} }
} }
[Test] [Test]
public void TestJsonTestPathJson() public void TestJsonGetPathType()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// TestHelpers.EnableLogging(); // 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"); int result = (int)InvokeOp("JsonGetPathType", storeId, ".");
Assert.That(result, Is.EqualTo(1)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT));
}
// 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"); int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello");
Assert.That(result2, Is.EqualTo(0)); 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); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int fakeStoreValueRemove = (int)InvokeOp("JsonTestPathJson", fakeStoreId, "Hello"); int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, ".");
Assert.That(fakeStoreValueRemove, Is.EqualTo(0)); 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")); Assert.That(value, Is.EqualTo("Times"));
} }
// Commented out as this currently unexpectedly fails.
// Test setting a key containing periods with delineation // Test setting a key containing periods with delineation
// { {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
//
// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times");
// Assert.That(result, Is.EqualTo(1)); Assert.That(result, Is.EqualTo(1));
//
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}"); string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun.Circus}");
// Assert.That(value, Is.EqualTo("Times")); Assert.That(value, Is.EqualTo("Times"));
// } }
// *** Test [] *** // *** Test [] ***
@ -494,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo("Times")); 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 // // Test setting a key containing brackets around an integer with delineation
// { // {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // 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"); // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times");
// Assert.That(result, Is.EqualTo(1)); // 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")); // Assert.That(value, Is.EqualTo("Times"));
// } // }
@ -530,16 +634,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(value, Is.EqualTo("")); 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 } // // Test setting a key containing unbalanced }
// { // {
// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); // UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
// //
// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); // int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times");
// Assert.That(result, Is.EqualTo(1)); // Assert.That(result, Is.EqualTo(0));
//
// string value = (string)InvokeOp("JsonGetValue", storeId, "{Fun}Circus}");
// Assert.That(value, Is.EqualTo("Times"));
// } // }
// Test setting a key containing unbalanced { with delineation // Test setting a key containing unbalanced { with delineation
@ -584,7 +685,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
} }
[Test] [Test]
public void TestJsonSetValueJson() public void TestJsonSetJson()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// TestHelpers.EnableLogging(); // TestHelpers.EnableLogging();
@ -593,7 +694,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{ {
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 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)); Assert.That(result, Is.EqualTo(1));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
@ -604,7 +705,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{ {
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 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)); Assert.That(result, Is.EqualTo(1));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled"); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Filled");
@ -615,7 +716,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{ {
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 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)); Assert.That(result, Is.EqualTo(0));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun"); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun");
@ -626,7 +727,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{ {
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 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)); Assert.That(result, Is.EqualTo(0));
string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus"); string value = (string)InvokeOp("JsonGetValue", storeId, "Fun.Circus");
@ -636,7 +737,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
// Test with fake store // Test with fake store
{ {
UUID fakeStoreId = TestHelpers.ParseTail(0x500); 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)); Assert.That(fakeStoreValueSet, Is.EqualTo(0));
} }
} }