Merge branch 'master' into careminster

This commit is contained in:
Melanie
2013-01-26 01:56:23 +00:00
10 changed files with 523 additions and 118 deletions

View File

@@ -92,12 +92,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message);
m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message);
return;
}
if (m_enabled)
m_log.DebugFormat("[JsonStoreScripts] module is enabled");
m_log.DebugFormat("[JsonStoreScripts]: module is enabled");
}
// -----------------------------------------------------------------
@@ -150,7 +150,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>();
if (m_comms == null)
{
m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined");
m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined");
m_enabled = false;
return;
}
@@ -158,40 +158,40 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_store = m_scene.RequestModuleInterface<IJsonStoreModule>();
if (m_store == null)
{
m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined");
m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined");
m_enabled = false;
return;
}
try
{
m_comms.RegisterScriptInvocation(this,"JsonCreateStore");
m_comms.RegisterScriptInvocation(this,"JsonDestroyStore");
m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
m_comms.RegisterScriptInvocation(this,"JsonReadNotecard");
m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard");
m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
m_comms.RegisterScriptInvocation(this,"JsonTestPath");
m_comms.RegisterScriptInvocation(this,"JsonTestPathJson");
m_comms.RegisterScriptInvocation(this, "JsonTestPath");
m_comms.RegisterScriptInvocation(this, "JsonTestPathJson");
m_comms.RegisterScriptInvocation(this,"JsonGetValue");
m_comms.RegisterScriptInvocation(this,"JsonGetValueJson");
m_comms.RegisterScriptInvocation(this, "JsonGetValue");
m_comms.RegisterScriptInvocation(this, "JsonGetValueJson");
m_comms.RegisterScriptInvocation(this,"JsonTakeValue");
m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson");
m_comms.RegisterScriptInvocation(this, "JsonTakeValue");
m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson");
m_comms.RegisterScriptInvocation(this,"JsonReadValue");
m_comms.RegisterScriptInvocation(this,"JsonReadValueJson");
m_comms.RegisterScriptInvocation(this, "JsonReadValue");
m_comms.RegisterScriptInvocation(this, "JsonReadValueJson");
m_comms.RegisterScriptInvocation(this,"JsonSetValue");
m_comms.RegisterScriptInvocation(this,"JsonSetValueJson");
m_comms.RegisterScriptInvocation(this, "JsonSetValue");
m_comms.RegisterScriptInvocation(this, "JsonSetValueJson");
m_comms.RegisterScriptInvocation(this,"JsonRemoveValue");
m_comms.RegisterScriptInvocation(this, "JsonRemoveValue");
}
catch (Exception e)
{
// See http://opensimulator.org/mantis/view.php?id=5971 for more information
m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message);
m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message);
m_enabled = false;
}
}
@@ -354,7 +354,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString());
m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
}
DispatchValue(scriptID,reqID,String.Empty);
@@ -389,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString());
m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
}
DispatchValue(scriptID,reqID,String.Empty);
@@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
if (a.Type != (sbyte)AssetType.Notecard)
GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID));
m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID);
m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID);
try
{
@@ -432,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
}
catch (Exception e)
{
m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message);
m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message);
}
GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString()));
@@ -495,4 +495,4 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
}
}
}
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using log4net;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.ScriptModuleComms;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
{
/// <summary>
/// Tests for inventory functions in LSL
/// </summary>
[TestFixture]
public class LSL_ApiInventoryTests : OpenSimTestCase
{
private Scene m_scene;
private MockScriptEngine m_engine;
private ScriptModuleCommsModule m_smcm;
[SetUp]
public override void SetUp()
{
base.SetUp();
TestHelpers.EnableLogging();
IConfigSource configSource = new IniConfigSource();
IConfig jsonStoreConfig = configSource.AddConfig("JsonStore");
jsonStoreConfig.Set("Enabled", "true");
m_engine = new MockScriptEngine();
m_smcm = new ScriptModuleCommsModule();
JsonStoreModule jsm = new JsonStoreModule();
JsonStoreScriptModule jssm = new JsonStoreScriptModule();
m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm);
}
// [Test]
public void TestJsonCreateStore()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" });
Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
}
// [Test]
public void TestJsonGetValue()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
string value
= (string)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
Assert.That(value, Is.EqualTo("World"));
}
// [Test]
public void TestJsonTestPath()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
int result
= (int)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" });
Assert.That(result, Is.EqualTo(1));
}
// [Test]
public void TestJsonSetValue()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID storeId
= (UUID)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" });
int result
= (int)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" });
Assert.That(result, Is.EqualTo(1));
string value
= (string)m_smcm.InvokeOperation(
UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
Assert.That(value, Is.EqualTo("World"));
}
}
}