aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2011-03-10 07:14:03 +0000
committerMelanie2011-03-10 07:14:03 +0000
commit9165a5207d81adfedeb07ed32eb095c0c42f086f (patch)
tree839af9da6d5d56613312ad7b4fa2b1f9493a4842 /OpenSim/Region/CoreModules
parentChange protection from being teleported home to extend to incognito gods. (diff)
parentChange existing users load iar test so that it fulfills it's original intenti... (diff)
downloadopensim-SC_OLD-9165a5207d81adfedeb07ed32eb095c0c42f086f.zip
opensim-SC_OLD-9165a5207d81adfedeb07ed32eb095c0c42f086f.tar.gz
opensim-SC_OLD-9165a5207d81adfedeb07ed32eb095c0c42f086f.tar.bz2
opensim-SC_OLD-9165a5207d81adfedeb07ed32eb095c0c42f086f.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs155
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs612
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs480
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs60
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs102
-rw-r--r--OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs1
13 files changed, 826 insertions, 637 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 6030706..7849d88 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -400,6 +400,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
401 if (UUID.Zero != ospResolvedId) // The user exists in this grid 401 if (UUID.Zero != ospResolvedId) // The user exists in this grid
402 { 402 {
403// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
404
403 item.CreatorIdAsUuid = ospResolvedId; 405 item.CreatorIdAsUuid = ospResolvedId;
404 406
405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 407 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index a71def7..613f0ed 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 109
110 scene.AddCommand( 110 scene.AddCommand(
111 this, "load iar", 111 this, "load iar",
112 "load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", 112 "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]",
113 "Load user inventory archive (IAR).", 113 "Load user inventory archive (IAR).",
114 "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" 114 "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones"
115 + "<first> is user's first name." + Environment.NewLine 115 + "<first> is user's first name." + Environment.NewLine
116 + "<last> is user's last name." + Environment.NewLine 116 + "<last> is user's last name." + Environment.NewLine
117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine 117 + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine
@@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
181 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
182 { 182 {
183 m_log.ErrorFormat( 183 m_log.ErrorFormat(
184 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 184 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 185 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
186 m_log.Error(e); 186 m_log.Error(e);
187 187
@@ -221,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
221 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
222 { 222 {
223 m_log.ErrorFormat( 223 m_log.ErrorFormat(
224 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 224 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 225 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
226 m_log.Error(e); 226 m_log.Error(e);
227 227
@@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
269 catch (EntryPointNotFoundException e) 269 catch (EntryPointNotFoundException e)
270 { 270 {
271 m_log.ErrorFormat( 271 m_log.ErrorFormat(
272 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 272 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 273 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
274 m_log.Error(e); 274 m_log.Error(e);
275 275
@@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
317 catch (EntryPointNotFoundException e) 317 catch (EntryPointNotFoundException e)
318 { 318 {
319 m_log.ErrorFormat( 319 m_log.ErrorFormat(
320 "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." 320 "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream."
321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 321 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
322 m_log.Error(e); 322 m_log.Error(e);
323 323
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
358 if (mainParams.Count < 6) 358 if (mainParams.Count < 6)
359 { 359 {
360 m_log.Error( 360 m_log.Error(
361 "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); 361 "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]");
362 return; 362 return;
363 } 363 }
364 364
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
new file mode 100644
index 0000000..dcafc49
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -0,0 +1,155 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class InventoryArchiveTestCase
53 {
54 protected ManualResetEvent mre = new ManualResetEvent(false);
55
56 /// <summary>
57 /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test.
58 /// </summary>
59 protected byte[] m_iarStreamBytes;
60
61 /// <summary>
62 /// Stream of data representing a common IAR for load tests.
63 /// </summary>
64 protected MemoryStream m_iarStream;
65
66 protected UserAccount m_ua1
67 = new UserAccount {
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr",
70 LastName = "Tiddles" };
71 protected UserAccount m_ua2
72 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord",
75 LastName = "Lucan" };
76 protected UserAccount m_ua3
77 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord",
80 LastName = "Lucan" };
81 protected string m_item1Name = "Ray Gun Item";
82
83 [SetUp]
84 public void SetUp()
85 {
86 m_iarStream = new MemoryStream(m_iarStreamBytes);
87 }
88
89 [TestFixtureSetUp]
90 public void FixtureSetup()
91 {
92 ConstructDefaultIarBytesForTestLoad();
93 }
94
95 protected void ConstructDefaultIarBytesForTestLoad()
96 {
97// log4net.Config.XmlConfigurator.Configure();
98
99 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
100 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
101
102 MemoryStream archiveWriteStream = new MemoryStream();
103 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
104
105 // Create asset
106 SceneObjectGroup object1;
107 SceneObjectPart part1;
108 {
109 string partName = "Ray Gun Object";
110 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
111 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
112 Vector3 groupPosition = new Vector3(10, 20, 30);
113 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
114 Vector3 offsetPosition = new Vector3(5, 10, 15);
115
116 part1
117 = new SceneObjectPart(
118 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
119 part1.Name = partName;
120
121 object1 = new SceneObjectGroup(part1);
122 scene.AddNewSceneObject(object1, false);
123 }
124
125 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
126 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
127 scene.AssetService.Store(asset1);
128
129 // Create item
130 InventoryItemBase item1 = new InventoryItemBase();
131 item1.Name = m_item1Name;
132 item1.AssetID = asset1.FullID;
133 item1.GroupID = UUID.Random();
134 item1.CreatorIdAsUuid = m_ua2.PrincipalID;
135 item1.Owner = UUID.Zero;
136
137 string archiveItem1Name = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
138 string archiveItem1Path = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItem1Name);
139 tar.WriteFile(
140 archiveItem1Path,
141 UserInventoryItemSerializer.Serialize(
142 item1, new Dictionary<string, object>(), scene.UserAccountService));
143 tar.Close();
144
145 m_iarStreamBytes = archiveWriteStream.ToArray();
146 }
147
148 protected void SaveCompleted(
149 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
150 Exception reportedException)
151 {
152 mre.Set();
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 76d0b85..b52014b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -31,7 +31,6 @@ using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using NUnit.Framework; 33using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Framework; 36using OpenSim.Framework;
@@ -50,184 +49,8 @@ using OpenSim.Tests.Common.Setup;
50namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
51{ 50{
52 [TestFixture] 51 [TestFixture]
53 public class InventoryArchiverTests 52 public class InventoryArchiverTests : InventoryArchiveTestCase
54 { 53 {
55 protected ManualResetEvent mre = new ManualResetEvent(false);
56
57 /// <summary>
58 /// Stream of data representing a common IAR that can be reused in load tests.
59 /// </summary>
60 protected MemoryStream m_iarStream;
61
62 protected UserAccount m_ua1
63 = new UserAccount {
64 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
65 FirstName = "Mr",
66 LastName = "Tiddles" };
67 protected UserAccount m_ua2
68 = new UserAccount {
69 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
70 FirstName = "Lord",
71 LastName = "Lucan" };
72 string m_item1Name = "b.lsl";
73
74 private void SaveCompleted(
75 Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
76 Exception reportedException)
77 {
78 mre.Set();
79 }
80
81 [SetUp]
82 public void Init()
83 {
84 ConstructDefaultIarForTestLoad();
85 }
86
87 protected void ConstructDefaultIarForTestLoad()
88 {
89 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random());
90
91 MemoryStream archiveWriteStream = new MemoryStream();
92 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
93
94 InventoryItemBase item1 = new InventoryItemBase();
95 item1.Name = m_item1Name;
96 item1.AssetID = UUID.Random();
97 item1.GroupID = UUID.Random();
98 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
99 //item1.CreatorId = userUuid.ToString();
100 item1.CreatorId = m_ua2.PrincipalID.ToString();
101 item1.Owner = UUID.Zero;
102
103 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
104 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
105
106 string item1FileName
107 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
108 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
109 tar.Close();
110 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
111 }
112
113 /// <summary>
114 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
115 /// (subject to change since there is no fixed format yet).
116 /// </summary>
117 [Test]
118 public void TestSavePathToIarV0_1()
119 {
120 TestHelper.InMethod();
121// log4net.Config.XmlConfigurator.Configure();
122
123 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
124
125 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
126 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
127
128 // Create user
129 string userFirstName = "Jock";
130 string userLastName = "Stirrup";
131 string userPassword = "troll";
132 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
133 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
134
135 // Create asset
136 SceneObjectGroup object1;
137 SceneObjectPart part1;
138 {
139 string partName = "My Little Dog Object";
140 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
141 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
142 Vector3 groupPosition = new Vector3(10, 20, 30);
143 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
144 Vector3 offsetPosition = new Vector3(5, 10, 15);
145
146 part1
147 = new SceneObjectPart(
148 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
149 part1.Name = partName;
150
151 object1 = new SceneObjectGroup(part1);
152 scene.AddNewSceneObject(object1, false);
153 }
154
155 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
156 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
157 scene.AssetService.Store(asset1);
158
159 // Create item
160 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
161 InventoryItemBase item1 = new InventoryItemBase();
162 item1.Name = "My Little Dog";
163 item1.AssetID = asset1.FullID;
164 item1.ID = item1Id;
165 InventoryFolderBase objsFolder
166 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
167 item1.Folder = objsFolder.ID;
168 scene.AddInventoryItem(item1);
169
170 MemoryStream archiveWriteStream = new MemoryStream();
171 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
172
173 // Test saving a particular path
174 mre.Reset();
175 archiverModule.ArchiveInventory(
176 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
177 mre.WaitOne(60000, false);
178
179 byte[] archive = archiveWriteStream.ToArray();
180 MemoryStream archiveReadStream = new MemoryStream(archive);
181 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
182
183 //bool gotControlFile = false;
184 bool gotObject1File = false;
185 //bool gotObject2File = false;
186 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
187 string expectedObject1FilePath = string.Format(
188 "{0}{1}{2}",
189 ArchiveConstants.INVENTORY_PATH,
190 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
191 expectedObject1FileName);
192
193 string filePath;
194 TarArchiveReader.TarEntryType tarEntryType;
195
196// Console.WriteLine("Reading archive");
197
198 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
199 {
200// Console.WriteLine("Got {0}", filePath);
201
202// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
203// {
204// gotControlFile = true;
205// }
206
207 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
208 {
209// string fileName = filePath.Remove(0, "Objects/".Length);
210//
211// if (fileName.StartsWith(part1.Name))
212// {
213 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
214 gotObject1File = true;
215// }
216// else if (fileName.StartsWith(part2.Name))
217// {
218// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
219// gotObject2File = true;
220// }
221 }
222 }
223
224// Assert.That(gotControlFile, Is.True, "No control file in archive");
225 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
226// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
227
228 // TODO: Test presence of more files and contents of files.
229 }
230
231 /// <summary> 54 /// <summary>
232 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive 55 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
233 /// (subject to change since there is no fixed format yet). 56 /// (subject to change since there is no fixed format yet).
@@ -346,40 +169,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
346 } 169 }
347 170
348 /// <summary> 171 /// <summary>
349 /// Test that things work when the load path specified starts with a slash
350 /// </summary>
351 [Test]
352 public void TestLoadIarPathStartsWithSlash()
353 {
354 TestHelper.InMethod();
355// log4net.Config.XmlConfigurator.Configure();
356
357 SerialiserModule serialiserModule = new SerialiserModule();
358 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
359 Scene scene = SceneSetupHelpers.SetupScene("inventory");
360 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
361
362 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
363 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream);
364
365 InventoryItemBase foundItem1
366 = InventoryArchiveUtils.FindItemByPath(
367 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name);
368
369 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
370 }
371
372 /// <summary>
373 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 172 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
374 /// an account exists with the creator name. 173 /// an account exists with the same name as the creator, though not the same id.
375 /// </summary> 174 /// </summary>
376 ///
377 /// This test also does some deeper probing of loading into nested inventory structures
378 [Test] 175 [Test]
379 public void TestLoadIarV0_1ExistingUsers() 176 public void TestLoadIarV0_1SameNameCreator()
380 { 177 {
381 TestHelper.InMethod(); 178 TestHelper.InMethod();
382 //log4net.Config.XmlConfigurator.Configure(); 179// log4net.Config.XmlConfigurator.Configure();
383 180
384 SerialiserModule serialiserModule = new SerialiserModule(); 181 SerialiserModule serialiserModule = new SerialiserModule();
385 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 182 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
@@ -390,14 +187,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
390 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 187 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
391 188
392 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 189 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
393 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 190 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua3, "hampshire");
394 191
395 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 192 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream);
396
397 InventoryItemBase foundItem1 193 InventoryItemBase foundItem1
398 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 194 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);
399
400 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
401 195
402// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the 196// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
403// UUID, not the OSPA itself. 197// UUID, not the OSPA itself.
@@ -405,415 +199,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
405// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), 199// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
406// "Loaded item non-uuid creator doesn't match original"); 200// "Loaded item non-uuid creator doesn't match original");
407 Assert.That( 201 Assert.That(
408 foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), 202 foundItem1.CreatorId, Is.EqualTo(m_ua3.PrincipalID.ToString()),
409 "Loaded item non-uuid creator doesn't match original"); 203 "Loaded item non-uuid creator doesn't match original");
410
411 Assert.That( 204 Assert.That(
412 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), 205 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua3.PrincipalID),
413 "Loaded item uuid creator doesn't match original"); 206 "Loaded item uuid creator doesn't match original");
414 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 207 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID),
415 "Loaded item owner doesn't match inventory reciever"); 208 "Loaded item owner doesn't match inventory reciever");
416
417 // Now try loading to a root child folder
418 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
419 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
420 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
421
422 InventoryItemBase foundItem2
423 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
424 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
425
426 // Now try loading to a more deeply nested folder
427 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
428 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
429 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
430
431 InventoryItemBase foundItem3
432 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
433 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
434 }
435
436 [Test]
437 public void TestIarV0_1WithEscapedChars()
438 {
439 TestHelper.InMethod();
440// log4net.Config.XmlConfigurator.Configure();
441
442 string itemName = "You & you are a mean/man/";
443 string humanEscapedItemName = @"You & you are a mean\/man\/";
444 string userPassword = "meowfood";
445
446 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
447
448 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
449 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
450
451 // Create user
452 string userFirstName = "Jock";
453 string userLastName = "Stirrup";
454 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
455 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
456
457 // Create asset
458 SceneObjectGroup object1;
459 SceneObjectPart part1;
460 {
461 string partName = "part name";
462 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
463 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
464 Vector3 groupPosition = new Vector3(10, 20, 30);
465 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
466 Vector3 offsetPosition = new Vector3(5, 10, 15);
467
468 part1
469 = new SceneObjectPart(
470 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
471 part1.Name = partName;
472
473 object1 = new SceneObjectGroup(part1);
474 scene.AddNewSceneObject(object1, false);
475 }
476
477 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
478 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
479 scene.AssetService.Store(asset1);
480
481 // Create item
482 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
483 InventoryItemBase item1 = new InventoryItemBase();
484 item1.Name = itemName;
485 item1.AssetID = asset1.FullID;
486 item1.ID = item1Id;
487 InventoryFolderBase objsFolder
488 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
489 item1.Folder = objsFolder.ID;
490 scene.AddInventoryItem(item1);
491
492 MemoryStream archiveWriteStream = new MemoryStream();
493 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
494
495 mre.Reset();
496 archiverModule.ArchiveInventory(
497 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
498 mre.WaitOne(60000, false);
499
500 // LOAD ITEM
501 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
502
503 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
504
505 InventoryItemBase foundItem1
506 = InventoryArchiveUtils.FindItemByPath(
507 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
508
509 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
510// Assert.That(
511// foundItem1.CreatorId, Is.EqualTo(userUuid),
512// "Loaded item non-uuid creator doesn't match that of the loading user");
513 Assert.That(
514 foundItem1.Name, Is.EqualTo(itemName),
515 "Loaded item name doesn't match saved name");
516 } 209 }
517 210
518 /// <summary> 211 /// <summary>
519 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 212 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
520 /// embedded creators do not exist in the system 213 /// the creator or an account with the creator's name does not exist within the system.
521 /// </summary> 214 /// </summary>
522 ///
523 /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature
524 /// (as tested in the a later commented out test)
525 /// This test is currently disabled
526 [Test] 215 [Test]
527 public void TestLoadIarV0_1AbsentUsers() 216 public void TestLoadIarV0_1AbsentCreator()
528 { 217 {
529 TestHelper.InMethod(); 218 TestHelper.InMethod();
530 //log4net.Config.XmlConfigurator.Configure(); 219// log4net.Config.XmlConfigurator.Configure();
531
532 string userFirstName = "Charlie";
533 string userLastName = "Chan";
534 UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999");
535 string userItemCreatorFirstName = "Bat";
536 string userItemCreatorLastName = "Man";
537 //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888");
538
539 string itemName = "b.lsl";
540 string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
541
542 MemoryStream archiveWriteStream = new MemoryStream();
543 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
544
545 InventoryItemBase item1 = new InventoryItemBase();
546 item1.Name = itemName;
547 item1.AssetID = UUID.Random();
548 item1.GroupID = UUID.Random();
549 item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName);
550 //item1.CreatorId = userUuid.ToString();
551 //item1.CreatorId = "00000000-0000-0000-0000-000000000444";
552 item1.Owner = UUID.Zero;
553 220
554 string item1FileName
555 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
556 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
557 tar.Close();
558
559 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
560 SerialiserModule serialiserModule = new SerialiserModule(); 221 SerialiserModule serialiserModule = new SerialiserModule();
561 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 222 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
562
563 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
564 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 223 Scene scene = SceneSetupHelpers.SetupScene("inventory");
565
566 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 224 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
567 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood");
568 225
569 archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); 226 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
227 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "password", m_iarStream);
570 228
571 InventoryItemBase foundItem1 229 InventoryItemBase foundItem1
572 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); 230 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);
573 231
574 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 232 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
575// Assert.That( 233// Assert.That(
576// foundItem1.CreatorId, Is.EqualTo(userUuid), 234// foundItem1.CreatorId, Is.EqualTo(userUuid),
577// "Loaded item non-uuid creator doesn't match that of the loading user"); 235// "Loaded item non-uuid creator doesn't match that of the loading user");
578 Assert.That( 236 Assert.That(
579 foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), 237 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua1.PrincipalID),
580 "Loaded item uuid creator doesn't match that of the loading user"); 238 "Loaded item uuid creator doesn't match that of the loading user");
581 } 239 }
582
583 /// <summary>
584 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
585 /// no account exists with the creator name
586 /// </summary>
587 /// Disabled since temporary profiles have not yet been implemented.
588 ///
589 //[Test]
590 //public void TestLoadIarV0_1TempProfiles()
591 //{
592 // TestHelper.InMethod();
593
594 // //log4net.Config.XmlConfigurator.Configure();
595
596 // string userFirstName = "Dennis";
597 // string userLastName = "Menace";
598 // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa");
599 // string user2FirstName = "Walter";
600 // string user2LastName = "Mitty";
601
602 // string itemName = "b.lsl";
603 // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
604
605 // MemoryStream archiveWriteStream = new MemoryStream();
606 // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
607
608 // InventoryItemBase item1 = new InventoryItemBase();
609 // item1.Name = itemName;
610 // item1.AssetID = UUID.Random();
611 // item1.GroupID = UUID.Random();
612 // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName);
613 // item1.Owner = UUID.Zero;
614
615 // string item1FileName
616 // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
617 // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
618 // tar.Close();
619
620 // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
621 // SerialiserModule serialiserModule = new SerialiserModule();
622 // InventoryArchiverModule archiverModule = new InventoryArchiverModule();
623
624 // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
625 // Scene scene = SceneSetupHelpers.SetupScene();
626 // IUserAdminService userAdminService = scene.CommsManager.UserAdminService;
627
628 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
629 // userAdminService.AddUser(
630 // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid);
631
632 // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream);
633
634 // // Check that a suitable temporary user profile has been created.
635 // UserProfileData user2Profile
636 // = scene.CommsManager.UserService.GetUserProfile(
637 // OspResolver.HashName(user2FirstName + " " + user2LastName));
638 // Assert.That(user2Profile, Is.Not.Null);
639 // Assert.That(user2Profile.FirstName == user2FirstName);
640 // Assert.That(user2Profile.SurName == user2LastName);
641
642 // CachedUserInfo userInfo
643 // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
644 // userInfo.OnInventoryReceived += InventoryReceived;
645
646 // lock (this)
647 // {
648 // userInfo.FetchInventory();
649 // Monitor.Wait(this, 60000);
650 // }
651
652 // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
653
654 // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
655 // Assert.That(
656 // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName)));
657 // Assert.That(foundItem.Owner, Is.EqualTo(userUuid));
658
659 // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod());
660 //}
661
662 /// <summary>
663 /// Test replication of an archive path to the user's inventory.
664 /// </summary>
665 [Test]
666 public void TestNewIarPath()
667 {
668 TestHelper.InMethod();
669// log4net.Config.XmlConfigurator.Configure();
670
671 Scene scene = SceneSetupHelpers.SetupScene("inventory");
672 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
673
674 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
675 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
676
677 string folder1Name = "1";
678 string folder2aName = "2a";
679 string folder2bName = "2b";
680
681 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
682 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
683 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
684
685 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
686 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
687
688 {
689 // Test replication of path1
690 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
691 .ReplicateArchivePathToUserInventory(
692 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
693 foldersCreated, nodesLoaded);
694
695 List<InventoryFolderBase> folder1Candidates
696 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
697 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
698
699 InventoryFolderBase folder1 = folder1Candidates[0];
700 List<InventoryFolderBase> folder2aCandidates
701 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
702 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
703 }
704
705 {
706 // Test replication of path2
707 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
708 .ReplicateArchivePathToUserInventory(
709 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
710 foldersCreated, nodesLoaded);
711
712 List<InventoryFolderBase> folder1Candidates
713 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
714 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
715
716 InventoryFolderBase folder1 = folder1Candidates[0];
717
718 List<InventoryFolderBase> folder2aCandidates
719 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
720 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
721
722 List<InventoryFolderBase> folder2bCandidates
723 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
724 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
725 }
726 }
727
728 /// <summary>
729 /// Test replication of a partly existing archive path to the user's inventory. This should create
730 /// a duplicate path without the merge option.
731 /// </summary>
732 [Test]
733 public void TestPartExistingIarPath()
734 {
735 TestHelper.InMethod();
736 //log4net.Config.XmlConfigurator.Configure();
737
738 Scene scene = SceneSetupHelpers.SetupScene("inventory");
739 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
740
741 string folder1ExistingName = "a";
742 string folder2Name = "b";
743
744 InventoryFolderBase folder1
745 = UserInventoryTestUtils.CreateInventoryFolder(
746 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
747
748 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
749 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
750
751 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
752
753 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
754 .ReplicateArchivePathToUserInventory(
755 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
756 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
757
758 List<InventoryFolderBase> folder1PostCandidates
759 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
760 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
761
762 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
763 InventoryFolderBase folder1Post = null;
764 foreach (InventoryFolderBase folder in folder1PostCandidates)
765 {
766 if (folder.ID != folder1.ID)
767 {
768 folder1Post = folder;
769 break;
770 }
771 }
772// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
773
774 List<InventoryFolderBase> folder2PostCandidates
775 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
776 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
777 }
778
779 /// <summary>
780 /// Test replication of a partly existing archive path to the user's inventory. This should create
781 /// a merged path.
782 /// </summary>
783 [Test]
784 public void TestMergeIarPath()
785 {
786 TestHelper.InMethod();
787// log4net.Config.XmlConfigurator.Configure();
788
789 Scene scene = SceneSetupHelpers.SetupScene("inventory");
790 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
791
792 string folder1ExistingName = "a";
793 string folder2Name = "b";
794
795 InventoryFolderBase folder1
796 = UserInventoryTestUtils.CreateInventoryFolder(
797 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
798
799 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
800 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
801
802 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
803
804 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
805 .ReplicateArchivePathToUserInventory(
806 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
807 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
808
809 List<InventoryFolderBase> folder1PostCandidates
810 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
811 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
812 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
813
814 List<InventoryFolderBase> folder2PostCandidates
815 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
816 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
817 }
818 } 240 }
819} \ No newline at end of file 241} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
new file mode 100644
index 0000000..1220a70
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -0,0 +1,480 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
41using OpenSim.Region.CoreModules.World.Serialiser;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{
51 [TestFixture]
52 public class PathTests : InventoryArchiveTestCase
53 {
54 /// <summary>
55 /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
56 /// (subject to change since there is no fixed format yet).
57 /// </summary>
58 [Test]
59 public void TestSavePathToIarV0_1()
60 {
61 TestHelper.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68
69 // Create user
70 string userFirstName = "Jock";
71 string userLastName = "Stirrup";
72 string userPassword = "troll";
73 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
74 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
75
76 // Create asset
77 SceneObjectGroup object1;
78 SceneObjectPart part1;
79 {
80 string partName = "My Little Dog Object";
81 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
82 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
83 Vector3 groupPosition = new Vector3(10, 20, 30);
84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
85 Vector3 offsetPosition = new Vector3(5, 10, 15);
86
87 part1
88 = new SceneObjectPart(
89 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
90 part1.Name = partName;
91
92 object1 = new SceneObjectGroup(part1);
93 scene.AddNewSceneObject(object1, false);
94 }
95
96 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
97 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
98 scene.AssetService.Store(asset1);
99
100 // Create item
101 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
102 InventoryItemBase item1 = new InventoryItemBase();
103 item1.Name = "My Little Dog";
104 item1.AssetID = asset1.FullID;
105 item1.ID = item1Id;
106 InventoryFolderBase objsFolder
107 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
108 item1.Folder = objsFolder.ID;
109 scene.AddInventoryItem(item1);
110
111 MemoryStream archiveWriteStream = new MemoryStream();
112 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
113
114 // Test saving a particular path
115 mre.Reset();
116 archiverModule.ArchiveInventory(
117 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
118 mre.WaitOne(60000, false);
119
120 byte[] archive = archiveWriteStream.ToArray();
121 MemoryStream archiveReadStream = new MemoryStream(archive);
122 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
123
124 //bool gotControlFile = false;
125 bool gotObject1File = false;
126 //bool gotObject2File = false;
127 string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
128 string expectedObject1FilePath = string.Format(
129 "{0}{1}{2}",
130 ArchiveConstants.INVENTORY_PATH,
131 InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
132 expectedObject1FileName);
133
134 string filePath;
135 TarArchiveReader.TarEntryType tarEntryType;
136
137// Console.WriteLine("Reading archive");
138
139 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
140 {
141// Console.WriteLine("Got {0}", filePath);
142
143// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
144// {
145// gotControlFile = true;
146// }
147
148 if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
149 {
150// string fileName = filePath.Remove(0, "Objects/".Length);
151//
152// if (fileName.StartsWith(part1.Name))
153// {
154 Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
155 gotObject1File = true;
156// }
157// else if (fileName.StartsWith(part2.Name))
158// {
159// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
160// gotObject2File = true;
161// }
162 }
163 }
164
165// Assert.That(gotControlFile, Is.True, "No control file in archive");
166 Assert.That(gotObject1File, Is.True, "No item1 file in archive");
167// Assert.That(gotObject2File, Is.True, "No object2 file in archive");
168
169 // TODO: Test presence of more files and contents of files.
170 }
171
172 /// <summary>
173 /// Test loading an IAR to various different inventory paths.
174 /// </summary>
175 [Test]
176 public void TestLoadIarToInventoryPaths()
177 {
178 TestHelper.InMethod();
179// log4net.Config.XmlConfigurator.Configure();
180
181 SerialiserModule serialiserModule = new SerialiserModule();
182 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
183
184 // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
185 Scene scene = SceneSetupHelpers.SetupScene("inventory");
186
187 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
188
189 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
190 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
191
192 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream);
193 InventoryItemBase foundItem1
194 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);
195
196 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
197
198 // Now try loading to a root child folder
199 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
200 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
201 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);
202
203 InventoryItemBase foundItem2
204 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);
205 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
206
207 // Now try loading to a more deeply nested folder
208 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
209 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
210 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);
211
212 InventoryItemBase foundItem3
213 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);
214 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
215 }
216
217 /// <summary>
218 /// Test that things work when the load path specified starts with a slash
219 /// </summary>
220 [Test]
221 public void TestLoadIarPathStartsWithSlash()
222 {
223 TestHelper.InMethod();
224// log4net.Config.XmlConfigurator.Configure();
225
226 SerialiserModule serialiserModule = new SerialiserModule();
227 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
228 Scene scene = SceneSetupHelpers.SetupScene("inventory");
229 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
230
231 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
232 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream);
233
234 InventoryItemBase foundItem1
235 = InventoryArchiveUtils.FindItemByPath(
236 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name);
237
238 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
239 }
240
241 [Test]
242 public void TestLoadIarPathWithEscapedChars()
243 {
244 TestHelper.InMethod();
245// log4net.Config.XmlConfigurator.Configure();
246
247 string itemName = "You & you are a mean/man/";
248 string humanEscapedItemName = @"You & you are a mean\/man\/";
249 string userPassword = "meowfood";
250
251 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
252
253 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
254 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
255
256 // Create user
257 string userFirstName = "Jock";
258 string userLastName = "Stirrup";
259 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
260 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
261
262 // Create asset
263 SceneObjectGroup object1;
264 SceneObjectPart part1;
265 {
266 string partName = "part name";
267 UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
268 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
269 Vector3 groupPosition = new Vector3(10, 20, 30);
270 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
271 Vector3 offsetPosition = new Vector3(5, 10, 15);
272
273 part1
274 = new SceneObjectPart(
275 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
276 part1.Name = partName;
277
278 object1 = new SceneObjectGroup(part1);
279 scene.AddNewSceneObject(object1, false);
280 }
281
282 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
283 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
284 scene.AssetService.Store(asset1);
285
286 // Create item
287 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
288 InventoryItemBase item1 = new InventoryItemBase();
289 item1.Name = itemName;
290 item1.AssetID = asset1.FullID;
291 item1.ID = item1Id;
292 InventoryFolderBase objsFolder
293 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
294 item1.Folder = objsFolder.ID;
295 scene.AddInventoryItem(item1);
296
297 MemoryStream archiveWriteStream = new MemoryStream();
298 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
299
300 mre.Reset();
301 archiverModule.ArchiveInventory(
302 Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
303 mre.WaitOne(60000, false);
304
305 // LOAD ITEM
306 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
307
308 archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);
309
310 InventoryItemBase foundItem1
311 = InventoryArchiveUtils.FindItemByPath(
312 scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
313
314 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
315// Assert.That(
316// foundItem1.CreatorId, Is.EqualTo(userUuid),
317// "Loaded item non-uuid creator doesn't match that of the loading user");
318 Assert.That(
319 foundItem1.Name, Is.EqualTo(itemName),
320 "Loaded item name doesn't match saved name");
321 }
322
323 /// <summary>
324 /// Test replication of an archive path to the user's inventory.
325 /// </summary>
326 [Test]
327 public void TestNewIarPath()
328 {
329 TestHelper.InMethod();
330// log4net.Config.XmlConfigurator.Configure();
331
332 Scene scene = SceneSetupHelpers.SetupScene("inventory");
333 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
334
335 Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>();
336 HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>();
337
338 string folder1Name = "1";
339 string folder2aName = "2a";
340 string folder2bName = "2b";
341
342 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
343 string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
344 string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());
345
346 string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
347 string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });
348
349 {
350 // Test replication of path1
351 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
352 .ReplicateArchivePathToUserInventory(
353 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
354 foldersCreated, nodesLoaded);
355
356 List<InventoryFolderBase> folder1Candidates
357 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
358 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
359
360 InventoryFolderBase folder1 = folder1Candidates[0];
361 List<InventoryFolderBase> folder2aCandidates
362 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
363 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
364 }
365
366 {
367 // Test replication of path2
368 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
369 .ReplicateArchivePathToUserInventory(
370 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
371 foldersCreated, nodesLoaded);
372
373 List<InventoryFolderBase> folder1Candidates
374 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
375 Assert.That(folder1Candidates.Count, Is.EqualTo(1));
376
377 InventoryFolderBase folder1 = folder1Candidates[0];
378
379 List<InventoryFolderBase> folder2aCandidates
380 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
381 Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
382
383 List<InventoryFolderBase> folder2bCandidates
384 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
385 Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
386 }
387 }
388
389 /// <summary>
390 /// Test replication of a partly existing archive path to the user's inventory. This should create
391 /// a duplicate path without the merge option.
392 /// </summary>
393 [Test]
394 public void TestPartExistingIarPath()
395 {
396 TestHelper.InMethod();
397 //log4net.Config.XmlConfigurator.Configure();
398
399 Scene scene = SceneSetupHelpers.SetupScene("inventory");
400 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
401
402 string folder1ExistingName = "a";
403 string folder2Name = "b";
404
405 InventoryFolderBase folder1
406 = UserInventoryTestUtils.CreateInventoryFolder(
407 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
408
409 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
410 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
411
412 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
413
414 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
415 .ReplicateArchivePathToUserInventory(
416 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
417 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
418
419 List<InventoryFolderBase> folder1PostCandidates
420 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
421 Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
422
423 // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
424 InventoryFolderBase folder1Post = null;
425 foreach (InventoryFolderBase folder in folder1PostCandidates)
426 {
427 if (folder.ID != folder1.ID)
428 {
429 folder1Post = folder;
430 break;
431 }
432 }
433// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
434
435 List<InventoryFolderBase> folder2PostCandidates
436 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
437 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
438 }
439
440 /// <summary>
441 /// Test replication of a partly existing archive path to the user's inventory. This should create
442 /// a merged path.
443 /// </summary>
444 [Test]
445 public void TestMergeIarPath()
446 {
447 TestHelper.InMethod();
448// log4net.Config.XmlConfigurator.Configure();
449
450 Scene scene = SceneSetupHelpers.SetupScene("inventory");
451 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
452
453 string folder1ExistingName = "a";
454 string folder2Name = "b";
455
456 InventoryFolderBase folder1
457 = UserInventoryTestUtils.CreateInventoryFolder(
458 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
459
460 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
461 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
462
463 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
464
465 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
466 .ReplicateArchivePathToUserInventory(
467 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
468 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
469
470 List<InventoryFolderBase> folder1PostCandidates
471 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
472 Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
473 Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
474
475 List<InventoryFolderBase> folder2PostCandidates
476 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
477 Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
478 }
479 }
480} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index e622e0c..138556f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -400,6 +400,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
400 if (!UpdateAgent(reg, finalDestination, agent)) 400 if (!UpdateAgent(reg, finalDestination, agent))
401 { 401 {
402 // Region doesn't take it 402 // Region doesn't take it
403 m_log.WarnFormat(
404 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.",
405 sp.Name, finalDestination.RegionName);
406
403 Fail(sp, finalDestination); 407 Fail(sp, finalDestination);
404 return; 408 return;
405 } 409 }
@@ -426,16 +430,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
426 // that the client contacted the destination before we send the attachments and close things here. 430 // that the client contacted the destination before we send the attachments and close things here.
427 if (!WaitForCallback(sp.UUID)) 431 if (!WaitForCallback(sp.UUID))
428 { 432 {
429 Fail(sp, finalDestination); 433 m_log.WarnFormat(
434 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.",
435 sp.Name, finalDestination.RegionName);
436
437 Fail(sp, finalDestination);
430 return; 438 return;
431 } 439 }
432 440
433
434 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it 441 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
435 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 442 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
436 443
437 // Well, this is it. The agent is over there. 444 // Well, this is it. The agent is over there.
438
439 KillEntity(sp.Scene, sp.LocalId); 445 KillEntity(sp.Scene, sp.LocalId);
440 446
441 // May need to logout or other cleanup 447 // May need to logout or other cleanup
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index ebfba2b..7128d2b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index ef910f4..e471f75 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using Nini.Config; 37using Nini.Config;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index e1eee3b..97833f3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
192 return false; 192 return false;
193 193
194 // Try local first 194 // Try local first
195 if (m_localBackend.UpdateAgent(destination, cAgentData)) 195 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
196 return true; 196 return m_localBackend.UpdateAgent(destination, cAgentData);
197
198 // else do the remote thing
199 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
200 return m_remoteConnector.UpdateAgent(destination, cAgentData);
201
202 return false;
203 197
198 return m_remoteConnector.UpdateAgent(destination, cAgentData);
204 } 199 }
205 200
206 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) 201 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData)
@@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
209 return false; 204 return false;
210 205
211 // Try local first 206 // Try local first
212 if (m_localBackend.UpdateAgent(destination, cAgentData)) 207 if (m_localBackend.IsLocalRegion(destination.RegionHandle))
213 return true; 208 return m_localBackend.UpdateAgent(destination, cAgentData);
214
215 // else do the remote thing
216 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
217 return m_remoteConnector.UpdateAgent(destination, cAgentData);
218
219 return false;
220 209
210 return m_remoteConnector.UpdateAgent(destination, cAgentData);
221 } 211 }
222 212
223 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 213 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 04b6e3d..e2760a2 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net.Config; 33using log4net.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
36using OpenMetaverse; 35using OpenMetaverse;
37using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
38using OpenSim.Framework; 37using OpenSim.Framework;
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
index 7c5d044..898ca4a 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs
@@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray; 50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap; 51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52 52
53namespace OpenSim.Region.CoreModules.Media.Moap 53namespace OpenSim.Region.CoreModules.World.Media.Moap
54{ 54{
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")]
56 public class MoapModule : INonSharedRegionModule, IMoapModule 56 public class MoapModule : INonSharedRegionModule, IMoapModule
@@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap
225 return me; 225 return me;
226 } 226 }
227 227
228 /// <summary>
229 /// Set the media entry on the face of the given part.
230 /// </summary>
231 /// <param name="part">/param>
232 /// <param name="face"></param>
233 /// <param name="me">If null, then the media entry is cleared.</param>
228 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) 234 public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
229 { 235 {
236// m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
237
230 CheckFaceParam(part, face); 238 CheckFaceParam(part, face);
231 239
232 if (null == part.Shape.Media) 240 if (null == part.Shape.Media)
233 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); 241 {
234 242 if (me == null)
243 return;
244 else
245 part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
246 }
247
235 lock (part.Shape.Media) 248 lock (part.Shape.Media)
236 part.Shape.Media[face] = me; 249 part.Shape.Media[face] = me;
237 250
238 UpdateMediaUrl(part, UUID.Zero); 251 UpdateMediaUrl(part, UUID.Zero);
252
253 SetPartMediaFlags(part, face, me != null);
254
239 part.ScheduleFullUpdate(); 255 part.ScheduleFullUpdate();
240 part.TriggerScriptChangedEvent(Changed.MEDIA); 256 part.TriggerScriptChangedEvent(Changed.MEDIA);
241 } 257 }
242 258
259 /// <summary>
260 /// Clear the media entry from the face of the given part.
261 /// </summary>
262 /// <param name="part"></param>
263 /// <param name="face"></param>
243 public void ClearMediaEntry(SceneObjectPart part, int face) 264 public void ClearMediaEntry(SceneObjectPart part, int face)
244 { 265 {
245 SetMediaEntry(part, face, null); 266 SetMediaEntry(part, face, null);
267 }
268
269 /// <summary>
270 /// Set the media flags on the texture face of the given part.
271 /// </summary>
272 /// <remarks>
273 /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY.
274 /// </remarks>
275 /// <param name="part"></param>
276 /// <param name="face"></param>
277 /// <param name="flag"></param>
278 protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag)
279 {
280 Primitive.TextureEntry te = part.Shape.Textures;
281 Primitive.TextureEntryFace teFace = te.CreateFace((uint)face);
282 teFace.MediaFlags = flag;
283 part.Shape.Textures = te;
246 } 284 }
247 285
248 /// <summary> 286 /// <summary>
@@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
333 } 371 }
334 372
335// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); 373// m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
336 374//
337// for (int i = 0; i < omu.FaceMedia.Length; i++) 375// for (int i = 0; i < omu.FaceMedia.Length; i++)
338// { 376// {
339// MediaEntry me = omu.FaceMedia[i]; 377// MediaEntry me = omu.FaceMedia[i];
@@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
368 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get 406 // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
369 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry 407 // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
370 // directly. 408 // directly.
371 Primitive.TextureEntry te = part.Shape.Textures; 409 SetPartMediaFlags(part, i, true);
372 Primitive.TextureEntryFace face = te.CreateFace((uint)i);
373 face.MediaFlags = true;
374 part.Shape.Textures = te;
375// m_log.DebugFormat( 410// m_log.DebugFormat(
376// "[MOAP]: Media flags for face {0} is {1}", 411// "[MOAP]: Media flags for face {0} is {1}",
377// i, part.Shape.Textures.FaceTextures[i].MediaFlags); 412// i, part.Shape.Textures.FaceTextures[i].MediaFlags);
@@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap
380 } 415 }
381 else 416 else
382 { 417 {
418// m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name);
419
383 // We need to go through the media textures one at a time to make sure that we have permission 420 // We need to go through the media textures one at a time to make sure that we have permission
384 // to change them 421 // to change them
385 422
@@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap
401 if (null == media[i]) 438 if (null == media[i])
402 continue; 439 continue;
403 440
404 Primitive.TextureEntryFace face = te.CreateFace((uint)i); 441 SetPartMediaFlags(part, i, true);
405 face.MediaFlags = true;
406 442
407 // m_log.DebugFormat( 443 // m_log.DebugFormat(
408 // "[MOAP]: Media flags for face {0} is {1}", 444 // "[MOAP]: Media flags for face {0} is {1}",
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
new file mode 100644
index 0000000..5b85830
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -0,0 +1,102 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Threading;
33using log4net.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.World.Media.Moap;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43using OpenSim.Tests.Common.Setup;
44
45namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
46{
47 [TestFixture]
48 public class MoapTests
49 {
50 protected TestScene m_scene;
51 protected MoapModule m_module;
52
53 [SetUp]
54 public void SetUp()
55 {
56 m_module = new MoapModule();
57 m_scene = SceneSetupHelpers.SetupScene();
58 SceneSetupHelpers.SetupSceneModules(m_scene, m_module);
59 }
60
61 [Test]
62 public void TestClearMediaUrl()
63 {
64 TestHelper.InMethod();
65// log4net.Config.XmlConfigurator.Configure();
66
67 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
68 MediaEntry me = new MediaEntry();
69
70 m_module.SetMediaEntry(part, 1, me);
71 m_module.ClearMediaEntry(part, 1);
72
73 Assert.That(part.Shape.Media[1], Is.EqualTo(null));
74
75 // Although we've cleared one face, other faces may still be present. So we need to check for an
76 // update media url version
77 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero));
78
79 // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture.
80 // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot.
81 // Not at all confusing, eh?
82 Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null);
83 }
84
85 [Test]
86 public void TestSetMediaUrl()
87 {
88 TestHelper.InMethod();
89
90 string homeUrl = "opensimulator.org";
91
92 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene);
93 MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
94
95 m_module.SetMediaEntry(part, 1, me);
96
97 Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl));
98 Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero));
99 Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True);
100 }
101 }
102} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
index f10e848..dafaa0c 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs
@@ -30,7 +30,6 @@ using System.IO;
30using System.Xml; 30using System.Xml;
31using log4net.Config; 31using log4net.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;