public void TestLoadOarUnorderedParts()
        {
            TestHelpers.InMethod();

            UUID ownerId = TestHelpers.ParseTail(0xaaaa);

            MemoryStream     archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11);
            SceneObjectPart  sop2
                = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
            SceneObjectPart sop3
                = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);

            // Add the parts so they will be written out in reverse order to the oar
            sog1.AddPart(sop3);
            sop3.LinkNum = 3;
            sog1.AddPart(sop2);
            sop2.LinkNum = 2;

            tar.WriteFile(
                ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
                SceneObjectSerializer.ToXml2Format(sog1));

            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(archiveReadStream);
            }

            Assert.That(m_lastErrorMessage, Is.Null);

            SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2");

            Assert.That(part2.LinkNum, Is.EqualTo(2));

            SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3");

            Assert.That(part3.LinkNum, Is.EqualTo(3));
        }
        public void TestLoadOarDeededLand()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID landID = TestHelpers.ParseTail(0x10);

            MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();

            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Groups");

            config.Set("Enabled", true);
            config.Set("Module", "GroupsModule");
            config.Set("DebugEnabled", true);
            SceneHelpers.SetupSceneModules(
                m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });

            // Create group in scene for loading
            // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
            UUID groupID
                = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);

            // Construct OAR
            MemoryStream     oarStream = new MemoryStream();
            TarArchiveWriter tar       = new TarArchiveWriter(oarStream);

            tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            LandObject lo = new LandObject(groupID, true, m_scene);

            lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
            LandData ld = lo.LandData;

            ld.GlobalID = landID;

            string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);

            tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null));
            tar.Close();

            oarStream = new MemoryStream(oarStream.ToArray());

            // Load OAR
            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(oarStream);
            }

            ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
            LandData    rLd = rLo.LandData;

            Assert.That(rLd.GlobalID, Is.EqualTo(landID));
            Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
            Assert.That(rLd.GroupID, Is.EqualTo(groupID));
            Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
        }