Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
commit
cd444c1e82
|
@ -204,8 +204,16 @@ namespace OpenSim.Data.Tests
|
||||||
UUID webloginkey = UUID.Random();
|
UUID webloginkey = UUID.Random();
|
||||||
uint homeregx = (uint) random.Next();
|
uint homeregx = (uint) random.Next();
|
||||||
uint homeregy = (uint) random.Next();
|
uint homeregy = (uint) random.Next();
|
||||||
Vector3 homeloc = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
Vector3 homeloc
|
||||||
Vector3 homelookat = new Vector3((float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5),(float)Math.Round(random.NextDouble(),5));
|
= new Vector3(
|
||||||
|
(float)Math.Round(random.NextDouble(), 5),
|
||||||
|
(float)Math.Round(random.NextDouble(), 5),
|
||||||
|
(float)Math.Round(random.NextDouble(), 5));
|
||||||
|
Vector3 homelookat
|
||||||
|
= new Vector3(
|
||||||
|
(float)Math.Round(random.NextDouble(), 5),
|
||||||
|
(float)Math.Round(random.NextDouble(), 5),
|
||||||
|
(float)Math.Round(random.NextDouble(), 5));
|
||||||
int created = random.Next();
|
int created = random.Next();
|
||||||
int lastlogin = random.Next();
|
int lastlogin = random.Next();
|
||||||
string userinvuri = RandomName();
|
string userinvuri = RandomName();
|
||||||
|
|
|
@ -0,0 +1,298 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NUnit.Framework.Constraints;
|
||||||
|
using NUnit.Framework.SyntaxHelpers;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.Tests
|
||||||
|
{
|
||||||
|
public static class Constraints
|
||||||
|
{
|
||||||
|
//This is here because C# has a gap in the language, you can't infer type from a constructor
|
||||||
|
public static PropertyCompareConstraint<T> PropertyCompareConstraint<T>(T expected)
|
||||||
|
{
|
||||||
|
return new PropertyCompareConstraint<T>(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PropertyCompareConstraint<T> : NUnit.Framework.Constraints.Constraint
|
||||||
|
{
|
||||||
|
private readonly object _expected;
|
||||||
|
//the reason everywhere uses propertyNames.Reverse().ToArray() is because the stack is backwards of the order we want to display the properties in.
|
||||||
|
private string failingPropertyName = string.Empty;
|
||||||
|
private object failingExpected;
|
||||||
|
private object failingActual;
|
||||||
|
|
||||||
|
public PropertyCompareConstraint(T expected)
|
||||||
|
{
|
||||||
|
_expected = expected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Matches(object actual)
|
||||||
|
{
|
||||||
|
return ObjectCompare(_expected, actual, new Stack<string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames)
|
||||||
|
{
|
||||||
|
if (actual.GetType() != expected.GetType())
|
||||||
|
{
|
||||||
|
propertyNames.Push("GetType()");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actual.GetType();
|
||||||
|
failingExpected = expected.GetType();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(actual.GetType() == typeof(Color))
|
||||||
|
{
|
||||||
|
Color actualColor = (Color) actual;
|
||||||
|
Color expectedColor = (Color) expected;
|
||||||
|
if (actualColor.R != expectedColor.R)
|
||||||
|
{
|
||||||
|
propertyNames.Push("R");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualColor.R;
|
||||||
|
failingExpected = expectedColor.R;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (actualColor.G != expectedColor.G)
|
||||||
|
{
|
||||||
|
propertyNames.Push("G");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualColor.G;
|
||||||
|
failingExpected = expectedColor.G;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (actualColor.B != expectedColor.B)
|
||||||
|
{
|
||||||
|
propertyNames.Push("B");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualColor.B;
|
||||||
|
failingExpected = expectedColor.B;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (actualColor.A != expectedColor.A)
|
||||||
|
{
|
||||||
|
propertyNames.Push("A");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualColor.A;
|
||||||
|
failingExpected = expectedColor.A;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Skip static properties. I had a nasty problem comparing colors because of all of the public static colors.
|
||||||
|
PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||||
|
foreach (var property in properties)
|
||||||
|
{
|
||||||
|
if (ignores.Contains(property.Name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
object actualValue = property.GetValue(actual, null);
|
||||||
|
object expectedValue = property.GetValue(expected, null);
|
||||||
|
|
||||||
|
//If they are both null, they are equal
|
||||||
|
if (actualValue == null && expectedValue == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//If only one is null, then they aren't
|
||||||
|
if (actualValue == null || expectedValue == null)
|
||||||
|
{
|
||||||
|
propertyNames.Push(property.Name);
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualValue;
|
||||||
|
failingExpected = expectedValue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IComparable comp = actualValue as IComparable;
|
||||||
|
if (comp != null)
|
||||||
|
{
|
||||||
|
if (comp.CompareTo(expectedValue) != 0)
|
||||||
|
{
|
||||||
|
propertyNames.Push(property.Name);
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
propertyNames.Pop();
|
||||||
|
failingActual = actualValue;
|
||||||
|
failingExpected = expectedValue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable arr = actualValue as IEnumerable;
|
||||||
|
if (arr != null)
|
||||||
|
{
|
||||||
|
List<object> actualList = arr.Cast<object>().ToList();
|
||||||
|
List<object> expectedList = ((IEnumerable)expectedValue).Cast<object>().ToList();
|
||||||
|
if (actualList.Count != expectedList.Count)
|
||||||
|
{
|
||||||
|
propertyNames.Push(property.Name);
|
||||||
|
propertyNames.Push("Count");
|
||||||
|
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||||
|
failingActual = actualList.Count;
|
||||||
|
failingExpected = expectedList.Count;
|
||||||
|
propertyNames.Pop();
|
||||||
|
propertyNames.Pop();
|
||||||
|
}
|
||||||
|
//Todo: A value-wise comparison of all of the values.
|
||||||
|
//Everything seems okay...
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyNames.Push(property.Name);
|
||||||
|
if (!ObjectCompare(expectedValue, actualValue, propertyNames))
|
||||||
|
return false;
|
||||||
|
propertyNames.Pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteDescriptionTo(MessageWriter writer)
|
||||||
|
{
|
||||||
|
writer.WriteExpectedValue(failingExpected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteActualValueTo(MessageWriter writer)
|
||||||
|
{
|
||||||
|
writer.WriteActualValue(failingActual);
|
||||||
|
writer.WriteLine();
|
||||||
|
writer.Write(" On Property: " + failingPropertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//These notes assume the lambda: (x=>x.Parent.Value)
|
||||||
|
//ignores should really contain like a fully dotted version of the property name, but I'm starting with small steps
|
||||||
|
readonly List<string> ignores = new List<string>();
|
||||||
|
public PropertyCompareConstraint<T> IgnoreProperty(Expression<Func<T, object>> func)
|
||||||
|
{
|
||||||
|
Expression express = func.Body;
|
||||||
|
PullApartExpression(express);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PullApartExpression(Expression express)
|
||||||
|
{
|
||||||
|
//This deals with any casts... like implicit casts to object. Not all UnaryExpression are casts, but this is a first attempt.
|
||||||
|
if (express is UnaryExpression)
|
||||||
|
PullApartExpression(((UnaryExpression)express).Operand);
|
||||||
|
if (express is MemberExpression)
|
||||||
|
{
|
||||||
|
//If the inside of the lambda is the access to x, we've hit the end of the chain.
|
||||||
|
// We should track by the fully scoped parameter name, but this is the first rev of doing this.
|
||||||
|
if (((MemberExpression)express).Expression is ParameterExpression)
|
||||||
|
{
|
||||||
|
ignores.Add(((MemberExpression)express).Member.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Otherwise there could be more parameters inside...
|
||||||
|
PullApartExpression(((MemberExpression)express).Expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class PropertyCompareConstraintTest
|
||||||
|
{
|
||||||
|
public class HasInt
|
||||||
|
{
|
||||||
|
public int TheValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IntShouldMatch()
|
||||||
|
{
|
||||||
|
HasInt actual = new HasInt { TheValue = 5 };
|
||||||
|
HasInt expected = new HasInt { TheValue = 5 };
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IntShouldNotMatch()
|
||||||
|
{
|
||||||
|
HasInt actual = new HasInt { TheValue = 5 };
|
||||||
|
HasInt expected = new HasInt { TheValue = 4 };
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IntShouldIgnore()
|
||||||
|
{
|
||||||
|
HasInt actual = new HasInt { TheValue = 5 };
|
||||||
|
HasInt expected = new HasInt { TheValue = 4 };
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x=>x.TheValue);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AssetShouldMatch()
|
||||||
|
{
|
||||||
|
UUID uuid1 = UUID.Random();
|
||||||
|
AssetBase actual = new AssetBase(uuid1, "asset one");
|
||||||
|
AssetBase expected = new AssetBase(uuid1, "asset one");
|
||||||
|
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AssetShouldNotMatch()
|
||||||
|
{
|
||||||
|
UUID uuid1 = UUID.Random();
|
||||||
|
AssetBase actual = new AssetBase(uuid1, "asset one");
|
||||||
|
AssetBase expected = new AssetBase(UUID.Random(), "asset one");
|
||||||
|
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AssetShouldNotMatch2()
|
||||||
|
{
|
||||||
|
UUID uuid1 = UUID.Random();
|
||||||
|
AssetBase actual = new AssetBase(uuid1, "asset one");
|
||||||
|
AssetBase expected = new AssetBase(uuid1, "asset two");
|
||||||
|
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestColors()
|
||||||
|
{
|
||||||
|
Color actual = Color.Red;
|
||||||
|
Color expected = Color.FromArgb(actual.A, actual.R, actual.G, actual.B);
|
||||||
|
|
||||||
|
var constraint = Constraints.PropertyCompareConstraint(expected);
|
||||||
|
|
||||||
|
Assert.That(constraint.Matches(actual), Is.True);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
namespace OpenSim.Data.Tests
|
||||||
|
{
|
||||||
|
public static class ScrambleForTesting
|
||||||
|
{
|
||||||
|
private static readonly Random random = new Random();
|
||||||
|
public static void Scramble(object obj)
|
||||||
|
{
|
||||||
|
PropertyInfo[] properties = obj.GetType().GetProperties();
|
||||||
|
foreach (var property in properties)
|
||||||
|
{
|
||||||
|
//Skip indexers of classes. We will assume that everything that has an indexer
|
||||||
|
// is also IEnumberable. May not always be true, but should be true normally.
|
||||||
|
if(property.GetIndexParameters().Length > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RandomizeProperty(obj, property, null);
|
||||||
|
}
|
||||||
|
//Now if it implments IEnumberable, it's probably some kind of list, so we should randomize
|
||||||
|
// everything inside of it.
|
||||||
|
IEnumerable enumerable = obj as IEnumerable;
|
||||||
|
if(enumerable != null)
|
||||||
|
{
|
||||||
|
foreach (object value in enumerable)
|
||||||
|
{
|
||||||
|
Scramble(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RandomizeProperty(object obj, PropertyInfo property, object[] index)
|
||||||
|
{
|
||||||
|
Type t = property.PropertyType;
|
||||||
|
if (!property.CanWrite)
|
||||||
|
return;
|
||||||
|
object value = property.GetValue(obj, index);
|
||||||
|
if (value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (t == typeof (string))
|
||||||
|
property.SetValue(obj, RandomName(), index);
|
||||||
|
else if (t == typeof (UUID))
|
||||||
|
property.SetValue(obj, UUID.Random(), index);
|
||||||
|
else if (t == typeof (sbyte))
|
||||||
|
property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index);
|
||||||
|
else if (t == typeof (short))
|
||||||
|
property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index);
|
||||||
|
else if (t == typeof (int))
|
||||||
|
property.SetValue(obj, random.Next(), index);
|
||||||
|
else if (t == typeof (long))
|
||||||
|
property.SetValue(obj, random.Next() * int.MaxValue, index);
|
||||||
|
else if (t == typeof (byte))
|
||||||
|
property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index);
|
||||||
|
else if (t == typeof (ushort))
|
||||||
|
property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index);
|
||||||
|
else if (t == typeof (uint))
|
||||||
|
property.SetValue(obj, Convert.ToUInt32(random.Next()), index);
|
||||||
|
else if (t == typeof (ulong))
|
||||||
|
property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index);
|
||||||
|
else if (t == typeof (bool))
|
||||||
|
property.SetValue(obj, true, index);
|
||||||
|
else if (t == typeof (byte[]))
|
||||||
|
{
|
||||||
|
byte[] bytes = new byte[30];
|
||||||
|
random.NextBytes(bytes);
|
||||||
|
property.SetValue(obj, bytes, index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Scramble(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string RandomName()
|
||||||
|
{
|
||||||
|
StringBuilder name = new StringBuilder();
|
||||||
|
int size = random.Next(5, 12);
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
char ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
|
||||||
|
name.Append(ch);
|
||||||
|
}
|
||||||
|
return name.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class ScrableForTestingTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestScramble()
|
||||||
|
{
|
||||||
|
AssetBase actual = new AssetBase(UUID.Random(), "asset one");
|
||||||
|
ScrambleForTesting.Scramble(actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* 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 NUnit.Framework;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ThreadTrackerTests
|
||||||
|
{
|
||||||
|
private bool running = true;
|
||||||
|
private bool running2 = true;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DefaultThreadTrackerTest()
|
||||||
|
{
|
||||||
|
List<Thread> lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
/*
|
||||||
|
foreach (Thread t in lThread)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(t.Name);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 1);
|
||||||
|
Assert.That(lThread[0].Name == "ThreadTrackerThread");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validate that adding a thread to the thread tracker works
|
||||||
|
/// Validate that removing a thread from the thread tracker also works.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void AddThreadToThreadTrackerTestAndRemoveTest()
|
||||||
|
{
|
||||||
|
Thread t = new Thread(run);
|
||||||
|
t.Name = "TestThread";
|
||||||
|
t.Priority = ThreadPriority.BelowNormal;
|
||||||
|
t.IsBackground = true;
|
||||||
|
t.SetApartmentState(ApartmentState.MTA);
|
||||||
|
t.Start();
|
||||||
|
ThreadTracker.Add(t);
|
||||||
|
|
||||||
|
List<Thread> lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 2);
|
||||||
|
|
||||||
|
foreach (Thread tr in lThread)
|
||||||
|
{
|
||||||
|
Assert.That((tr.Name == "ThreadTrackerThread" || tr.Name == "TestThread"));
|
||||||
|
}
|
||||||
|
running = false;
|
||||||
|
ThreadTracker.Remove(t);
|
||||||
|
|
||||||
|
lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 1);
|
||||||
|
|
||||||
|
foreach (Thread tr in lThread)
|
||||||
|
{
|
||||||
|
Assert.That((tr.Name == "ThreadTrackerThread"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test a dead thread removal by aborting it and setting it's last seen active date to 50 seconds
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void DeadThreadTest()
|
||||||
|
{
|
||||||
|
Thread t = new Thread(run2);
|
||||||
|
t.Name = "TestThread";
|
||||||
|
t.Priority = ThreadPriority.BelowNormal;
|
||||||
|
t.IsBackground = true;
|
||||||
|
t.SetApartmentState(ApartmentState.MTA);
|
||||||
|
t.Start();
|
||||||
|
ThreadTracker.Add(t);
|
||||||
|
t.Abort();
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
ThreadTracker.m_Threads[1].LastSeenActive = DateTime.Now.Ticks - (50*10000000);
|
||||||
|
ThreadTracker.CleanUp();
|
||||||
|
List<Thread> lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 1);
|
||||||
|
|
||||||
|
foreach (Thread tr in lThread)
|
||||||
|
{
|
||||||
|
Assert.That((tr.Name == "ThreadTrackerThread"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void UnstartedThreadTest()
|
||||||
|
{
|
||||||
|
Thread t = new Thread(run2);
|
||||||
|
t.Name = "TestThread";
|
||||||
|
t.Priority = ThreadPriority.BelowNormal;
|
||||||
|
t.IsBackground = true;
|
||||||
|
t.SetApartmentState(ApartmentState.MTA);
|
||||||
|
ThreadTracker.Add(t);
|
||||||
|
ThreadTracker.m_Threads[1].LastSeenActive = DateTime.Now.Ticks - (50 * 10000000);
|
||||||
|
ThreadTracker.CleanUp();
|
||||||
|
List<Thread> lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 1);
|
||||||
|
|
||||||
|
foreach (Thread tr in lThread)
|
||||||
|
{
|
||||||
|
Assert.That((tr.Name == "ThreadTrackerThread"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NullThreadTest()
|
||||||
|
{
|
||||||
|
Thread t = null;
|
||||||
|
ThreadTracker.Add(t);
|
||||||
|
|
||||||
|
List<Thread> lThread = ThreadTracker.GetThreads();
|
||||||
|
|
||||||
|
Assert.That(lThread.Count == 1);
|
||||||
|
|
||||||
|
foreach (Thread tr in lThread)
|
||||||
|
{
|
||||||
|
Assert.That((tr.Name == "ThreadTrackerThread"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Worker thread 0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
|
public void run( object o)
|
||||||
|
{
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Worker thread 1
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
|
public void run2(object o)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (running2)
|
||||||
|
{
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (ThreadAbortException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,12 +77,15 @@ namespace OpenSim.Framework
|
||||||
public static void Add(Thread thread)
|
public static void Add(Thread thread)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
lock (m_Threads)
|
if (thread != null)
|
||||||
{
|
{
|
||||||
ThreadTrackerItem tti = new ThreadTrackerItem();
|
lock (m_Threads)
|
||||||
tti.Thread = thread;
|
{
|
||||||
tti.LastSeenActive = DateTime.Now.Ticks;
|
ThreadTrackerItem tti = new ThreadTrackerItem();
|
||||||
m_Threads.Add(tti);
|
tti.Thread = thread;
|
||||||
|
tti.LastSeenActive = DateTime.Now.Ticks;
|
||||||
|
m_Threads.Add(tti);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -107,16 +110,25 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
|
foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
|
||||||
{
|
{
|
||||||
if (tti.Thread.IsAlive)
|
try
|
||||||
{
|
{
|
||||||
// Its active
|
|
||||||
tti.LastSeenActive = DateTime.Now.Ticks;
|
|
||||||
|
if (tti.Thread.IsAlive)
|
||||||
|
{
|
||||||
|
// Its active
|
||||||
|
tti.LastSeenActive = DateTime.Now.Ticks;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Its not active -- if its expired then remove it
|
||||||
|
if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
|
||||||
|
m_Threads.Remove(tti);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (NullReferenceException)
|
||||||
{
|
{
|
||||||
// Its not active -- if its expired then remove it
|
m_Threads.Remove(tti);
|
||||||
if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
|
|
||||||
m_Threads.Remove(tti);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
|
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//[Test]
|
[Test]
|
||||||
public void TestSaveIarV0_1()
|
public void TestSaveIarV0_1()
|
||||||
{
|
{
|
||||||
TestHelper.InMethod();
|
TestHelper.InMethod();
|
||||||
|
@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
||||||
|
|
||||||
Scene scene = SceneSetupHelpers.SetupScene("");
|
Scene scene = SceneSetupHelpers.SetupScene("Inventory");
|
||||||
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
||||||
CommunicationsManager cm = scene.CommsManager;
|
CommunicationsManager cm = scene.CommsManager;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||||
/// an account exists with the creator name.
|
/// an account exists with the creator name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//[Test]
|
[Test]
|
||||||
public void TestLoadIarV0_1ExistingUsers()
|
public void TestLoadIarV0_1ExistingUsers()
|
||||||
{
|
{
|
||||||
TestHelper.InMethod();
|
TestHelper.InMethod();
|
||||||
|
@ -262,7 +262,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
||||||
|
|
||||||
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
|
// Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
|
||||||
Scene scene = SceneSetupHelpers.SetupScene();
|
Scene scene = SceneSetupHelpers.SetupScene("inventory");
|
||||||
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
|
IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
|
||||||
|
|
||||||
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
|
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
|
||||||
|
@ -276,16 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
CachedUserInfo userInfo
|
CachedUserInfo userInfo
|
||||||
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
|
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
|
||||||
//userInfo.FetchInventory();
|
|
||||||
/*
|
|
||||||
for (int i = 0 ; i < 50 ; i++)
|
|
||||||
{
|
|
||||||
if (userInfo.HasReceivedInventory == true)
|
|
||||||
break;
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
|
|
||||||
*/
|
|
||||||
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
|
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
|
||||||
Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
|
Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
|
||||||
Assert.That(
|
Assert.That(
|
||||||
|
@ -395,17 +386,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
|
userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
|
||||||
Monitor.Wait(this, 60000);
|
Monitor.Wait(this, 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//userInfo.FetchInventory();
|
|
||||||
/*
|
|
||||||
for (int i = 0 ; i < 50 ; i++)
|
|
||||||
{
|
|
||||||
if (userInfo.HasReceivedInventory == true)
|
|
||||||
break;
|
|
||||||
Thread.Sleep(200);
|
|
||||||
}
|
|
||||||
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
|
|
||||||
*/
|
|
||||||
|
|
||||||
Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
|
Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder);
|
||||||
|
|
||||||
|
@ -429,22 +409,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
|
|
||||||
Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
|
Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
|
||||||
|
|
||||||
try
|
new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
|
||||||
{
|
.ReplicateArchivePathToUserInventory(
|
||||||
new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
|
itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
|
||||||
.ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
|
|
||||||
|
|
||||||
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
|
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
|
||||||
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
|
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
|
||||||
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
|
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
|
||||||
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
|
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
|
||||||
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
|
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
|
||||||
}
|
|
||||||
catch (NullReferenceException e)
|
|
||||||
{
|
|
||||||
// Non fatal for now until we resolve the race condition
|
|
||||||
Console.WriteLine("Test failed with {0}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
agent.InventoryFolder = UUID.Zero;
|
agent.InventoryFolder = UUID.Zero;
|
||||||
agent.startpos = Vector3.Zero;
|
agent.startpos = Vector3.Zero;
|
||||||
agent.CapsPath = GetRandomCapsObjectPath();
|
agent.CapsPath = GetRandomCapsObjectPath();
|
||||||
|
agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
|
||||||
|
|
||||||
string reason;
|
string reason;
|
||||||
scene.NewUserConnection(agent, out reason);
|
scene.NewUserConnection(agent, out reason);
|
||||||
|
@ -147,7 +148,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelper.InMethod();
|
TestHelper.InMethod();
|
||||||
|
|
||||||
string reason;
|
string reason;
|
||||||
|
|
||||||
|
if (acd1 == null)
|
||||||
|
fixNullPresence();
|
||||||
|
|
||||||
scene.NewUserConnection(acd1, out reason);
|
scene.NewUserConnection(acd1, out reason);
|
||||||
|
if (testclient == null)
|
||||||
|
testclient = new TestClient(acd1, scene);
|
||||||
scene.AddNewClient(testclient);
|
scene.AddNewClient(testclient);
|
||||||
|
|
||||||
ScenePresence presence = scene.GetScenePresence(agent1);
|
ScenePresence presence = scene.GetScenePresence(agent1);
|
||||||
|
@ -162,6 +169,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
|
||||||
Assert.That(neighbours.Count, Is.EqualTo(2));
|
Assert.That(neighbours.Count, Is.EqualTo(2));
|
||||||
}
|
}
|
||||||
|
public void fixNullPresence()
|
||||||
|
{
|
||||||
|
string firstName = "testfirstname";
|
||||||
|
|
||||||
|
AgentCircuitData agent = new AgentCircuitData();
|
||||||
|
agent.AgentID = agent1;
|
||||||
|
agent.firstname = firstName;
|
||||||
|
agent.lastname = "testlastname";
|
||||||
|
agent.SessionID = UUID.Zero;
|
||||||
|
agent.SecureSessionID = UUID.Zero;
|
||||||
|
agent.circuitcode = 123;
|
||||||
|
agent.BaseFolder = UUID.Zero;
|
||||||
|
agent.InventoryFolder = UUID.Zero;
|
||||||
|
agent.startpos = Vector3.Zero;
|
||||||
|
agent.CapsPath = GetRandomCapsObjectPath();
|
||||||
|
|
||||||
|
acd1 = agent;
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void T013_TestRemoveNeighbourRegion()
|
public void T013_TestRemoveNeighbourRegion()
|
||||||
|
|
|
@ -125,9 +125,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
if (lease.CurrentState == LeaseState.Initial)
|
if (lease.CurrentState == LeaseState.Initial)
|
||||||
{
|
{
|
||||||
lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0);
|
lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
|
||||||
lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
||||||
lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
||||||
}
|
}
|
||||||
return lease;
|
return lease;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,9 +166,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
if (lease.CurrentState == LeaseState.Initial)
|
if (lease.CurrentState == LeaseState.Initial)
|
||||||
{
|
{
|
||||||
lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0);
|
lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
|
||||||
lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
||||||
lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
||||||
}
|
}
|
||||||
return lease;
|
return lease;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,16 +42,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
public partial class ScriptBaseClass : MarshalByRefObject, IScript
|
public partial class ScriptBaseClass : MarshalByRefObject, IScript
|
||||||
{
|
{
|
||||||
private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>();
|
private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>();
|
||||||
private ScriptSponsor m_sponser;
|
// private ScriptSponsor m_sponser;
|
||||||
|
|
||||||
public override Object InitializeLifetimeService()
|
public override Object InitializeLifetimeService()
|
||||||
{
|
{
|
||||||
ILease lease = (ILease)base.InitializeLifetimeService();
|
ILease lease = (ILease)base.InitializeLifetimeService();
|
||||||
if (lease.CurrentState == LeaseState.Initial)
|
if (lease.CurrentState == LeaseState.Initial)
|
||||||
{
|
{
|
||||||
lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0);
|
// Infinite
|
||||||
lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
|
||||||
lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
|
||||||
|
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
|
||||||
}
|
}
|
||||||
return lease;
|
return lease;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sponser = new ScriptSponsor();
|
// m_sponser = new ScriptSponsor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Executor m_Executor = null;
|
private Executor m_Executor = null;
|
||||||
|
@ -112,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject);
|
ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject);
|
||||||
lease.Register(m_sponser);
|
// lease.Register(m_sponser);
|
||||||
|
|
||||||
MethodInfo mi = inits[api];
|
MethodInfo mi = inits[api];
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
m_sponser.Close();
|
// m_sponser.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, object> GetVars()
|
public Dictionary<string, object> GetVars()
|
||||||
|
|
|
@ -53,7 +53,7 @@ using OpenSim.Region.ScriptEngine.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
{
|
{
|
||||||
public class ScriptInstance : MarshalByRefObject, IScriptInstance, ISponsor
|
public class ScriptInstance : MarshalByRefObject, IScriptInstance
|
||||||
{
|
{
|
||||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
"SecondLife.Script");
|
"SecondLife.Script");
|
||||||
|
|
||||||
ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
|
ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
|
||||||
lease.Register(this);
|
// lease.Register(this);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -1006,10 +1006,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan Renewal(ILease lease)
|
|
||||||
{
|
|
||||||
return lease.InitialLeaseTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,25 +34,53 @@ namespace OpenSim.Services.Interfaces
|
||||||
|
|
||||||
public interface IAssetService
|
public interface IAssetService
|
||||||
{
|
{
|
||||||
// Three different ways to retrieve an asset
|
/// <summary>
|
||||||
//
|
/// Get an asset synchronously.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
AssetBase Get(string id);
|
AssetBase Get(string id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get an asset's metadata
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
AssetMetadata GetMetadata(string id);
|
AssetMetadata GetMetadata(string id);
|
||||||
|
|
||||||
byte[] GetData(string id);
|
byte[] GetData(string id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get an asset asynchronously
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The asset id</param>
|
||||||
|
/// <param name="sender">Represents the requester. Passed back via the handler</param>
|
||||||
|
/// <param name="handler">The handler to call back once the asset has been retrieved</param>
|
||||||
|
/// <returns>True if the id was parseable, false otherwise</returns>
|
||||||
bool Get(string id, Object sender, AssetRetrieved handler);
|
bool Get(string id, Object sender, AssetRetrieved handler);
|
||||||
|
|
||||||
// Creates a new asset
|
/// <summary>
|
||||||
// Returns a random ID if none is passed into it
|
/// Creates a new asset
|
||||||
//
|
/// </summary>
|
||||||
|
/// Returns a random ID if none is passed into it
|
||||||
|
/// <param name="asset"></param>
|
||||||
|
/// <returns></returns>
|
||||||
string Store(AssetBase asset);
|
string Store(AssetBase asset);
|
||||||
|
|
||||||
// Attachments and bare scripts need this!!
|
/// <summary>
|
||||||
//
|
/// Update an asset's content
|
||||||
|
/// </summary>
|
||||||
|
/// Attachments and bare scripts need this!!
|
||||||
|
/// <param name="id"> </param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
bool UpdateContent(string id, byte[] data);
|
bool UpdateContent(string id, byte[] data);
|
||||||
|
|
||||||
// Kill an asset
|
/// <summary>
|
||||||
//
|
/// Delete an asset
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
bool Delete(string id);
|
bool Delete(string id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,13 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
public AssetBase Get(string id)
|
public AssetBase Get(string id)
|
||||||
{
|
{
|
||||||
return Assets[ id ];
|
AssetBase asset;
|
||||||
|
if (Assets.ContainsKey(id))
|
||||||
|
asset = Assets[id];
|
||||||
|
else
|
||||||
|
asset = null;
|
||||||
|
|
||||||
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetMetadata GetMetadata(string id)
|
public AssetMetadata GetMetadata(string id)
|
||||||
|
@ -59,8 +65,10 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Get(string id, object sender, AssetRetrieved handler)
|
public bool Get(string id, object sender, AssetRetrieved handler)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
handler(id, sender, Get(id));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Store(AssetBase asset)
|
public string Store(AssetBase asset)
|
||||||
|
|
|
@ -25,7 +25,7 @@ See configuring OpenSim
|
||||||
== Installation on Linux ==
|
== Installation on Linux ==
|
||||||
|
|
||||||
Prereqs:
|
Prereqs:
|
||||||
* Mono >= 2.4 (>= 2.4.2 is better)
|
* Mono >= 2.0.1 (>= 2.4.2 is better)
|
||||||
* Nant >= 0.86beta
|
* Nant >= 0.86beta
|
||||||
* sqlite3 or mysql 5.x (you'll need a back end database)
|
* sqlite3 or mysql 5.x (you'll need a back end database)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue