aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs9
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs2
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs35
-rw-r--r--OpenSim/Data/Tests/BasicInventoryTest.cs56
-rw-r--r--OpenSim/Data/Tests/PropertyCompareConstraint.cs28
6 files changed, 95 insertions, 37 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d87649..0865083 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -196,18 +196,11 @@ namespace OpenSim.Data.MySQL
196 { 196 {
197 lock (_dbConnection) 197 lock (_dbConnection)
198 { 198 {
199 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
200 if (ExistsAsset(asset.FullID))
201 {
202 //m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
203 return;
204 }
205
206 _dbConnection.CheckConnection(); 199 _dbConnection.CheckConnection();
207 200
208 MySqlCommand cmd = 201 MySqlCommand cmd =
209 new MySqlCommand( 202 new MySqlCommand(
210 "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + 203 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
211 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", 204 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
212 _dbConnection.Connection); 205 _dbConnection.Connection);
213 206
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 121ef7a..849c246 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -604,7 +604,7 @@ namespace OpenSim.Data.MySQL
604 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); 604 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
605 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 605 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
606 cmd.Parameters.AddWithValue("?folderName", folderName); 606 cmd.Parameters.AddWithValue("?folderName", folderName);
607 cmd.Parameters.AddWithValue("?type", (short) folder.Type); 607 cmd.Parameters.AddWithValue("?type", folder.Type);
608 cmd.Parameters.AddWithValue("?version", folder.Version); 608 cmd.Parameters.AddWithValue("?version", folder.Version);
609 609
610 try 610 try
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index b09c1c9..72af7a0 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Data.SQLite
183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0; 183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
184 184
185 m_log.Info("[ASSET DB]: " + 185 m_log.Info("[ASSET DB]: " +
186 string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)", 186 string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
187 asset.FullID, asset.Name, asset.Description, asset.Type, 187 asset.FullID, asset.Name, asset.Description, asset.Type,
188 temporary, local, assetLength)); 188 temporary, local, assetLength));
189 } 189 }
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index eddb999..91b613a 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Data.Tests
84 a1.Data = asset1; 84 a1.Data = asset1;
85 a2.Data = asset1; 85 a2.Data = asset1;
86 a3.Data = asset1; 86 a3.Data = asset1;
87 87
88 a1.FullID = uuid1; 88 a1.FullID = uuid1;
89 a2.FullID = uuid2; 89 a2.FullID = uuid2;
90 a3.FullID = uuid3; 90 a3.FullID = uuid3;
@@ -92,15 +92,40 @@ namespace OpenSim.Data.Tests
92 db.CreateAsset(a1); 92 db.CreateAsset(a1);
93 db.CreateAsset(a2); 93 db.CreateAsset(a2);
94 db.CreateAsset(a3); 94 db.CreateAsset(a3);
95 95
96 AssetBase a1a = db.FetchAsset(uuid1); 96 AssetBase a1a = db.FetchAsset(uuid1);
97 Assert.That(a1, Constraints.PropertyCompareConstraint(a1a)); 97 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
98 98
99 AssetBase a2a = db.FetchAsset(uuid2); 99 AssetBase a2a = db.FetchAsset(uuid2);
100 Assert.That(a2, Constraints.PropertyCompareConstraint(a2a)); 100 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
101 101
102 AssetBase a3a = db.FetchAsset(uuid3); 102 AssetBase a3a = db.FetchAsset(uuid3);
103 Assert.That(a3, Constraints.PropertyCompareConstraint(a3a)); 103 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
104
105 ScrambleForTesting.Scramble(a1a);
106 ScrambleForTesting.Scramble(a2a);
107 ScrambleForTesting.Scramble(a3a);
108
109 a1a.Data = asset1;
110 a2a.Data = asset1;
111 a3a.Data = asset1;
112
113 a1a.FullID = uuid1;
114 a2a.FullID = uuid2;
115 a3a.FullID = uuid3;
116
117 db.UpdateAsset(a1a);
118 db.UpdateAsset(a2a);
119 db.UpdateAsset(a3a);
120
121 AssetBase a1b = db.FetchAsset(uuid1);
122 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
123
124 AssetBase a2b = db.FetchAsset(uuid2);
125 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
126
127 AssetBase a3b = db.FetchAsset(uuid3);
128 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
104 } 129 }
105 130
106 [Test] 131 [Test]
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
index 967c6e7..21552c8 100644
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ b/OpenSim/Data/Tests/BasicInventoryTest.cs
@@ -258,17 +258,59 @@ namespace OpenSim.Data.Tests
258 [Test] 258 [Test]
259 public void T104_RandomUpdateItem() 259 public void T104_RandomUpdateItem()
260 { 260 {
261 InventoryItemBase expected = db.getInventoryItem(item1); 261 UUID owner = UUID.Random();
262 UUID folder = UUID.Random();
263 UUID rootId = UUID.Random();
264 UUID rootAsset = UUID.Random();
265 InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
266 ScrambleForTesting.Scramble(f1);
267 f1.Owner = owner;
268 f1.ParentID = zero;
269 f1.ID = folder;
270
271 // succeed with true
272 db.addInventoryFolder(f1);
273 InventoryFolderBase f1a = db.getUserRootFolder(owner);
274 Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
275
276 ScrambleForTesting.Scramble(f1a);
277 f1a.Owner = owner;
278 f1a.ParentID = zero;
279 f1a.ID = folder;
280 db.updateInventoryFolder(f1a);
281
282 InventoryFolderBase f1b = db.getUserRootFolder(owner);
283 Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
284
285 //Now we have a valid folder to insert into, we can insert the item.
286 InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
287 ScrambleForTesting.Scramble(root);
288 root.ID = rootId;
289 root.AssetID = rootAsset;
290 root.Owner = owner;
291 root.Folder = folder;
292 db.addInventoryItem(root);
293
294 InventoryItemBase expected = db.getInventoryItem(rootId);
295 Assert.That(expected, Constraints.PropertyCompareConstraint(root)
296 .IgnoreProperty(x => x.InvType)
297 .IgnoreProperty(x => x.CreatorIdAsUuid)
298 .IgnoreProperty(x => x.Description)
299 .IgnoreProperty(x => x.CreatorId));
300
262 ScrambleForTesting.Scramble(expected); 301 ScrambleForTesting.Scramble(expected);
263 expected.ID = item1; 302 expected.ID = rootId;
303 expected.AssetID = rootAsset;
304 expected.Owner = owner;
305 expected.Folder = folder;
264 db.updateInventoryItem(expected); 306 db.updateInventoryItem(expected);
265 307
266 InventoryItemBase actual = db.getInventoryItem(item1); 308 InventoryItemBase actual = db.getInventoryItem(rootId);
267 Assert.That(actual, Constraints.PropertyCompareConstraint(expected) 309 Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
268 .IgnoreProperty(x=>x.InvType) 310 .IgnoreProperty(x => x.InvType)
269 .IgnoreProperty(x=>x.CreatorIdAsUuid) 311 .IgnoreProperty(x => x.CreatorIdAsUuid)
270 .IgnoreProperty(x=>x.Description) 312 .IgnoreProperty(x => x.Description)
271 .IgnoreProperty(x=>x.CreatorId)); 313 .IgnoreProperty(x => x.CreatorId));
272 } 314 }
273 315
274 [Test] 316 [Test]
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 5f53725..d64a51e 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -69,6 +69,19 @@ namespace OpenSim.Data.Tests
69 69
70 private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames) 70 private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames)
71 { 71 {
72 //If they are both null, they are equal
73 if (actual == null && expected == null)
74 return true;
75
76 //If only one is null, then they aren't
77 if (actual == null || expected == null)
78 {
79 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
80 failingActual = actual;
81 failingExpected = expected;
82 return false;
83 }
84
72 //prevent loops... 85 //prevent loops...
73 if(propertyNames.Count > 50) 86 if(propertyNames.Count > 50)
74 { 87 {
@@ -195,21 +208,6 @@ namespace OpenSim.Data.Tests
195 object actualValue = property.GetValue(actual, null); 208 object actualValue = property.GetValue(actual, null);
196 object expectedValue = property.GetValue(expected, null); 209 object expectedValue = property.GetValue(expected, null);
197 210
198 //If they are both null, they are equal
199 if (actualValue == null && expectedValue == null)
200 continue;
201
202 //If only one is null, then they aren't
203 if (actualValue == null || expectedValue == null)
204 {
205 propertyNames.Push(property.Name);
206 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
207 propertyNames.Pop();
208 failingActual = actualValue;
209 failingExpected = expectedValue;
210 return false;
211 }
212
213 propertyNames.Push(property.Name); 211 propertyNames.Push(property.Name);
214 if (!ObjectCompare(expectedValue, actualValue, propertyNames)) 212 if (!ObjectCompare(expectedValue, actualValue, propertyNames))
215 return false; 213 return false;