aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs213
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs32
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs126
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs8
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs2
-rw-r--r--TESTING.txt81
8 files changed, 284 insertions, 210 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 7849d88..9b98de3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46 47
@@ -75,6 +76,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// The stream from which the inventory archive will be loaded. 76 /// The stream from which the inventory archive will be loaded.
76 /// </value> 77 /// </value>
77 private Stream m_loadStream; 78 private Stream m_loadStream;
79
80 protected bool m_controlFileLoaded;
81 protected bool m_assetsLoaded;
82 protected bool m_inventoryNodesLoaded;
83
84 protected int m_successfulAssetRestores;
85 protected int m_failedAssetRestores;
86 protected int m_successfulItemRestores;
87
88 /// <summary>
89 /// Root destination folder for the IAR load.
90 /// </summary>
91 protected InventoryFolderBase m_rootDestinationFolder;
92
93 /// <summary>
94 /// Inventory nodes loaded from the iar.
95 /// </summary>
96 protected HashSet<InventoryNodeBase> m_loadedNodes = new HashSet<InventoryNodeBase>();
97
98 /// <summary>
99 /// In order to load identically named folders, we need to keep track of the folders that we have already
100 /// resolved.
101 /// </summary>
102 Dictionary <string, InventoryFolderBase> m_resolvedFolders = new Dictionary<string, InventoryFolderBase>();
103
104 /// <summary>
105 /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
106 /// after OSP resolution (since OSP creators are only stored in the item
107 /// </summary>
108 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
78 109
79 public InventoryArchiveReadRequest( 110 public InventoryArchiveReadRequest(
80 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 111 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -100,20 +131,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
100 /// <summary> 131 /// <summary>
101 /// Execute the request 132 /// Execute the request
102 /// </summary> 133 /// </summary>
134 /// <remarks>
135 /// Only call this once. To load another IAR, construct another request object.
136 /// </remarks>
103 /// <returns> 137 /// <returns>
104 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are 138 /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
105 /// returned 139 /// returned
106 /// </returns> 140 /// </returns>
141 /// <exception cref="System.Exception">Thrown if load fails.</exception>
107 public HashSet<InventoryNodeBase> Execute() 142 public HashSet<InventoryNodeBase> Execute()
108 { 143 {
109 try 144 try
110 { 145 {
111 string filePath = "ERROR"; 146 string filePath = "ERROR";
112 int successfulAssetRestores = 0;
113 int failedAssetRestores = 0;
114 int successfulItemRestores = 0;
115
116 HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>();
117 147
118 List<InventoryFolderBase> folderCandidates 148 List<InventoryFolderBase> folderCandidates
119 = InventoryArchiveUtils.FindFolderByPath( 149 = InventoryArchiveUtils.FindFolderByPath(
@@ -124,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
124 // Possibly provide an option later on to automatically create this folder if it does not exist 154 // Possibly provide an option later on to automatically create this folder if it does not exist
125 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 155 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
126 156
127 return loadedNodes; 157 return m_loadedNodes;
128 } 158 }
129 159
130 InventoryFolderBase rootDestinationFolder = folderCandidates[0]; 160 m_rootDestinationFolder = folderCandidates[0];
131 archive = new TarArchiveReader(m_loadStream); 161 archive = new TarArchiveReader(m_loadStream);
132
133 // In order to load identically named folders, we need to keep track of the folders that we have already
134 // resolved
135 Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>();
136
137 byte[] data; 162 byte[] data;
138 TarArchiveReader.TarEntryType entryType; 163 TarArchiveReader.TarEntryType entryType;
139 164
@@ -142,45 +167,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
142 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 167 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
143 { 168 {
144 LoadControlFile(filePath, data); 169 LoadControlFile(filePath, data);
145 } 170 }
146 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 171 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
147 { 172 {
148 if (LoadAsset(filePath, data)) 173 LoadAssetFile(filePath, data);
149 successfulAssetRestores++;
150 else
151 failedAssetRestores++;
152
153 if ((successfulAssetRestores) % 50 == 0)
154 m_log.DebugFormat(
155 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
156 successfulAssetRestores);
157 } 174 }
158 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) 175 else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
159 { 176 {
160 filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); 177 LoadInventoryFile(filePath, entryType, data);
161
162 // Trim off the file portion if we aren't already dealing with a directory path
163 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
164 filePath = filePath.Remove(filePath.LastIndexOf("/") + 1);
165
166 InventoryFolderBase foundFolder
167 = ReplicateArchivePathToUserInventory(
168 filePath, rootDestinationFolder, resolvedFolders, loadedNodes);
169
170 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
171 {
172 InventoryItemBase item = LoadItem(data, foundFolder);
173
174 if (item != null)
175 {
176 successfulItemRestores++;
177
178 // If we aren't loading the folder containing the item then well need to update the
179 // viewer separately for that item.
180 if (!loadedNodes.Contains(foundFolder))
181 loadedNodes.Add(item);
182 }
183 }
184 } 178 }
185 } 179 }
186 180
@@ -188,10 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
188 182
189 m_log.DebugFormat( 183 m_log.DebugFormat(
190 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", 184 "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
191 successfulAssetRestores, failedAssetRestores); 185 m_successfulAssetRestores, m_failedAssetRestores);
192 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); 186 m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores);
193 187
194 return loadedNodes; 188 return m_loadedNodes;
195 } 189 }
196 finally 190 finally
197 { 191 {
@@ -404,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
404 398
405 item.CreatorIdAsUuid = ospResolvedId; 399 item.CreatorIdAsUuid = ospResolvedId;
406 400
407 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 401 // Don't preserve the OSPA in the creator id (which actually gets persisted to the
408 // database). Instead, replace with the UUID that we found. 402 // database). Instead, replace with the UUID that we found.
409 item.CreatorId = ospResolvedId.ToString(); 403 item.CreatorId = ospResolvedId.ToString();
410 404
@@ -412,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
412 } 406 }
413 else if (item.CreatorData == null || item.CreatorData == String.Empty) 407 else if (item.CreatorData == null || item.CreatorData == String.Empty)
414 { 408 {
415 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 409 item.CreatorId = m_userInfo.PrincipalID.ToString();
410 item.CreatorIdAsUuid = new UUID(item.CreatorId);
416 } 411 }
417 412
418 item.Owner = m_userInfo.PrincipalID; 413 item.Owner = m_userInfo.PrincipalID;
@@ -420,6 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
420 // Reset folder ID to the one in which we want to load it 415 // Reset folder ID to the one in which we want to load it
421 item.Folder = loadFolder.ID; 416 item.Folder = loadFolder.ID;
422 417
418 // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
419 // is loaded.
420 // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
421 // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
422 // relying on native tar tools.
423 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
424
423 m_scene.AddInventoryItem(item); 425 m_scene.AddInventoryItem(item);
424 426
425 return item; 427 return item;
@@ -448,18 +450,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
448 } 450 }
449 451
450 string extension = filename.Substring(i); 452 string extension = filename.Substring(i);
451 string uuid = filename.Remove(filename.Length - extension.Length); 453 string rawUuid = filename.Remove(filename.Length - extension.Length);
454 UUID assetId = new UUID(rawUuid);
452 455
453 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 456 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
454 { 457 {
455 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 458 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
456 459
457 if (assetType == (sbyte)AssetType.Unknown) 460 if (assetType == (sbyte)AssetType.Unknown)
458 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 461 {
462 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
463 }
464 else if (assetType == (sbyte)AssetType.Object)
465 {
466 if (m_creatorIdForAssetId.ContainsKey(assetId))
467 {
468 string xmlData = Utils.BytesToString(data);
469 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
470 foreach (SceneObjectPart sop in sog.Parts)
471 {
472 if (sop.CreatorData == null || sop.CreatorData == "")
473 {
474 sop.CreatorID = m_creatorIdForAssetId[assetId];
475 }
476 }
477
478 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
479 }
480 }
459 481
460 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 482 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
461 483
462 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); 484 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
463 asset.Data = data; 485 asset.Data = data;
464 486
465 m_scene.AssetService.Store(asset); 487 m_scene.AssetService.Store(asset);
@@ -497,7 +519,88 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
497 majorVersion, MAX_MAJOR_VERSION)); 519 majorVersion, MAX_MAJOR_VERSION));
498 } 520 }
499 521
500 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 522 m_controlFileLoaded = true;
523 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
501 } 524 }
525
526 /// <summary>
527 /// Load inventory file
528 /// </summary>
529 /// <param name="path"></param>
530 /// <param name="entryType"></param>
531 /// <param name="data"></param>
532 protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data)
533 {
534 if (!m_controlFileLoaded)
535 throw new Exception(
536 string.Format(
537 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
538 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH));
539
540 if (m_assetsLoaded)
541 throw new Exception(
542 string.Format(
543 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
544 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
545
546 path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length);
547
548 // Trim off the file portion if we aren't already dealing with a directory path
549 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
550 path = path.Remove(path.LastIndexOf("/") + 1);
551
552 InventoryFolderBase foundFolder
553 = ReplicateArchivePathToUserInventory(
554 path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes);
555
556 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
557 {
558 InventoryItemBase item = LoadItem(data, foundFolder);
559
560 if (item != null)
561 {
562 m_successfulItemRestores++;
563
564 // If we aren't loading the folder containing the item then well need to update the
565 // viewer separately for that item.
566 if (!m_loadedNodes.Contains(foundFolder))
567 m_loadedNodes.Add(item);
568 }
569 }
570
571 m_inventoryNodesLoaded = true;
572 }
573
574 /// <summary>
575 /// Load asset file
576 /// </summary>
577 /// <param name="path"></param>
578 /// <param name="data"></param>
579 protected void LoadAssetFile(string path, byte[] data)
580 {
581 if (!m_controlFileLoaded)
582 throw new Exception(
583 string.Format(
584 "The IAR you are trying to load does not list {0} before {1}. Aborting load",
585 ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH));
586
587 if (!m_inventoryNodesLoaded)
588 throw new Exception(
589 string.Format(
590 "The IAR you are trying to load does not list all {0} before {1}. Aborting load",
591 ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH));
592
593 if (LoadAsset(path, data))
594 m_successfulAssetRestores++;
595 else
596 m_failedAssetRestores++;
597
598 if ((m_successfulAssetRestores) % 50 == 0)
599 m_log.DebugFormat(
600 "[INVENTORY ARCHIVER]: Loaded {0} assets...",
601 m_successfulAssetRestores);
602
603 m_assetsLoaded = true;
604 }
502 } 605 }
503} \ No newline at end of file 606} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
index dcafc49..e5127a0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -63,17 +63,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
63 /// </summary> 63 /// </summary>
64 protected MemoryStream m_iarStream; 64 protected MemoryStream m_iarStream;
65 65
66 protected UserAccount m_ua1 66 protected UserAccount m_uaMT
67 = new UserAccount { 67 = new UserAccount {
68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), 68 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"),
69 FirstName = "Mr", 69 FirstName = "Mr",
70 LastName = "Tiddles" }; 70 LastName = "Tiddles" };
71 protected UserAccount m_ua2 71 protected UserAccount m_uaLL1
72 = new UserAccount { 72 = new UserAccount {
73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), 73 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"),
74 FirstName = "Lord", 74 FirstName = "Lord",
75 LastName = "Lucan" }; 75 LastName = "Lucan" };
76 protected UserAccount m_ua3 76 protected UserAccount m_uaLL2
77 = new UserAccount { 77 = new UserAccount {
78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), 78 PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"),
79 FirstName = "Lord", 79 FirstName = "Lord",
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
81 protected string m_item1Name = "Ray Gun Item"; 81 protected string m_item1Name = "Ray Gun Item";
82 82
83 [SetUp] 83 [SetUp]
84 public void SetUp() 84 public virtual void SetUp()
85 { 85 {
86 m_iarStream = new MemoryStream(m_iarStreamBytes); 86 m_iarStream = new MemoryStream(m_iarStreamBytes);
87 } 87 }
@@ -96,11 +96,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
96 { 96 {
97// log4net.Config.XmlConfigurator.Configure(); 97// log4net.Config.XmlConfigurator.Configure();
98 98
99 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
99 Scene scene = SceneSetupHelpers.SetupScene("Inventory"); 100 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
100 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 101 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
102
103 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
101 104
102 MemoryStream archiveWriteStream = new MemoryStream(); 105 MemoryStream archiveWriteStream = new MemoryStream();
103 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
104 106
105 // Create asset 107 // Create asset
106 SceneObjectGroup object1; 108 SceneObjectGroup object1;
@@ -129,18 +131,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
129 // Create item 131 // Create item
130 InventoryItemBase item1 = new InventoryItemBase(); 132 InventoryItemBase item1 = new InventoryItemBase();
131 item1.Name = m_item1Name; 133 item1.Name = m_item1Name;
134 item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020");
132 item1.AssetID = asset1.FullID; 135 item1.AssetID = asset1.FullID;
133 item1.GroupID = UUID.Random(); 136 item1.GroupID = UUID.Random();
134 item1.CreatorIdAsUuid = m_ua2.PrincipalID; 137 item1.CreatorIdAsUuid = m_uaLL1.PrincipalID;
135 item1.Owner = UUID.Zero; 138 item1.Owner = m_uaLL1.PrincipalID;
136 139 item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
137 string archiveItem1Name = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); 140 scene.AddInventoryItem(item1);
138 string archiveItem1Path = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItem1Name); 141
139 tar.WriteFile( 142 archiverModule.ArchiveInventory(
140 archiveItem1Path, 143 Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream);
141 UserInventoryItemSerializer.Serialize(
142 item1, new Dictionary<string, object>(), scene.UserAccountService));
143 tar.Close();
144 144
145 m_iarStreamBytes = archiveWriteStream.ToArray(); 145 m_iarStreamBytes = archiveWriteStream.ToArray();
146 } 146 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index b52014b..7f156f8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -50,7 +50,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
50{ 50{
51 [TestFixture] 51 [TestFixture]
52 public class InventoryArchiverTests : InventoryArchiveTestCase 52 public class InventoryArchiverTests : InventoryArchiveTestCase
53 { 53 {
54 protected TestScene m_scene;
55 protected InventoryArchiverModule m_archiverModule;
56
57 [SetUp]
58 public override void SetUp()
59 {
60 base.SetUp();
61
62 SerialiserModule serialiserModule = new SerialiserModule();
63 m_archiverModule = new InventoryArchiverModule();
64
65 m_scene = SceneSetupHelpers.SetupScene("Inventory");
66 SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
67 }
68
54 /// <summary> 69 /// <summary>
55 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive 70 /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive
56 /// (subject to change since there is no fixed format yet). 71 /// (subject to change since there is no fixed format yet).
@@ -61,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
61 TestHelper.InMethod(); 76 TestHelper.InMethod();
62// log4net.Config.XmlConfigurator.Configure(); 77// log4net.Config.XmlConfigurator.Configure();
63 78
64 InventoryArchiverModule archiverModule = new InventoryArchiverModule();
65
66 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
67 SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
68
69 // Create user 79 // Create user
70 string userFirstName = "Jock"; 80 string userFirstName = "Jock";
71 string userLastName = "Stirrup"; 81 string userLastName = "Stirrup";
72 string userPassword = "troll"; 82 string userPassword = "troll";
73 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 83 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
74 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); 84 UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
75 85
76 // Create asset 86 // Create asset
77 SceneObjectGroup object1; 87 SceneObjectGroup object1;
@@ -90,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
90 part1.Name = partName; 100 part1.Name = partName;
91 101
92 object1 = new SceneObjectGroup(part1); 102 object1 = new SceneObjectGroup(part1);
93 scene.AddNewSceneObject(object1, false); 103 m_scene.AddNewSceneObject(object1, false);
94 } 104 }
95 105
96 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 106 UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
97 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); 107 AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
98 scene.AssetService.Store(asset1); 108 m_scene.AssetService.Store(asset1);
99 109
100 // Create item 110 // Create item
101 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); 111 UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
@@ -105,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
105 item1.AssetID = asset1.FullID; 115 item1.AssetID = asset1.FullID;
106 item1.ID = item1Id; 116 item1.ID = item1Id;
107 InventoryFolderBase objsFolder 117 InventoryFolderBase objsFolder
108 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; 118 = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
109 item1.Folder = objsFolder.ID; 119 item1.Folder = objsFolder.ID;
110 scene.AddInventoryItem(item1); 120 m_scene.AddInventoryItem(item1);
111 121
112 MemoryStream archiveWriteStream = new MemoryStream(); 122 MemoryStream archiveWriteStream = new MemoryStream();
113 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 123 m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
114 124
115 mre.Reset(); 125 mre.Reset();
116 archiverModule.ArchiveInventory( 126 m_archiverModule.ArchiveInventory(
117 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); 127 Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream);
118 mre.WaitOne(60000, false); 128 mre.WaitOne(60000, false);
119 129
@@ -169,6 +179,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
169 } 179 }
170 180
171 /// <summary> 181 /// <summary>
182 /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
183 /// objects.
184 /// </summary>
185 [Test]
186 public void TestLoadIarCreatorAccountPresent()
187 {
188 TestHelper.InMethod();
189// log4net.Config.XmlConfigurator.Configure();
190
191 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
192
193 m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
194 InventoryItemBase foundItem1
195 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
196
197 Assert.That(
198 foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
199 "Loaded item non-uuid creator doesn't match original");
200 Assert.That(
201 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
202 "Loaded item uuid creator doesn't match original");
203 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
204 "Loaded item owner doesn't match inventory reciever");
205
206 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
207 string xmlData = Utils.BytesToString(asset1.Data);
208 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
209
210 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
211 }
212
213 /// <summary>
172 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where 214 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
173 /// an account exists with the same name as the creator, though not the same id. 215 /// an account exists with the same name as the creator, though not the same id.
174 /// </summary> 216 /// </summary>
@@ -177,35 +219,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
177 { 219 {
178 TestHelper.InMethod(); 220 TestHelper.InMethod();
179// log4net.Config.XmlConfigurator.Configure(); 221// 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 222
189 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 223 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
190 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua3, "hampshire"); 224 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
191 225
192 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 226 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
193 InventoryItemBase foundItem1 227 InventoryItemBase foundItem1
194 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 228 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
195 229
196// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
197// UUID, not the OSPA itself.
198// Assert.That(
199// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
200// "Loaded item non-uuid creator doesn't match original");
201 Assert.That( 230 Assert.That(
202 foundItem1.CreatorId, Is.EqualTo(m_ua3.PrincipalID.ToString()), 231 foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
203 "Loaded item non-uuid creator doesn't match original"); 232 "Loaded item non-uuid creator doesn't match original");
204 Assert.That( 233 Assert.That(
205 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua3.PrincipalID), 234 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
206 "Loaded item uuid creator doesn't match original"); 235 "Loaded item uuid creator doesn't match original");
207 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 236 Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
208 "Loaded item owner doesn't match inventory reciever"); 237 "Loaded item owner doesn't match inventory reciever");
238
239 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
240 string xmlData = Utils.BytesToString(asset1.Data);
241 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
242
243 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
209 } 244 }
210 245
211 /// <summary> 246 /// <summary>
@@ -218,24 +253,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
218 TestHelper.InMethod(); 253 TestHelper.InMethod();
219// log4net.Config.XmlConfigurator.Configure(); 254// log4net.Config.XmlConfigurator.Configure();
220 255
221 SerialiserModule serialiserModule = new SerialiserModule(); 256 UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password");
222 InventoryArchiverModule archiverModule = new InventoryArchiverModule(); 257 m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
223 Scene scene = SceneSetupHelpers.SetupScene("inventory");
224 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
225
226 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password");
227 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "password", m_iarStream);
228 258
229 InventoryItemBase foundItem1 259 InventoryItemBase foundItem1
230 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 260 = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
231 261
232 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); 262 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
233// Assert.That(
234// foundItem1.CreatorId, Is.EqualTo(userUuid),
235// "Loaded item non-uuid creator doesn't match that of the loading user");
236 Assert.That( 263 Assert.That(
237 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua1.PrincipalID), 264 foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
265 "Loaded item non-uuid creator doesn't match that of the loading user");
266 Assert.That(
267 foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
238 "Loaded item uuid creator doesn't match that of the loading user"); 268 "Loaded item uuid creator doesn't match that of the loading user");
269
270 AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
271 string xmlData = Utils.BytesToString(asset1.Data);
272 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
273
274 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
239 } 275 }
240 } 276 }
241} \ No newline at end of file 277} \ 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
index 1220a70..0e8f647 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs
@@ -84,9 +84,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); 84 Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
85 Vector3 offsetPosition = new Vector3(5, 10, 15); 85 Vector3 offsetPosition = new Vector3(5, 10, 15);
86 86
87 part1 87 part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
88 = new SceneObjectPart(
89 ownerId, shape, groupPosition, rotationOffset, offsetPosition);
90 part1.Name = partName; 88 part1.Name = partName;
91 89
92 object1 = new SceneObjectGroup(part1); 90 object1 = new SceneObjectGroup(part1);
@@ -186,31 +184,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
186 184
187 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 185 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
188 186
189 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 187 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood");
190 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 188 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");
191 189
192 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); 190 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
193 InventoryItemBase foundItem1 191 InventoryItemBase foundItem1
194 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); 192 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
195 193
196 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");
197 195
198 // Now try loading to a root child folder 196 // Now try loading to a root child folder
199 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA"); 197 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
200 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); 198 MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
201 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream); 199 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);
202 200
203 InventoryItemBase foundItem2 201 InventoryItemBase foundItem2
204 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name); 202 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);
205 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); 203 Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
206 204
207 // Now try loading to a more deeply nested folder 205 // Now try loading to a more deeply nested folder
208 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC"); 206 UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
209 archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); 207 archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
210 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream); 208 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);
211 209
212 InventoryItemBase foundItem3 210 InventoryItemBase foundItem3
213 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name); 211 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);
214 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); 212 Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
215 } 213 }
216 214
@@ -228,12 +226,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
228 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 226 Scene scene = SceneSetupHelpers.SetupScene("inventory");
229 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 227 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
230 228
231 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); 229 UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password");
232 archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); 230 archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream);
233 231
234 InventoryItemBase foundItem1 232 InventoryItemBase foundItem1
235 = InventoryArchiveUtils.FindItemByPath( 233 = InventoryArchiveUtils.FindItemByPath(
236 scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); 234 scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name);
237 235
238 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); 236 Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()");
239 } 237 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 334dcb0..282e4f1 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
113 data = new MapBlockData(); 113 data = new MapBlockData();
114 data.Agents = 0; 114 data.Agents = 0;
115 data.Access = info.Access; 115 data.Access = info.Access;
116 data.MapImageId = info.TerrainImage; 116 data.MapImageId = UUID.Zero; // could use info.TerrainImage but it seems to break viewer2
117 data.Name = info.RegionName; 117 data.Name = info.RegionName;
118 data.RegionFlags = 0; // TODO not used? 118 data.RegionFlags = 0; // TODO not used?
119 data.WaterHeight = 0; // not used 119 data.WaterHeight = 0; // not used
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 7e59b10..854f1dc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1287,9 +1287,13 @@ namespace OpenSim.Region.Framework.Scenes
1287 1287
1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs) 1288 public Dictionary<UUID, string> GetScriptStates(bool oldIDs)
1289 { 1289 {
1290 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1291
1292 if (m_part.ParentGroup.Scene == null) // Group not in a scene
1293 return ret;
1294
1290 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 1295 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1291 1296
1292 Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
1293 if (engines == null) // No engine at all 1297 if (engines == null) // No engine at all
1294 return ret; 1298 return ret;
1295 1299
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 8647cfe..ff4423f 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Tests.Common
68 return CreateAsset( 68 return CreateAsset(
69 assetUuid, 69 assetUuid,
70 AssetType.Object, 70 AssetType.Object,
71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)), 71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
72 sog.OwnerID); 72 sog.OwnerID);
73 } 73 }
74 74
diff --git a/TESTING.txt b/TESTING.txt
index e0a7748..54fc976 100644
--- a/TESTING.txt
+++ b/TESTING.txt
@@ -2,23 +2,14 @@
2 2
3== Running Tests == 3== Running Tests ==
4 4
5On Linux: 5On Linux you will need to have NUnit installed (http://www.nunit.org).
6This is commonly available in distribution package repositories.
6 7
7 > nant test 8When this is installed, run the command
8
9This will print out to the console the test state.
10
11On Windows: Please see the TESTING ON WINDOWS section below.
12 9
10 > nant test
13 11
14Also, every checkin will run tests that are kicked off by bamboo. 12Please see the TESTING ON WINDOWS section below for Windows instructions.
15Results are posted here: http://www.opensimulator.org:8085/ as well as
16to #opensim-dev IRC channel.
17
18== Writing Tests ==
19
20Tests are written to run under NUnit. For more information on NUnit
21please see: http://www.nunit.org/index.php
22 13
23== Adding Tests == 14== Adding Tests ==
24 15
@@ -32,70 +23,15 @@ that if you are writing tests they end up in a "Tests" sub-directory
32of the directory where the code you are testing resides. 23of the directory where the code you are testing resides.
33 24
34If you have added a new test assembly that hasn't existed before you 25If you have added a new test assembly that hasn't existed before you
35must list it in both ".nant/local.include" and ".nant/bamboo.build" 26must list it in both ".nant/local.include"
36for it to be accessible to Linux users and to the continuous 27for it to be accessible to Linux users and to the continuous
37integration system. 28integration system.
38 29
39
40=== The Gory Details ===
41The following is the original document which started off this
42document. It should probably be better integrated with the new info.
43
44==UPDATE==
45
46The text immediately following is an update to the testing documentation. The
47update is written on 2008.08.30 and is copied from an email to the opensim-dev
48mailing list[1]. The information below the update, beginning with the section
49titled TESTING, is still relevant, so please read this document in its
50entirety.
51
52Mike Mazur
53
54[1] https://lists.berlios.de/pipermail/opensim-dev/2008-August/002695.html
55
56"""
57The tests are contained in certain DLLs. At the time of writing, these DLLs
58have tests in them:
59
60OpenSim.Region.ScriptEngine.Common.Tests.dll
61OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests.dll
62OpenSim.Region.ScriptEngine.Shared.Tests.dll
63OpenSim.Framework.Tests.dll OpenSim.Region.CoreModules.dll
64OpenSim.Region.Physics.OdePlugin.dll[2]
65
66The console command used to run the tests is `nunit-console` (or
67`nunit-console2` on some systems). This command takes a listing of DLLs to
68inspect for tests.
69
70Currently Bamboo's[3] build file (.nant/bamboo.build) lists only those DLLs
71for nunit-console to use. However it would be equally correct to simply pass
72in all DLLs in bin/; those without tests are just skipped.
73
74The nunit-console command generates a file TestResults.txt by default. This is
75an XML file containing a listing of all DLLs inspected, tests executed,
76successes, failures, etc. If nunit-console is passed in all DLLs in bin/, this
77file bloats with lots of entries like this:
78
79 <test-suite name="/home/mike/source/workspace/bin/OpenSim.Grid.Communications.OGS1.dll" success="True" time="0.000" asserts="0">
80 <results />
81 </test-suite>
82 <test-suite name="/home/mike/source/workspace/bin/OpenSim.Region.ClientStack.dll" success="True" time="0.000" asserts="0">
83 <results />
84 </test-suite>
85
86Therefore it makes more sense to me to specify the DLLs when running
87nunit-console.
88
89[2] Note that OpenSim.Region.Physics.OdePlugin.dll is in bin/Physics/ and
90needs to be first copied to bin/ before nunit-console is executed.
91[3] http://opensimulator.org:8085/
92"""
93
94==TESTING ON WINDOWS== 30==TESTING ON WINDOWS==
95 31
96To use nunit testing on opensim code, you have a variety of methods. The 32To use nunit testing on opensim code, you have a variety of methods. The
97easiast methods involve using IDE capabilities to test code. Using 33easiast methods involve using IDE capabilities to test code. Using
98VS2005/2008 I recommend using the testing capabilities of Resarper(commercial) 34VS2005/2008 I recommend using the testing capabilities of Resharper(commercial)
99or TestDriven.Net(free). Both will recognize nunit tests within your 35or TestDriven.Net(free). Both will recognize nunit tests within your
100application and allow you to test them individually, or all at once, etc. You 36application and allow you to test them individually, or all at once, etc. You
101will also be able to step into debug mode into a test through these add-ins 37will also be able to step into debug mode into a test through these add-ins
@@ -133,6 +69,3 @@ Example
133 69
134nunit-console2 OpenSim.Framework.Tests.dll (on linux) 70nunit-console2 OpenSim.Framework.Tests.dll (on linux)
135nunit-console OpenSim.Framework.Tests.dll (on windows) 71nunit-console OpenSim.Framework.Tests.dll (on windows)
136
137For more information on testing contact the autor of this testing readme: Daedius Moskvitch ( daedius @@@@ daedius com)
138