aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs43
1 files changed, 31 insertions, 12 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs
index a5165d9..984f6d3 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs
@@ -140,7 +140,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
140 { 140 {
141 if (!rdata.IsAuthenticated) 141 if (!rdata.IsAuthenticated)
142 { 142 {
143 rdata.Fail(Rest.HttpStatusCodeNotAuthorized, Rest.HttpStatusDescNotAuthorized); 143 rdata.Fail(Rest.HttpStatusCodeNotAuthorized,
144 String.Format("user \"{0}\" could not be authenticated", rdata.userName));
144 } 145 }
145 } 146 }
146 catch (RestException e) 147 catch (RestException e)
@@ -160,10 +161,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
160 161
161 // Check that a test was specified 162 // Check that a test was specified
162 163
163 if (rdata.parameters.Length < 1) 164 if (rdata.Parameters.Length < 1)
164 { 165 {
165 Rest.Log.DebugFormat("{0} Insufficient parameters", MsgId); 166 Rest.Log.DebugFormat("{0} Insufficient parameters", MsgId);
166 rdata.Fail(Rest.HttpStatusCodeBadRequest, Rest.HttpStatusDescBadRequest); 167 rdata.Fail(Rest.HttpStatusCodeBadRequest, "not enough parameters");
167 } 168 }
168 169
169 // Select the test 170 // Select the test
@@ -180,8 +181,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
180 private static bool testsLoaded = false; 181 private static bool testsLoaded = false;
181 private static List<Type> classes = new List<Type>(); 182 private static List<Type> classes = new List<Type>();
182 private static List<ITest> tests = new List<ITest>(); 183 private static List<ITest> tests = new List<ITest>();
183 private static Type[] parms = new Type[1]; 184 private static Type[] parms = new Type[0];
184 private static Object[] args = new Object[1]; 185 private static Object[] args = new Object[0];
185 186
186 static RestTestServices() 187 static RestTestServices()
187 { 188 {
@@ -191,9 +192,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
191 Type[] types = m.GetTypes(); 192 Type[] types = m.GetTypes();
192 foreach (Type t in types) 193 foreach (Type t in types)
193 { 194 {
194 if (t.GetInterface("ITest") != null) 195 try
195 { 196 {
196 classes.Add(t); 197 if (t.GetInterface("ITest") != null)
198 {
199 classes.Add(t);
200 }
201 }
202 catch (Exception e)
203 {
204 Rest.Log.WarnFormat("[STATIC-TEST] Unable to include test {0} : {1}", t, e.Message);
197 } 205 }
198 } 206 }
199 } 207 }
@@ -205,27 +213,38 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
205 /// registering itself with this handler. 213 /// registering itself with this handler.
206 /// I was not able to make this code work in a constructor. 214 /// I was not able to make this code work in a constructor.
207 /// </summary> 215 /// </summary>
216
208 private void loadTests() 217 private void loadTests()
209 { 218 {
210 lock (tests) 219 lock (tests)
211 { 220 {
212 if (!testsLoaded) 221 if (!testsLoaded)
213 { 222 {
214 parms[0] = this.GetType();
215 args[0] = this;
216 223
217 ConstructorInfo ci; 224 ConstructorInfo ci;
218 Object ht; 225 Object ht;
219 226
220 foreach (Type t in classes) 227 foreach (Type t in classes)
221 { 228 {
222 ci = t.GetConstructor(parms); 229 try
223 ht = ci.Invoke(args); 230 {
224 tests.Add((ITest)ht); 231 if (t.GetInterface("ITest") != null)
232 {
233 ci = t.GetConstructor(parms);
234 ht = ci.Invoke(args);
235 tests.Add((ITest)ht);
236 Rest.Log.WarnFormat("{0} Test {1} added", MsgId, t);
237 }
238 }
239 catch (Exception e)
240 {
241 Rest.Log.WarnFormat("{0} Unable to load test {1} : {2}", MsgId, t, e.Message);
242 }
225 } 243 }
226 testsLoaded = true; 244 testsLoaded = true;
227 } 245 }
228 } 246 }
229 } 247 }
248
230 } 249 }
231} 250}