public void TestNotecardAsset()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID ownerId   = TestHelpers.ParseTail(0x10);
            UUID soAssetId = TestHelpers.ParseTail(0x20);
            UUID ncAssetId = TestHelpers.ParseTail(0x30);

            SceneObjectGroup so      = SceneHelpers.CreateSceneObject(1, ownerId);
            AssetBase        soAsset = AssetHelpers.CreateAsset(soAssetId, so);

            m_assetService.Store(soAsset);

            AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString());

            m_assetService.Store(ncAsset);

            IDictionary <UUID, AssetType> foundAssetUuids = new Dictionary <UUID, AssetType>();

            m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids);

            // We count the uuid as gathered even if the asset itself is corrupt.
            Assert.That(foundAssetUuids.Count, Is.EqualTo(2));
            Assert.That(foundAssetUuids.ContainsKey(ncAssetId));
            Assert.That(foundAssetUuids.ContainsKey(soAssetId));
        }
Esempio n. 2
0
        public void TestCreate()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
//            ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);

            // 8 is the index of the first baked texture in AvatarAppearance
            UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);

            Primitive.TextureEntry     originalTe  = new Primitive.TextureEntry(UUID.Zero);
            Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
            originalTef.TextureID = originalFace8TextureId;

            // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
            // ScenePresence.SendInitialData() to reset our entire appearance.
            scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));

            afm.SetAppearance(sp, originalTe, null);

            INPCModule npcModule = scene.RequestModuleInterface <INPCModule>();
            UUID       npcId     = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);

            ScenePresence npc = scene.GetScenePresence(npcId);

            Assert.That(npc, Is.Not.Null);
            Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
            Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
        }
Esempio n. 3
0
        public void TestAddTemporaryLocalAsset()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
            config.AddConfig("AssetService");
            config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
            config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");

            LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();

            lasc.Initialise(config);

            // If it is local, it should not be stored
            AssetBase a1 = AssetHelpers.CreateNotecardAsset();

            a1.Local     = true;
            a1.Temporary = true;

            lasc.Store(a1);

            Assert.That(lasc.Get(a1.ID), Is.Null);
            Assert.That(lasc.GetData(a1.ID), Is.Null);
            Assert.That(lasc.GetMetadata(a1.ID), Is.Null);

            // TODO: Add cache and check that this does receive a copy of the asset
        }
Esempio n. 4
0
        private void TestAddRemoveNPCs(int numberOfNpcs)
        {
            ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
//            ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);

            // 8 is the index of the first baked texture in AvatarAppearance
            UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);

            Primitive.TextureEntry     originalTe  = new Primitive.TextureEntry(UUID.Zero);
            Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
            originalTef.TextureID = originalFace8TextureId;

            // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
            // ScenePresence.SendInitialData() to reset our entire appearance.
            scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));

/*
 *          afm.SetAppearance(sp, originalTe, null);
 *
 *          INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
 *
 *          List<UUID> npcs = new List<UUID>();
 *
 *          long startGcMemory = GC.GetTotalMemory(true);
 *          Stopwatch sw = new Stopwatch();
 *          sw.Start();
 *
 *          for (int i = 0; i < numberOfNpcs; i++)
 *          {
 *              npcs.Add(
 *                  npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
 *          }
 *
 *          for (int i = 0; i < numberOfNpcs; i++)
 *          {
 *              Assert.That(npcs[i], Is.Not.Null);
 *
 *              ScenePresence npc = scene.GetScenePresence(npcs[i]);
 *              Assert.That(npc, Is.Not.Null);
 *          }
 *
 *          for (int i = 0; i < numberOfNpcs; i++)
 *          {
 *              Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
 *              ScenePresence npc = scene.GetScenePresence(npcs[i]);
 *              Assert.That(npc, Is.Null);
 *          }
 *
 *          sw.Stop();
 *
 *          long endGcMemory = GC.GetTotalMemory(true);
 *
 *          Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
 *          Console.WriteLine(
 *              "End {0} MB, Start {1} MB, Diff {2} MB",
 *              endGcMemory / 1024 / 1024,
 *              startGcMemory / 1024 / 1024,
 *              (endGcMemory - startGcMemory) / 1024 / 1024);
 */
        }
        public void TestGoodAssetStoreRequest()
        {
            TestHelpers.InMethod();

            UUID assetId = TestHelpers.ParseTail(0x1);

            IConfigSource config = new IniConfigSource();
            config.AddConfig("AssetService");
            config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");

            AssetService assetService = new AssetService(config);

            AssetServerPostHandler asph = new AssetServerPostHandler(assetService);

            AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World");

            MemoryStream buffer = new MemoryStream();

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = Encoding.UTF8;

            using (XmlWriter writer = XmlWriter.Create(buffer, settings))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(AssetBase));
                serializer.Serialize(writer, asset);
                writer.Flush();
            }

            buffer.Position = 0;
            asph.Handle(null, buffer, null, null);

            AssetBase retrievedAsset = assetService.Get(assetId.ToString());

            Assert.That(retrievedAsset, Is.Not.Null);
        }
        public void TestExpireAsset()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            AssetBase asset = AssetHelpers.CreateNotecardAsset();

            asset.ID = TestHelpers.ParseTail(0x2).ToString();

            m_cache.Store(asset);

            m_cache.Expire(asset.ID);

            AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString());

            Assert.That(retrievedAsset, Is.Null);
        }
        public void TestCacheAsset()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            AssetBase asset = AssetHelpers.CreateNotecardAsset();

            asset.ID = TestHelpers.ParseTail(0x1).ToString();

            // Check we don't get anything before the asset is put in the cache
            AssetBase retrievedAsset = m_cache.Get(asset.ID.ToString());

            Assert.That(retrievedAsset, Is.Null);

            m_cache.Store(asset);

            // Check that asset is now in cache
            retrievedAsset = m_cache.Get(asset.ID.ToString());
            Assert.That(retrievedAsset, Is.Not.Null);
            Assert.That(retrievedAsset.ID, Is.EqualTo(asset.ID));
        }
