aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting
diff options
context:
space:
mode:
authorMelanie2013-01-31 02:53:11 +0000
committerMelanie2013-01-31 02:53:11 +0000
commit9a4de546fe92105c570d6861377ec47d32b4186e (patch)
treeedfb86074fc7c78126203a2c05a38e260c0d4076 /OpenSim/Region/OptionalModules/Scripting
parentMerge branch 'avination' into careminster (diff)
parentAdd JsonTestStore to determine if a JsonStore is associated with (diff)
downloadopensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.zip
opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.gz
opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.bz2
opensim-SC-9a4de546fe92105c570d6861377ec47d32b4186e.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs13
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs11
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs119
3 files changed, 110 insertions, 33 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
index e68764a..b9b3ebc 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
@@ -221,6 +221,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
221 /// 221 ///
222 /// </summary> 222 /// </summary>
223 // ----------------------------------------------------------------- 223 // -----------------------------------------------------------------
224 public bool TestStore(UUID storeID)
225 {
226 if (! m_enabled) return false;
227
228 lock (m_JsonValueStore)
229 return m_JsonValueStore.ContainsKey(storeID);
230 }
231
232 // -----------------------------------------------------------------
233 /// <summary>
234 ///
235 /// </summary>
236 // -----------------------------------------------------------------
224 public bool TestPath(UUID storeID, string path, bool useJson) 237 public bool TestPath(UUID storeID, string path, bool useJson)
225 { 238 {
226 if (! m_enabled) return false; 239 if (! m_enabled) return false;
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index b9dcfea..29955af 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -167,6 +167,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
167 { 167 {
168 m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); 168 m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
169 m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); 169 m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
170 m_comms.RegisterScriptInvocation(this, "JsonTestStore");
170 171
171 m_comms.RegisterScriptInvocation(this, "JsonReadNotecard"); 172 m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
172 m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard"); 173 m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
@@ -248,6 +249,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
248 /// 249 ///
249 /// </summary> 250 /// </summary>
250 // ----------------------------------------------------------------- 251 // -----------------------------------------------------------------
252 protected int JsonTestStore(UUID hostID, UUID scriptID, UUID storeID)
253 {
254 return m_store.TestStore(storeID) ? 1 : 0;
255 }
256
257 // -----------------------------------------------------------------
258 /// <summary>
259 ///
260 /// </summary>
261 // -----------------------------------------------------------------
251 protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) 262 protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID)
252 { 263 {
253 UUID reqID = UUID.Random(); 264 UUID reqID = UUID.Random();
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index 397dd93..8042a93 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
48 /// Tests for inventory functions in LSL 48 /// Tests for inventory functions in LSL
49 /// </summary> 49 /// </summary>
50 [TestFixture] 50 [TestFixture]
51 public class LSL_ApiInventoryTests : OpenSimTestCase 51 public class JsonStoreScriptModuleTests : OpenSimTestCase
52 { 52 {
53 private Scene m_scene; 53 private Scene m_scene;
54 private MockScriptEngine m_engine; 54 private MockScriptEngine m_engine;
@@ -59,8 +59,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
59 { 59 {
60 base.SetUp(); 60 base.SetUp();
61 61
62 TestHelpers.EnableLogging();
63
64 IConfigSource configSource = new IniConfigSource(); 62 IConfigSource configSource = new IniConfigSource();
65 IConfig jsonStoreConfig = configSource.AddConfig("JsonStore"); 63 IConfig jsonStoreConfig = configSource.AddConfig("JsonStore");
66 jsonStoreConfig.Set("Enabled", "true"); 64 jsonStoreConfig.Set("Enabled", "true");
@@ -72,74 +70,129 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
72 70
73 m_scene = new SceneHelpers().SetupScene(); 71 m_scene = new SceneHelpers().SetupScene();
74 SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm); 72 SceneHelpers.SetupSceneModules(m_scene, configSource, m_engine, m_smcm, jsm, jssm);
73
74 try
75 {
76 m_smcm.RegisterScriptInvocation(this, "DummyTestMethod");
77 }
78 catch (ArgumentException)
79 {
80 Assert.Ignore("Ignoring test since running on .NET 3.5 or earlier.");
81 }
82
83 // XXX: Unfortunately, ICommsModule currently has no way of deregistering methods.
75 } 84 }
76 85
77// [Test] 86 private object InvokeOp(string name, params object[] args)
87 {
88 return m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, name, args);
89 }
90
91 [Test]
78 public void TestJsonCreateStore() 92 public void TestJsonCreateStore()
79 { 93 {
80 TestHelpers.InMethod(); 94 TestHelpers.InMethod();
81// TestHelpers.EnableLogging(); 95// TestHelpers.EnableLogging();
82 96
83 UUID storeId = (UUID)m_smcm.InvokeOperation(UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{}" }); 97 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
84
85 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero)); 98 Assert.That(storeId, Is.Not.EqualTo(UUID.Zero));
86 } 99 }
87 100
88// [Test] 101 [Test]
89 public void TestJsonGetValue() 102 public void TestJsonDestroyStore()
90 { 103 {
91 TestHelpers.InMethod(); 104 TestHelpers.InMethod();
92// TestHelpers.EnableLogging(); 105// TestHelpers.EnableLogging();
93 106
94 UUID storeId 107 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
95 = (UUID)m_smcm.InvokeOperation( 108 int dsrv = (int)InvokeOp("JsonDestroyStore", storeId);
96 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); 109
110 Assert.That(dsrv, Is.EqualTo(1));
111
112 int tprv = (int)InvokeOp("JsonTestPath", storeId, "Hello");
113 Assert.That(tprv, Is.EqualTo(0));
114 }
115
116 [Test]
117 public void TestJsonGetValue()
118 {
119 TestHelpers.InMethod();
120// TestHelpers.EnableLogging();
97 121
98 string value 122 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
99 = (string)m_smcm.InvokeOperation(
100 UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
101 123
124 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello");
102 Assert.That(value, Is.EqualTo("World")); 125 Assert.That(value, Is.EqualTo("World"));
103 } 126 }
104 127
105// [Test] 128// [Test]
106 public void TestJsonTestPath() 129// public void TestJsonTakeValue()
130// {
131// TestHelpers.InMethod();
132//// TestHelpers.EnableLogging();
133//
134// UUID storeId
135// = (UUID)m_smcm.InvokeOperation(
136// UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
137//
138// string value
139// = (string)m_smcm.InvokeOperation(
140// UUID.Zero, UUID.Zero, "JsonTakeValue", new object[] { storeId, "Hello" });
141//
142// Assert.That(value, Is.EqualTo("World"));
143//
144// string value2
145// = (string)m_smcm.InvokeOperation(
146// UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
147//
148// Assert.That(value, Is.Null);
149// }
150
151 [Test]
152 public void TestJsonRemoveValue()
107 { 153 {
108 TestHelpers.InMethod(); 154 TestHelpers.InMethod();
109// TestHelpers.EnableLogging(); 155// TestHelpers.EnableLogging();
110 156
111 UUID storeId 157 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
112 = (UUID)m_smcm.InvokeOperation( 158
113 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); 159 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
160 Assert.That(returnValue, Is.EqualTo(1));
161
162 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
163 Assert.That(result, Is.EqualTo(0));
164
165 string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello");
166 Assert.That(returnValue2, Is.EqualTo(""));
167 }
168
169 [Test]
170 public void TestJsonTestPath()
171 {
172 TestHelpers.InMethod();
173// TestHelpers.EnableLogging();
114 174
115 int result 175 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
116 = (int)m_smcm.InvokeOperation(
117 UUID.Zero, UUID.Zero, "JsonTestPath", new object[] { storeId, "Hello" });
118 176
177 int result = (int)InvokeOp("JsonTestPath", storeId, "Hello");
119 Assert.That(result, Is.EqualTo(1)); 178 Assert.That(result, Is.EqualTo(1));
120 } 179 }
121 180
122// [Test] 181 [Test]
123 public void TestJsonSetValue() 182 public void TestJsonSetValue()
124 { 183 {
125 TestHelpers.InMethod(); 184 TestHelpers.InMethod();
126// TestHelpers.EnableLogging(); 185// TestHelpers.EnableLogging();
127 186
128 UUID storeId 187 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
129 = (UUID)m_smcm.InvokeOperation(
130 UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ }" });
131
132 int result
133 = (int)m_smcm.InvokeOperation(
134 UUID.Zero, UUID.Zero, "JsonSetValue", new object[] { storeId, "Hello", "World" });
135 188
189 int result = (int)InvokeOp("JsonSetValue", storeId, "Hello", "World");
136 Assert.That(result, Is.EqualTo(1)); 190 Assert.That(result, Is.EqualTo(1));
137 191
138 string value 192 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello");
139 = (string)m_smcm.InvokeOperation(
140 UUID.Zero, UUID.Zero, "JsonGetValue", new object[] { storeId, "Hello" });
141
142 Assert.That(value, Is.EqualTo("World")); 193 Assert.That(value, Is.EqualTo("World"));
143 } 194 }
195
196 public object DummyTestMethod(object o1, object o2, object o3, object o4, object o5) { return null; }
144 } 197 }
145} \ No newline at end of file 198} \ No newline at end of file