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 TestBadXmlAssetStoreRequest() { TestHelpers.InMethod(); 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); MemoryStream buffer = new MemoryStream(); byte[] badData = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f }; buffer.Write(badData, 0, badData.Length); buffer.Position = 0; TestOSHttpResponse response = new TestOSHttpResponse(); asph.Handle(null, buffer, null, response); Assert.That(response.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest)); }