clockwerk-opensim-stable – Diff between revs 1 and 3

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 1 Rev 3
1 /* 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27   27  
28 using System; 28 using System;
29 using System.Collections.Generic; 29 using System.Collections.Generic;
30 using System.IO; 30 using System.IO;
31 using System.Reflection; 31 using System.Reflection;
32 using System.Threading; 32 using System.Threading;
33 using NUnit.Framework; 33 using NUnit.Framework;
34 using OpenMetaverse; 34 using OpenMetaverse;
35 using OpenSim.Data; 35 using OpenSim.Data;
36 using OpenSim.Framework; 36 using OpenSim.Framework;
37 using OpenSim.Framework.Serialization; 37 using OpenSim.Framework.Serialization;
38 using OpenSim.Framework.Serialization.External; 38 using OpenSim.Framework.Serialization.External;
39 using OpenSim.Framework.Communications; 39 using OpenSim.Framework.Communications;
40 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 40 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41 using OpenSim.Region.CoreModules.World.Serialiser; 41 using OpenSim.Region.CoreModules.World.Serialiser;
42 using OpenSim.Region.Framework.Scenes; 42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Region.Framework.Scenes.Serialization; 43 using OpenSim.Region.Framework.Scenes.Serialization;
44 using OpenSim.Services.Interfaces; 44 using OpenSim.Services.Interfaces;
45 using OpenSim.Tests.Common; 45 using OpenSim.Tests.Common;
46 using OpenSim.Tests.Common.Mock; 46 using OpenSim.Tests.Common.Mock;
47   47  
48 namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 48 namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
49 { 49 {
50 [TestFixture] 50 [TestFixture]
51 public class InventoryArchiveLoadPathTests : InventoryArchiveTestCase 51 public class InventoryArchiveLoadPathTests : InventoryArchiveTestCase
52 { 52 {
53 /// <summary> 53 /// <summary>
54 /// Test loading an IAR to various different inventory paths. 54 /// Test loading an IAR to various different inventory paths.
55 /// </summary> 55 /// </summary>
56 [Test] 56 [Test]
57 public void TestLoadIarToInventoryPaths() 57 public void TestLoadIarToInventoryPaths()
58 { 58 {
59 TestHelpers.InMethod(); 59 TestHelpers.InMethod();
60 // log4net.Config.XmlConfigurator.Configure(); 60 // log4net.Config.XmlConfigurator.Configure();
61 61
62 SerialiserModule serialiserModule = new SerialiserModule(); 62 SerialiserModule serialiserModule = new SerialiserModule();
63 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 63 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
64 64
65 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene 65 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
66 Scene scene = new SceneHelpers().SetupScene(); 66 Scene scene = new SceneHelpers().SetupScene();
67 67
68 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 68 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
69   69  
70 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); 70 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood");
71 UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); 71 UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
72 72
73 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); 73 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", m_iarStream);
74 InventoryItemBase foundItem1 74 InventoryItemBase foundItem1
75 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); 75 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
76 76
77 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 77 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
78   78  
79 // Now try loading to a root child folder 79 // Now try loading to a root child folder
80 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false); 80 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false);
81 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); 81 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
82 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); 82 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", archiveReadStream);
83   83  
84 InventoryItemBase foundItem2 84 InventoryItemBase foundItem2
85 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name); 85 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
86 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); 86 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
87   87  
88 // Now try loading to a more deeply nested folder 88 // Now try loading to a more deeply nested folder
89 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false); 89 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false);
90 archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 90 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
91 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); 91 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", archiveReadStream);
92   92  
93 InventoryItemBase foundItem3 93 InventoryItemBase foundItem3
94 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name); 94 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
95 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); 95 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
96 } 96 }
97 97
98 /// <summary> 98 /// <summary>
99 /// Test that things work when the load path specified starts with a slash 99 /// Test that things work when the load path specified starts with a slash
100 /// </summary> 100 /// </summary>
101 [Test] 101 [Test]
102 public void TestLoadIarPathStartsWithSlash() 102 public void TestLoadIarPathStartsWithSlash()
103 { 103 {
104 TestHelpers.InMethod(); 104 TestHelpers.InMethod();
105 // log4net.Config.XmlConfigurator.Configure(); 105 // log4net.Config.XmlConfigurator.Configure();
106 106
107 SerialiserModule serialiserModule = new SerialiserModule(); 107 SerialiserModule serialiserModule = new SerialiserModule();
108 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 108 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
109 Scene scene = new SceneHelpers().SetupScene(); 109 Scene scene = new SceneHelpers().SetupScene();
110 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 110 SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
111 111
112 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); 112 UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password");
113 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); 113 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", m_iarStream);
114   114  
115 InventoryItemBase foundItem1 115 InventoryItemBase foundItem1
116 = InventoryArchiveUtils.FindItemByPath( 116 = InventoryArchiveUtils.FindItemByPath(
117 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name); 117 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name);
118 118
119 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); 119 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
120 } 120 }
121 121
122 [Test] 122 [Test]
123 public void TestLoadIarPathWithEscapedChars() 123 public void TestLoadIarPathWithEscapedChars()
124 { 124 {
125 TestHelpers.InMethod(); 125 TestHelpers.InMethod();
126 // log4net.Config.XmlConfigurator.Configure(); 126 // log4net.Config.XmlConfigurator.Configure();
127   127  
128 string itemName = "You & you are a mean/man/"; 128 string itemName = "You & you are a mean/man/";
129 string humanEscapedItemName = @"You & you are a mean\/man\/"; 129 string humanEscapedItemName = @"You & you are a mean\/man\/";
130 string userPassword = "meowfood"; -  
131   130  
132 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 131 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
133   132  
134 Scene scene = new SceneHelpers().SetupScene(); 133 Scene scene = new SceneHelpers().SetupScene();
135 SceneHelpers.SetupSceneModules(scene, archiverModule); 134 SceneHelpers.SetupSceneModules(scene, archiverModule);
136   135  
137 // Create user 136 // Create user
138 string userFirstName = "Jock"; 137 string userFirstName = "Jock";
139 string userLastName = "Stirrup"; 138 string userLastName = "Stirrup";
140 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 139 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
141 UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); 140 UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
142 141
143 // Create asset 142 // Create asset
144 SceneObjectGroup object1; 143 SceneObjectGroup object1;
145 SceneObjectPart part1; 144 SceneObjectPart part1;
146 { 145 {
147 string partName = "part name"; 146 string partName = "part name";
148 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); 147 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
149 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); 148 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
150 Vector3 groupPosition = new Vector3(10, 20, 30); 149 Vector3 groupPosition = new Vector3(10, 20, 30);
151 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); 150 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
152 Vector3 offsetPosition = new Vector3(5, 10, 15); 151 Vector3 offsetPosition = new Vector3(5, 10, 15);
153   152  
154 part1 153 part1
155 = new SceneObjectPart( 154 = new SceneObjectPart(
156 ownerId, shape, groupPosition, rotationOffset, offsetPosition); 155 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
157 part1.Name = partName; 156 part1.Name = partName;
158   157  
159 object1 = new SceneObjectGroup(part1); 158 object1 = new SceneObjectGroup(part1);
160 scene.AddNewSceneObject(object1, false); 159 scene.AddNewSceneObject(object1, false);
161 } 160 }
162   161  
163 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 162 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
164 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 163 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
165 scene.AssetService.Store(asset1); 164 scene.AssetService.Store(asset1);
166   165  
167 // Create item 166 // Create item
168 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 167 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
169 InventoryItemBase item1 = new InventoryItemBase(); 168 InventoryItemBase item1 = new InventoryItemBase();
170 item1.Name = itemName; 169 item1.Name = itemName;
171 item1.AssetID = asset1.FullID; 170 item1.AssetID = asset1.FullID;
172 item1.ID = item1Id; 171 item1.ID = item1Id;
173 InventoryFolderBase objsFolder 172 InventoryFolderBase objsFolder
174 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, "Objects")[0]; 173 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, "Objects")[0];
175 item1.Folder = objsFolder.ID; 174 item1.Folder = objsFolder.ID;
176 scene.AddInventoryItem(item1); 175 scene.AddInventoryItem(item1);
177   176  
178 MemoryStream archiveWriteStream = new MemoryStream(); 177 MemoryStream archiveWriteStream = new MemoryStream();
179 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 178 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
180   179  
181 mre.Reset(); 180 mre.Reset();
182 archiverModule.ArchiveInventory( 181 archiverModule.ArchiveInventory(
183 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); 182 Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream);
184 mre.WaitOne(60000, false); 183 mre.WaitOne(60000, false);
185   184  
186 // LOAD ITEM 185 // LOAD ITEM
187 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 186 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
188 187
189 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); 188 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", archiveReadStream);
190   189  
191 InventoryItemBase foundItem1 190 InventoryItemBase foundItem1
192 = InventoryArchiveUtils.FindItemByPath( 191 = InventoryArchiveUtils.FindItemByPath(
193 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); 192 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
194 193
195 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 194 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
196 // Assert.That( 195 // Assert.That(
197 // foundItem1.CreatorId, Is.EqualTo(userUuid), 196 // foundItem1.CreatorId, Is.EqualTo(userUuid),
198 // "Loaded item non-uuid creator doesn't match that of the loading user"); 197 // "Loaded item non-uuid creator doesn't match that of the loading user");
199 Assert.That( 198 Assert.That(
200 foundItem1.Name, Is.EqualTo(itemName), 199 foundItem1.Name, Is.EqualTo(itemName),
201 "Loaded item name doesn't match saved name"); 200 "Loaded item name doesn't match saved name");
202 } 201 }
203 202
204 /// <summary> 203 /// <summary>
205 /// Test replication of an archive path to the user's inventory. 204 /// Test replication of an archive path to the user's inventory.
206 /// </summary> 205 /// </summary>
207 [Test] 206 [Test]
208 public void TestNewIarPath() 207 public void TestNewIarPath()
209 { 208 {
210 TestHelpers.InMethod(); 209 TestHelpers.InMethod();
211 // log4net.Config.XmlConfigurator.Configure(); 210 // log4net.Config.XmlConfigurator.Configure();
212 211
213 Scene scene = new SceneHelpers().SetupScene(); 212 Scene scene = new SceneHelpers().SetupScene();
214 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); 213 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
215 214
216 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); 215 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
217 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>(); 216 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
218 217
219 string folder1Name = "1"; 218 string folder1Name = "1";
220 string folder2aName = "2a"; 219 string folder2aName = "2a";
221 string folder2bName = "2b"; 220 string folder2bName = "2b";
222 221
223 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); 222 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
224 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); 223 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
225 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); 224 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
226 225
227 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); 226 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
228 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); 227 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
229   228  
230 { 229 {
231 // Test replication of path1 230 // Test replication of path1
232 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) 231 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
233 .ReplicateArchivePathToUserInventory( 232 .ReplicateArchivePathToUserInventory(
234 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 233 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
235 foldersCreated, nodesLoaded); 234 foldersCreated, nodesLoaded);
236 235
237 List<InventoryFolderBase> folder1Candidates 236 List<InventoryFolderBase> folder1Candidates
238 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); 237 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
239 Assert.That(folder1Candidates.Count, Is.EqualTo(1)); 238 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
240 239
241 InventoryFolderBase folder1 = folder1Candidates[0]; 240 InventoryFolderBase folder1 = folder1Candidates[0];
242 List<InventoryFolderBase> folder2aCandidates 241 List<InventoryFolderBase> folder2aCandidates
243 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName); 242 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
244 Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); 243 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
245 } 244 }
246 245
247 { 246 {
248 // Test replication of path2 247 // Test replication of path2
249 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) 248 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
250 .ReplicateArchivePathToUserInventory( 249 .ReplicateArchivePathToUserInventory(
251 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 250 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
252 foldersCreated, nodesLoaded); 251 foldersCreated, nodesLoaded);
253 252
254 List<InventoryFolderBase> folder1Candidates 253 List<InventoryFolderBase> folder1Candidates
255 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); 254 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
256 Assert.That(folder1Candidates.Count, Is.EqualTo(1)); 255 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
257 256
258 InventoryFolderBase folder1 = folder1Candidates[0]; 257 InventoryFolderBase folder1 = folder1Candidates[0];
259 258
260 List<InventoryFolderBase> folder2aCandidates 259 List<InventoryFolderBase> folder2aCandidates
261 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName); 260 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
262 Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); 261 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
263 262
264 List<InventoryFolderBase> folder2bCandidates 263 List<InventoryFolderBase> folder2bCandidates
265 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2bName); 264 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2bName);
266 Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); 265 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
267 } 266 }
268 } 267 }
269 268
270 /// <summary> 269 /// <summary>
271 /// Test replication of a partly existing archive path to the user's inventory. This should create 270 /// Test replication of a partly existing archive path to the user's inventory. This should create
272 /// a duplicate path without the merge option. 271 /// a duplicate path without the merge option.
273 /// </summary> 272 /// </summary>
274 [Test] 273 [Test]
275 public void TestPartExistingIarPath() 274 public void TestPartExistingIarPath()
276 { 275 {
277 TestHelpers.InMethod(); 276 TestHelpers.InMethod();
278 //log4net.Config.XmlConfigurator.Configure(); 277 //log4net.Config.XmlConfigurator.Configure();
279 278
280 Scene scene = new SceneHelpers().SetupScene(); 279 Scene scene = new SceneHelpers().SetupScene();
281 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); 280 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
282 281
283 string folder1ExistingName = "a"; 282 string folder1ExistingName = "a";
284 string folder2Name = "b"; 283 string folder2Name = "b";
285 284
286 InventoryFolderBase folder1 285 InventoryFolderBase folder1
287 = UserInventoryHelpers.CreateInventoryFolder( 286 = UserInventoryHelpers.CreateInventoryFolder(
288 scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false); 287 scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false);
289 288
290 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); 289 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
291 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); 290 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
292 291
293 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); 292 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
294   293  
295 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false) 294 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
296 .ReplicateArchivePathToUserInventory( 295 .ReplicateArchivePathToUserInventory(
297 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 296 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
298 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); 297 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
299   298  
300 List<InventoryFolderBase> folder1PostCandidates 299 List<InventoryFolderBase> folder1PostCandidates
301 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); 300 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
302 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); 301 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
303 302
304 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. 303 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
305 InventoryFolderBase folder1Post = null; 304 InventoryFolderBase folder1Post = null;
306 foreach (InventoryFolderBase folder in folder1PostCandidates) 305 foreach (InventoryFolderBase folder in folder1PostCandidates)
307 { 306 {
308 if (folder.ID != folder1.ID) 307 if (folder.ID != folder1.ID)
309 { 308 {
310 folder1Post = folder; 309 folder1Post = folder;
311 break; 310 break;
312 } 311 }
313 } 312 }
314 // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); 313 // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
315   314  
316 List<InventoryFolderBase> folder2PostCandidates 315 List<InventoryFolderBase> folder2PostCandidates
317 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1Post, "b"); 316 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1Post, "b");
318 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); 317 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
319 } 318 }
320 319
321 /// <summary> 320 /// <summary>
322 /// Test replication of a partly existing archive path to the user's inventory. This should create 321 /// Test replication of a partly existing archive path to the user's inventory. This should create
323 /// a merged path. 322 /// a merged path.
324 /// </summary> 323 /// </summary>
325 [Test] 324 [Test]
326 public void TestMergeIarPath() 325 public void TestMergeIarPath()
327 { 326 {
328 TestHelpers.InMethod(); 327 TestHelpers.InMethod();
329 // log4net.Config.XmlConfigurator.Configure(); 328 // log4net.Config.XmlConfigurator.Configure();
330 329
331 Scene scene = new SceneHelpers().SetupScene(); 330 Scene scene = new SceneHelpers().SetupScene();
332 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); 331 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene);
333 332
334 string folder1ExistingName = "a"; 333 string folder1ExistingName = "a";
335 string folder2Name = "b"; 334 string folder2Name = "b";
336 335
337 InventoryFolderBase folder1 336 InventoryFolderBase folder1
338 = UserInventoryHelpers.CreateInventoryFolder( 337 = UserInventoryHelpers.CreateInventoryFolder(
339 scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false); 338 scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false);
340 339
341 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); 340 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
342 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); 341 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
343 342
344 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); 343 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
345   344  
346 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true) 345 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true)
347 .ReplicateArchivePathToUserInventory( 346 .ReplicateArchivePathToUserInventory(
348 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 347 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
349 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); 348 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
350   349  
351 List<InventoryFolderBase> folder1PostCandidates 350 List<InventoryFolderBase> folder1PostCandidates
352 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); 351 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
353 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); 352 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
354 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); 353 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
355   354  
356 List<InventoryFolderBase> folder2PostCandidates 355 List<InventoryFolderBase> folder2PostCandidates
357 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1PostCandidates[0], "b"); 356 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1PostCandidates[0], "b");
358 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); 357 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
359 } 358 }
360 } 359 }
361 } 360 }
362   361  
363   362