* Fixed MySQL/MySQLAssetData.cs to properly do updates * Removed an extra parameter from MySQL/MySQLInventoryData.cs * Fixed a bug in SQLite/SQLiteAssetData.cs that was causing a NRE when updating an asset. * Improved the BasicAssetTest.cs to do full create/update/get testing * Improved the BasicInventoryTest.cs to do full create/update/get of both a folder and an item * Moved the null ref tests to the start of the PropertyCompareConstraint.cs, so that it doesn't throw when passing in a null item
parent
f6251ce810
commit
d2e5380cb2
|
@ -196,18 +196,11 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
lock (_dbConnection)
|
||||
{
|
||||
//m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
|
||||
if (ExistsAsset(asset.FullID))
|
||||
{
|
||||
//m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
_dbConnection.CheckConnection();
|
||||
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand(
|
||||
"insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
|
||||
"replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
|
||||
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
|
||||
_dbConnection.Connection);
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ namespace OpenSim.Data.MySQL
|
|||
cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
|
||||
cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
|
||||
cmd.Parameters.AddWithValue("?folderName", folderName);
|
||||
cmd.Parameters.AddWithValue("?type", (short) folder.Type);
|
||||
cmd.Parameters.AddWithValue("?type", folder.Type);
|
||||
cmd.Parameters.AddWithValue("?version", folder.Version);
|
||||
|
||||
try
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace OpenSim.Data.SQLite
|
|||
int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
|
||||
|
||||
m_log.Info("[ASSET DB]: " +
|
||||
string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)",
|
||||
string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
|
||||
asset.FullID, asset.Name, asset.Description, asset.Type,
|
||||
temporary, local, assetLength));
|
||||
}
|
||||
|
|
|
@ -94,13 +94,38 @@ namespace OpenSim.Data.Tests
|
|||
db.CreateAsset(a3);
|
||||
|
||||
AssetBase a1a = db.FetchAsset(uuid1);
|
||||
Assert.That(a1, Constraints.PropertyCompareConstraint(a1a));
|
||||
Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
|
||||
|
||||
AssetBase a2a = db.FetchAsset(uuid2);
|
||||
Assert.That(a2, Constraints.PropertyCompareConstraint(a2a));
|
||||
Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
|
||||
|
||||
AssetBase a3a = db.FetchAsset(uuid3);
|
||||
Assert.That(a3, Constraints.PropertyCompareConstraint(a3a));
|
||||
Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
|
||||
|
||||
ScrambleForTesting.Scramble(a1a);
|
||||
ScrambleForTesting.Scramble(a2a);
|
||||
ScrambleForTesting.Scramble(a3a);
|
||||
|
||||
a1a.Data = asset1;
|
||||
a2a.Data = asset1;
|
||||
a3a.Data = asset1;
|
||||
|
||||
a1a.FullID = uuid1;
|
||||
a2a.FullID = uuid2;
|
||||
a3a.FullID = uuid3;
|
||||
|
||||
db.UpdateAsset(a1a);
|
||||
db.UpdateAsset(a2a);
|
||||
db.UpdateAsset(a3a);
|
||||
|
||||
AssetBase a1b = db.FetchAsset(uuid1);
|
||||
Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
|
||||
|
||||
AssetBase a2b = db.FetchAsset(uuid2);
|
||||
Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
|
||||
|
||||
AssetBase a3b = db.FetchAsset(uuid3);
|
||||
Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -258,17 +258,59 @@ namespace OpenSim.Data.Tests
|
|||
[Test]
|
||||
public void T104_RandomUpdateItem()
|
||||
{
|
||||
InventoryItemBase expected = db.getInventoryItem(item1);
|
||||
UUID owner = UUID.Random();
|
||||
UUID folder = UUID.Random();
|
||||
UUID rootId = UUID.Random();
|
||||
UUID rootAsset = UUID.Random();
|
||||
InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
|
||||
ScrambleForTesting.Scramble(f1);
|
||||
f1.Owner = owner;
|
||||
f1.ParentID = zero;
|
||||
f1.ID = folder;
|
||||
|
||||
// succeed with true
|
||||
db.addInventoryFolder(f1);
|
||||
InventoryFolderBase f1a = db.getUserRootFolder(owner);
|
||||
Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
|
||||
|
||||
ScrambleForTesting.Scramble(f1a);
|
||||
f1a.Owner = owner;
|
||||
f1a.ParentID = zero;
|
||||
f1a.ID = folder;
|
||||
db.updateInventoryFolder(f1a);
|
||||
|
||||
InventoryFolderBase f1b = db.getUserRootFolder(owner);
|
||||
Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
|
||||
|
||||
//Now we have a valid folder to insert into, we can insert the item.
|
||||
InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
|
||||
ScrambleForTesting.Scramble(root);
|
||||
root.ID = rootId;
|
||||
root.AssetID = rootAsset;
|
||||
root.Owner = owner;
|
||||
root.Folder = folder;
|
||||
db.addInventoryItem(root);
|
||||
|
||||
InventoryItemBase expected = db.getInventoryItem(rootId);
|
||||
Assert.That(expected, Constraints.PropertyCompareConstraint(root)
|
||||
.IgnoreProperty(x => x.InvType)
|
||||
.IgnoreProperty(x => x.CreatorIdAsUuid)
|
||||
.IgnoreProperty(x => x.Description)
|
||||
.IgnoreProperty(x => x.CreatorId));
|
||||
|
||||
ScrambleForTesting.Scramble(expected);
|
||||
expected.ID = item1;
|
||||
expected.ID = rootId;
|
||||
expected.AssetID = rootAsset;
|
||||
expected.Owner = owner;
|
||||
expected.Folder = folder;
|
||||
db.updateInventoryItem(expected);
|
||||
|
||||
InventoryItemBase actual = db.getInventoryItem(item1);
|
||||
InventoryItemBase actual = db.getInventoryItem(rootId);
|
||||
Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
|
||||
.IgnoreProperty(x=>x.InvType)
|
||||
.IgnoreProperty(x=>x.CreatorIdAsUuid)
|
||||
.IgnoreProperty(x=>x.Description)
|
||||
.IgnoreProperty(x=>x.CreatorId));
|
||||
.IgnoreProperty(x => x.InvType)
|
||||
.IgnoreProperty(x => x.CreatorIdAsUuid)
|
||||
.IgnoreProperty(x => x.Description)
|
||||
.IgnoreProperty(x => x.CreatorId));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -69,6 +69,19 @@ namespace OpenSim.Data.Tests
|
|||
|
||||
private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames)
|
||||
{
|
||||
//If they are both null, they are equal
|
||||
if (actual == null && expected == null)
|
||||
return true;
|
||||
|
||||
//If only one is null, then they aren't
|
||||
if (actual == null || expected == null)
|
||||
{
|
||||
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
|
||||
failingActual = actual;
|
||||
failingExpected = expected;
|
||||
return false;
|
||||
}
|
||||
|
||||
//prevent loops...
|
||||
if(propertyNames.Count > 50)
|
||||
{
|
||||
|
@ -195,21 +208,6 @@ namespace OpenSim.Data.Tests
|
|||
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;
|
||||
}
|
||||
|
||||
propertyNames.Push(property.Name);
|
||||
if (!ObjectCompare(expectedValue, actualValue, propertyNames))
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue