29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Threading;
35 using NUnit.Framework;
37 using OpenMetaverse.Assets;
38 using OpenSim.Framework;
39 using OpenSim.Framework.Serialization;
40 using OpenSim.Framework.Serialization.External;
41 using OpenSim.Region.CoreModules.World.Land;
42 using OpenSim.Region.CoreModules.World.Serialiser;
43 using OpenSim.Region.CoreModules.World.Terrain;
44 using OpenSim.Region.Framework.Scenes;
45 using OpenSim.Region.Framework.Scenes.Serialization;
46 using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
47 using OpenSim.Tests.Common;
52 using OpenSim.Region.Framework.Interfaces;
59 private Guid m_lastRequestId;
60 private string m_lastErrorMessage;
69 private AutoResetEvent m_oarEvent =
new AutoResetEvent(
false);
81 m_scene = m_sceneHelpers.SetupScene();
82 SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, m_serialiserModule, terrainModule);
85 private void LoadCompleted(Guid requestId, List<UUID> loadedScenes,
string errorMessage)
89 m_lastRequestId = requestId;
90 m_lastErrorMessage = errorMessage;
91 Console.WriteLine(
"About to pulse ArchiverTests on LoadCompleted");
96 private void SaveCompleted(Guid requestId,
string errorMessage)
100 m_lastRequestId = requestId;
101 m_lastErrorMessage = errorMessage;
102 Console.WriteLine(
"About to pulse ArchiverTests on SaveCompleted");
109 string partName =
"My Little Pony";
110 UUID ownerId = UUID.Parse(
"00000000-0000-0000-0000-000000000015");
112 Vector3 groupPosition =
new Vector3(10, 20, 30);
113 Quaternion rotationOffset =
new Quaternion(20, 30, 40, 50);
114 rotationOffset.Normalize();
117 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName };
122 string partName =
"Action Man";
123 UUID ownerId = UUID.Parse(
"00000000-0000-0000-0000-000000000016");
125 Vector3 groupPosition =
new Vector3(90, 80, 70);
126 Quaternion rotationOffset =
new Quaternion(60, 70, 80, 90);
127 rotationOffset.Normalize();
128 Vector3 offsetPosition =
new Vector3(20, 25, 30);
130 return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName };
137 scene.AddNewSceneObject(sog1,
false);
139 AssetNotecard nc =
new AssetNotecard();
140 nc.BodyText =
"Hello World!";
142 ncAssetUuid = UUID.Random();
143 UUID ncItemUuid = UUID.Random();
145 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
146 m_scene.AssetService.Store(ncAsset);
149 =
new TaskInventoryItem { Name =
"ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
152 part2.Inventory.AddInventoryItem(ncItem,
true);
154 scene.AddNewSceneObject(sog2,
false);
157 private static void CreateSoundAsset(
TarArchiveWriter tar, Assembly assembly,
string soundDataResourceName, out byte[] soundData, out UUID soundUuid)
159 using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
161 using (BinaryReader br =
new BinaryReader(resource))
164 soundData = br.ReadBytes(99999999);
165 soundUuid = UUID.Parse(
"00000000-0000-0000-0000-000000000001");
166 string soundAssetFileName
167 = ArchiveConstants.ASSETS_PATH + soundUuid
168 + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
169 tar.
WriteFile(soundAssetFileName, soundData);
186 TestHelpers.InMethod();
192 CreateTestObjects(m_scene, out sog1, out sog2, out ncAssetUuid);
194 MemoryStream archiveWriteStream =
new MemoryStream();
195 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
197 Guid requestId =
new Guid(
"00000000-0000-0000-0000-808080808080");
200 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId);
205 m_oarEvent.WaitOne(60000);
207 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
209 byte[] archive = archiveWriteStream.ToArray();
210 MemoryStream archiveReadStream =
new MemoryStream(archive);
213 bool gotNcAssetFile =
false;
215 string expectedNcAssetFileName = string.Format(
"{0}_{1}", ncAssetUuid,
"notecard.txt");
217 List<string> foundPaths =
new List<string>();
218 List<string> expectedPaths =
new List<string>();
219 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1));
220 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2));
223 TarArchiveReader.TarEntryType tarEntryType;
225 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
226 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
228 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
232 Assert.That(arr.ControlFileLoaded, Is.True);
234 while (tar.
ReadEntry(out filePath, out tarEntryType) != null)
238 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
240 Assert.That(fileName, Is.EqualTo(expectedNcAssetFileName));
241 gotNcAssetFile =
true;
245 foundPaths.Add(filePath);
249 Assert.That(gotNcAssetFile, Is.True,
"No notecard asset file in archive");
250 Assert.That(foundPaths, Is.EquivalentTo(expectedPaths));
261 TestHelpers.InMethod();
266 m_scene.AddNewSceneObject(sog1,
false);
270 AssetNotecard nc =
new AssetNotecard();
271 nc.BodyText =
"Hello World!";
273 UUID ncAssetUuid =
new UUID(
"00000000-0000-0000-1000-000000000000");
274 UUID ncItemUuid =
new UUID(
"00000000-0000-0000-1100-000000000000");
276 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
277 m_scene.AssetService.Store(ncAsset);
280 =
new TaskInventoryItem { Name =
"ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
281 part2.Inventory.AddInventoryItem(ncItem,
true);
283 m_scene.AddNewSceneObject(sog2,
false);
285 MemoryStream archiveWriteStream =
new MemoryStream();
287 Guid requestId =
new Guid(
"00000000-0000-0000-0000-808080808080");
289 Dictionary<string, Object>
options =
new Dictionary<string, Object>();
290 options.Add(
"noassets",
true);
292 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId,
options);
297 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
299 byte[] archive = archiveWriteStream.ToArray();
300 MemoryStream archiveReadStream =
new MemoryStream(archive);
303 List<string> foundPaths =
new List<string>();
304 List<string> expectedPaths =
new List<string>();
305 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1));
306 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2));
309 TarArchiveReader.TarEntryType tarEntryType;
311 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
312 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
314 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
318 Assert.That(arr.ControlFileLoaded, Is.True);
320 while (tar.
ReadEntry(out filePath, out tarEntryType) != null)
324 Assert.Fail(
"Asset was found in saved oar of TestSaveOarNoAssets()");
328 foundPaths.Add(filePath);
332 Assert.That(foundPaths, Is.EquivalentTo(expectedPaths));
343 TestHelpers.InMethod();
346 MemoryStream archiveWriteStream =
new MemoryStream();
350 tar.WriteDir(
"ignoreme");
354 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
357 ArchiveConstants.CONTROL_FILE_PATH,
361 part1.SitTargetOrientation =
new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
362 part1.SitTargetPosition =
new Vector3(1, 2, 3);
367 string soundItemName =
"sound-item1";
368 UUID soundItemUuid = UUID.Parse(
"00000000-0000-0000-0000-000000000002");
369 Type type = GetType();
370 Assembly assembly = type.Assembly;
371 string soundDataResourceName = null;
372 string[] names = assembly.GetManifestResourceNames();
373 foreach (
string name
in names)
375 if (name.EndsWith(
".Resources.test-sound.wav"))
376 soundDataResourceName = name;
378 Assert.That(soundDataResourceName, Is.Not.Null);
382 CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);
385 =
new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
386 part1.Inventory.AddInventoryItem(item1,
true);
387 m_scene.AddNewSceneObject(object1,
false);
389 string object1FileName = string.Format(
390 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
392 Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
394 tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
398 MemoryStream archiveReadStream =
new MemoryStream(archiveWriteStream.ToArray());
400 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
402 m_archiverModule.DearchiveRegion(archiveReadStream);
404 m_oarEvent.WaitOne(60000);
406 Assert.That(m_lastErrorMessage, Is.Null);
408 TestLoadedRegion(part1, soundItemName, soundData);
418 TestHelpers.InMethod();
420 UUID ownerId = TestHelpers.ParseTail(0xaaaa);
422 MemoryStream archiveWriteStream =
new MemoryStream();
426 ArchiveConstants.CONTROL_FILE_PATH,
429 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId,
"obj1-", 0x11);
431 = SceneHelpers.CreateSceneObjectPart(
"obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
433 = SceneHelpers.CreateSceneObjectPart(
"obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);
442 ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
447 MemoryStream archiveReadStream =
new MemoryStream(archiveWriteStream.ToArray());
449 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
451 m_archiverModule.DearchiveRegion(archiveReadStream);
453 m_oarEvent.WaitOne(60000);
455 Assert.That(m_lastErrorMessage, Is.Null);
458 Assert.That(part2.LinkNum, Is.EqualTo(2));
461 Assert.That(part3.LinkNum, Is.EqualTo(3));
470 TestHelpers.InMethod();
475 m_scene.AddNewSceneObject(sog1,
false);
479 AssetNotecard nc =
new AssetNotecard();
480 nc.BodyText =
"Hello World!";
482 UUID ncAssetUuid =
new UUID(
"00000000-0000-0000-1000-000000000000");
483 UUID ncItemUuid =
new UUID(
"00000000-0000-0000-1100-000000000000");
485 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
486 m_scene.AssetService.Store(ncAsset);
489 =
new TaskInventoryItem { Name =
"ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
490 part2.Inventory.AddInventoryItem(ncItem,
true);
492 m_scene.AddNewSceneObject(sog2,
false);
494 MemoryStream archiveWriteStream =
new MemoryStream();
495 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
497 Guid requestId =
new Guid(
"00000000-0000-0000-0000-808080808080");
500 m_archiverModule.ArchiveRegion(
501 archiveWriteStream, requestId,
new Dictionary<string, Object>() { {
"wipe-owners", Boolean.TrueString } });
503 m_oarEvent.WaitOne(60000);
505 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
507 byte[] archive = archiveWriteStream.ToArray();
508 MemoryStream archiveReadStream =
new MemoryStream(archive);
511 UUID estateOwner = TestHelpers.ParseTail(0x4747);
512 UUID objectOwner = TestHelpers.ParseTail(0x15);
520 TestScene scene2 = m_sceneHelpers2.SetupScene();
521 SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule);
525 UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner);
527 scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;
529 scene2.EventManager.OnOarFileLoaded += LoadCompleted;
531 archiverModule.DearchiveRegion(archiveReadStream);
533 m_oarEvent.WaitOne(60000);
535 Assert.That(m_lastErrorMessage, Is.Null);
538 Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner));
539 Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner));
552 TestHelpers.InMethod();
555 UUID landID = TestHelpers.ParseTail(0x10);
559 IConfigSource configSource =
new IniConfigSource();
560 IConfig config = configSource.AddConfig(
"Groups");
561 config.Set(
"Enabled",
true);
562 config.Set(
"Module",
"GroupsModule");
563 config.Set(
"DebugEnabled",
true);
564 SceneHelpers.SetupSceneModules(
570 = groupsService.CreateGroup(UUID.Zero,
"group1",
"",
true, UUID.Zero, 3,
true,
true,
true, UUID.Zero);
573 MemoryStream oarStream =
new MemoryStream();
576 tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
578 ArchiveConstants.CONTROL_FILE_PATH,
582 lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
584 ld.GlobalID = landID;
586 string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
587 Dictionary<string, object>
options =
new Dictionary<string, object>();
588 tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld,
options));
591 oarStream =
new MemoryStream(oarStream.ToArray());
594 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
596 m_archiverModule.DearchiveRegion(oarStream);
598 m_oarEvent.WaitOne(60000);
600 ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
603 Assert.That(rLd.GlobalID, Is.EqualTo(landID));
604 Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
605 Assert.That(rLd.GroupID, Is.EqualTo(groupID));
606 Assert.That(rLd.IsGroupOwned, Is.EqualTo(
true));
615 TestHelpers.InMethod();
618 MemoryStream archiveWriteStream =
new MemoryStream();
621 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
623 ArchiveConstants.CONTROL_FILE_PATH,
628 rs.AllowDamage =
true;
629 rs.AllowLandJoinDivide =
true;
630 rs.AllowLandResell =
true;
632 rs.BlockShowInSearch =
true;
633 rs.BlockTerraform =
true;
634 rs.DisableCollisions =
true;
635 rs.DisablePhysics =
true;
636 rs.DisableScripts =
true;
637 rs.Elevation1NW = 15.9;
638 rs.Elevation1NE = 45.3;
639 rs.Elevation1SE = 49;
640 rs.Elevation1SW = 1.9;
641 rs.Elevation2NW = 4.5;
642 rs.Elevation2NE = 19.2;
643 rs.Elevation2SE = 9.2;
644 rs.Elevation2SW = 2.1;
646 rs.SunPosition = 12.0;
647 rs.ObjectBonus = 1.4;
648 rs.RestrictPushing =
true;
649 rs.TerrainLowerLimit = 0.4;
650 rs.TerrainRaiseLimit = 17.9;
651 rs.TerrainTexture1 = UUID.Parse(
"00000000-0000-0000-0000-000000000020");
652 rs.TerrainTexture2 = UUID.Parse(
"00000000-0000-0000-0000-000000000040");
653 rs.TerrainTexture3 = UUID.Parse(
"00000000-0000-0000-0000-000000000060");
654 rs.TerrainTexture4 = UUID.Parse(
"00000000-0000-0000-0000-000000000080");
655 rs.UseEstateSun =
true;
657 rs.TelehubObject = UUID.Parse(
"00000000-0000-0000-0000-111111111111");
658 rs.AddSpawnPoint(SpawnPoint.Parse(
"1,-2,0.33"));
660 tar.WriteFile(ArchiveConstants.SETTINGS_PATH +
"region1.xml", RegionSettingsSerializer.Serialize(rs));
664 MemoryStream archiveReadStream =
new MemoryStream(archiveWriteStream.ToArray());
666 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
668 m_archiverModule.DearchiveRegion(archiveReadStream);
670 m_oarEvent.WaitOne(60000);
672 Assert.That(m_lastErrorMessage, Is.Null);
675 Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
676 Assert.That(loadedRs.AllowDamage, Is.True);
677 Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
678 Assert.That(loadedRs.AllowLandResell, Is.True);
679 Assert.That(loadedRs.BlockFly, Is.True);
680 Assert.That(loadedRs.BlockShowInSearch, Is.True);
681 Assert.That(loadedRs.BlockTerraform, Is.True);
682 Assert.That(loadedRs.DisableCollisions, Is.True);
683 Assert.That(loadedRs.DisablePhysics, Is.True);
684 Assert.That(loadedRs.DisableScripts, Is.True);
685 Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
686 Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
687 Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
688 Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
689 Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
690 Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
691 Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
692 Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
693 Assert.That(loadedRs.FixedSun, Is.True);
694 Assert.AreEqual(12.0, loadedRs.SunPosition);
695 Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
696 Assert.That(loadedRs.RestrictPushing, Is.True);
697 Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
698 Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
699 Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse(
"00000000-0000-0000-0000-000000000020")));
700 Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse(
"00000000-0000-0000-0000-000000000040")));
701 Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse(
"00000000-0000-0000-0000-000000000060")));
702 Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse(
"00000000-0000-0000-0000-000000000080")));
703 Assert.That(loadedRs.UseEstateSun, Is.True);
704 Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
705 Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject);
706 Assert.AreEqual(0, loadedRs.SpawnPoints().Count);
715 TestHelpers.InMethod();
718 MemoryStream archiveWriteStream =
new MemoryStream();
734 Scene scene = m_sceneHelpers.SetupScene();
735 SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
741 scene.EventManager.OnOarFileSaved += SaveCompleted;
743 m_archiverModule.ArchiveRegion(archiveWriteStream);
745 m_oarEvent.WaitOne(60000);
753 byte[] archive = archiveWriteStream.ToArray();
754 MemoryStream archiveReadStream =
new MemoryStream(archive);
756 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
757 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
758 archiveOptions.Add(
"merge", null);
760 m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
762 m_oarEvent.WaitOne(60000);
764 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
765 Assert.That(object1Existing, Is.Not.Null,
"object1 was not present after merge");
766 Assert.That(object1Existing.Name, Is.EqualTo(part1.Name),
"object1 names not identical after merge");
767 Assert.That(object1Existing.GroupPosition, Is.EqualTo(part1.GroupPosition),
"object1 group position not equal after merge");
769 SceneObjectPart object2PartMerged = m_scene.GetSceneObjectPart(part2.Name);
770 Assert.That(object2PartMerged, Is.Not.Null,
"object2 was not present after merge");
771 Assert.That(object2PartMerged.Name, Is.EqualTo(part2.Name),
"object2 names not identical after merge");
772 Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2.GroupPosition),
"object2 group position not equal after merge");
782 TestHelpers.InMethod();
789 List<Scene> scenes =
new List<Scene>();
792 Dictionary<string, Scene> regionPaths =
new Dictionary<string, Scene>();
795 Dictionary<UUID, List<string>> expectedPaths =
new Dictionary<UUID, List<string>>();
798 List<UUID> expectedAssets =
new List<UUID>();
800 for (uint y = 0; y < HEIGHT; y++)
802 for (uint x = 0; x < WIDTH; x++)
805 if (x == 0 && y == 0)
811 scene = m_sceneHelpers.SetupScene(string.Format(
"Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y);
816 string dir = String.Format(
"{0}_{1}_{2}", x + 1, y + 1, scene.RegionInfo.RegionName.Replace(
" ",
"_"));
817 regionPaths[dir] = scene;
823 CreateTestObjects(scene, out sog1, out sog2, out ncAssetUuid);
825 expectedPaths[scene.RegionInfo.RegionID] =
new List<string>();
826 expectedPaths[scene.RegionInfo.RegionID].Add(ArchiveHelpers.CreateObjectPath(sog1));
827 expectedPaths[scene.RegionInfo.RegionID].Add(ArchiveHelpers.CreateObjectPath(sog2));
829 expectedAssets.Add(ncAssetUuid);
834 MemoryStream archiveWriteStream =
new MemoryStream();
836 Guid requestId =
new Guid(
"00000000-0000-0000-0000-808080808080");
838 Dictionary<string, Object>
options =
new Dictionary<string, Object>();
839 options.Add(
"all",
true);
841 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
843 m_archiverModule.ArchiveRegion(archiveWriteStream, requestId,
options);
845 m_oarEvent.WaitOne(60000);
849 Assert.That(m_lastRequestId, Is.EqualTo(requestId));
851 byte[] archive = archiveWriteStream.ToArray();
852 MemoryStream archiveReadStream =
new MemoryStream(archive);
855 Dictionary<UUID, List<string>> foundPaths =
new Dictionary<UUID, List<string>>();
856 List<UUID> foundAssets =
new List<UUID>();
858 foreach (
Scene scene
in scenes)
860 foundPaths[scene.RegionInfo.RegionID] =
new List<string>();
864 TarArchiveReader.TarEntryType tarEntryType;
866 byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
867 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
869 Dictionary<string, object> archiveOptions =
new Dictionary<string, object>();
873 Assert.That(arr.ControlFileLoaded, Is.True);
875 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
880 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
881 if (fileName.EndsWith(
"_notecard.txt"))
882 foundAssets.Add(
UUID.Parse(fileName.Substring(0, fileName.Length -
"_notecard.txt".Length)));
887 Assert.IsTrue(filePath.StartsWith(ArchiveConstants.REGIONS_PATH));
888 string[] parts = filePath.Split(
new Char[] {
'/' }, 3);
889 Assert.AreEqual(3, parts.Length);
890 string regionDirectory = parts[1];
891 string relativePath = parts[2];
892 Scene scene = regionPaths[regionDirectory];
896 foundPaths[scene.RegionInfo.RegionID].Add(relativePath);
901 Assert.AreEqual(scenes.Count, foundPaths.Count);
902 foreach (
Scene scene
in scenes)
904 Assert.That(foundPaths[scene.RegionInfo.RegionID], Is.EquivalentTo(expectedPaths[scene.RegionInfo.RegionID]));
907 Assert.That(foundAssets, Is.EquivalentTo(expectedAssets));
916 TestHelpers.InMethod();
923 for (uint y = 0; y < HEIGHT; y++)
925 for (uint x = 0; x < WIDTH; x++)
928 if (x == 0 && y == 0)
934 scene = m_sceneHelpers.SetupScene(string.Format(
"Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y);
941 m_sceneHelpers.SceneManager.ForEachScene(delegate(
Scene scene)
943 scenesGroup.AddScene(scene);
945 scenesGroup.CalcSceneLocations();
949 MemoryStream archiveWriteStream =
new MemoryStream();
953 writeRequest.MultiRegionFormat =
true;
955 ArchiveConstants.CONTROL_FILE_PATH, writeRequest.CreateControlFile(scenesGroup));
958 part1.SitTargetOrientation =
new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
959 part1.SitTargetPosition =
new Vector3(1, 2, 3);
964 string soundItemName =
"sound-item1";
965 UUID soundItemUuid = UUID.Parse(
"00000000-0000-0000-0000-000000000002");
966 Type type = GetType();
967 Assembly assembly = type.Assembly;
968 string soundDataResourceName = null;
969 string[] names = assembly.GetManifestResourceNames();
970 foreach (
string name
in names)
972 if (name.EndsWith(
".Resources.test-sound.wav"))
973 soundDataResourceName = name;
975 Assert.That(soundDataResourceName, Is.Not.Null);
979 CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);
982 =
new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
983 part1.Inventory.AddInventoryItem(item1,
true);
984 m_scene.AddNewSceneObject(object1,
false);
986 string object1FileName = string.Format(
987 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
989 Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
991 string path =
"regions/1_1_Unit_test_region/" + ArchiveConstants.OBJECTS_PATH + object1FileName;
992 tar.WriteFile(path, SceneObjectSerializer.ToXml2Format(object1));
999 m_sceneHelpers.SceneManager.ForEachScene(delegate(
Scene scene)
1001 scene.DeleteAllSceneObjects();
1005 m_sceneHelpers.SceneManager.CloseScene(SceneManager.Instance.Scenes[1]);
1010 MemoryStream archiveReadStream =
new MemoryStream(archiveWriteStream.ToArray());
1012 m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
1014 m_archiverModule.DearchiveRegion(archiveReadStream);
1016 m_oarEvent.WaitOne(60000);
1018 Assert.That(m_lastErrorMessage, Is.Null);
1020 Assert.AreEqual(3, m_sceneHelpers.SceneManager.Scenes.Count);
1022 TestLoadedRegion(part1, soundItemName, soundData);
1025 private void TestLoadedRegion(
SceneObjectPart part1,
string soundItemName, byte[] soundData)
1027 SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);
1029 Assert.That(object1PartLoaded, Is.Not.Null,
"object1 was not loaded");
1030 Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name),
"object1 names not identical");
1031 Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition),
"object1 group position not equal");
1033 Quaternion qtmp1 =
new Quaternion (
1034 (
float)Math.Round(object1PartLoaded.RotationOffset.X,5),
1035 (float)Math.Round(object1PartLoaded.RotationOffset.Y,5),
1036 (float)Math.Round(object1PartLoaded.RotationOffset.Z,5),
1037 (float)Math.Round(object1PartLoaded.RotationOffset.W,5));
1038 Quaternion qtmp2 =
new Quaternion (
1039 (
float)Math.Round(part1.RotationOffset.X,5),
1040 (float)Math.Round(part1.RotationOffset.Y,5),
1041 (float)Math.Round(part1.RotationOffset.Z,5),
1042 (float)Math.Round(part1.RotationOffset.W,5));
1044 Assert.That(qtmp1, Is.EqualTo(qtmp2),
"object1 rotation offset not equal");
1046 object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition),
"object1 offset position not equal");
1047 Assert.That(object1PartLoaded.SitTargetOrientation, Is.EqualTo(part1.SitTargetOrientation));
1048 Assert.That(object1PartLoaded.SitTargetPosition, Is.EqualTo(part1.SitTargetPosition));
1050 TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
1051 Assert.That(loadedSoundItem, Is.Not.Null,
"loaded sound item was null");
1052 AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
1053 Assert.That(loadedSoundAsset, Is.Not.Null,
"loaded sound asset was null");
1054 Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData),
"saved and loaded sound data do not match");
1056 Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0,
"incorrect number of parcels");
Temporary code to do the bare minimum required to read a tar archive for our purposes ...
const string OBJECTS_PATH
The regions included in an OAR file.
void TestLoadOar()
Test loading an OpenSim Region Archive.
A group of regions arranged in a rectangle, possibly with holes.
void TestSaveOarNoAssets()
Test saving an OpenSim Region Archive with the no assets option
Constants for the archiving module
void TestSaveMultiRegionOar()
Test saving a multi-region OAR.
void TestLoadOarRegionSettings()
Test loading the region settings of an OpenSim Region Archive.
SerialiserModule m_serialiserModule
OpenSim.Framework.Serialization.TarArchiveReader TarArchiveReader
void TestSaveOar()
Test saving an OpenSim Region Archive.
void TestLoadMultiRegionOar()
Test loading a multi-region OAR.
void TestLoadPublishedOar()
Test loading an OpenSim Region Archive saved with the –publish option.
OpenSim.Framework.RegionSettings RegionSettings
void TestLoadOarDeededLand()
Test OAR loading where the land parcel is group deeded.
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
TaskInventoryItem m_soundItem
Represents an item in a task inventory
Serialize and deserialize scene objects.
SceneHelpers m_sceneHelpers
Temporary code to produce a tar archive in tar v7 format
ArchiverModule m_archiverModule
OpenSim.Framework.Serialization.ArchiveConstants ArchiveConstants
Asset class. All Assets are reference by this class or a class derived from this class ...
Keeps track of a specific piece of land's information
Details of a Parcel of land
Helpers for setting up scenes.
void WriteFile(string filePath, string data)
Write a file to the tar archive
SceneObjectPart CreateSceneObjectPart1()
Interactive OpenSim region server
SceneObjectPart CreateSceneObjectPart2()
This module loads and saves OpenSimulator region archives
Prepare to write out an archive.
byte[] ReadEntry(out string filePath, out TarEntryType entryType)
Read the next entry in the tar file.
OpenSim.Framework.Serialization.TarArchiveWriter TarArchiveWriter
static string ToXml2Format(SceneObjectGroup sceneObject)
Serialize a scene object to the 'xml2' format.
void TestMergeOar()
Test merging an OpenSim Region Archive into an existing scene
void TestLoadOarUnorderedParts()
Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e...
Handles an individual archive read request