Esempio n. 8
0
        public void TestAddTemporaryAsset()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
            config.AddConfig("AssetService");
            config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
            config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");

            LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();

            lasc.Initialise(config);

            // If it is remote, it should be stored
            AssetBase a2 = AssetHelpers.CreateNotecardAsset();

            a2.Local     = false;
            a2.Temporary = true;

            lasc.Store(a2);

            AssetBase retreivedA2 = lasc.Get(a2.ID);

            Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID));
            Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID));
            Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length));

            AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID);

            Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID));

            byte[] retrievedA2Data = lasc.GetData(a2.ID);
            Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length));

            // TODO: Add cache and check that this does receive a copy of the asset
        }
        public void TestNotecardAsset()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID ownerId               = TestHelpers.ParseTail(0x10);
            UUID embeddedId            = TestHelpers.ParseTail(0x20);
            UUID secondLevelEmbeddedId = TestHelpers.ParseTail(0x21);
            UUID missingEmbeddedId     = TestHelpers.ParseTail(0x22);
            UUID ncAssetId             = TestHelpers.ParseTail(0x30);

            AssetBase ncAsset
                = AssetHelpers.CreateNotecardAsset(
                      ncAssetId, string.Format("Hello{0}World{1}", embeddedId, missingEmbeddedId));

            m_assetService.Store(ncAsset);

            AssetBase embeddedAsset
                = AssetHelpers.CreateNotecardAsset(embeddedId, string.Format("{0} We'll meet again.", secondLevelEmbeddedId));

            m_assetService.Store(embeddedAsset);

            AssetBase secondLevelEmbeddedAsset
                = AssetHelpers.CreateNotecardAsset(secondLevelEmbeddedId, "Don't know where, don't know when.");

            m_assetService.Store(secondLevelEmbeddedAsset);

            m_uuidGatherer.AddForInspection(ncAssetId);
            m_uuidGatherer.GatherAll();

//            foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys)
//                System.Console.WriteLine("key : {0}", key);

            Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3));
            Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId));
            Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId));
            Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId));
        }
Esempio n. 10
0
        public void TestCreate()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            SetUpScene();

            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
//            ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);

            // 8 is the index of the first baked texture in AvatarAppearance
            UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);

            Primitive.TextureEntry     originalTe  = new Primitive.TextureEntry(UUID.Zero);
            Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
            originalTef.TextureID = originalFace8TextureId;

            // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
            // ScenePresence.SendInitialData() to reset our entire appearance.
            m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));

            m_afMod.SetAppearance(sp, originalTe, null, null);

            UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);

            ScenePresence npc = m_scene.GetScenePresence(npcId);

            Assert.That(npc, Is.Not.Null);
            Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
            Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));

            IClientAPI client;

            Assert.That(m_scene.TryGetClient(npcId, out client), Is.True);

            // Have to account for both SP and NPC.
            Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2));
        }