diff options
author | Justin Clark-Casey (justincc) | 2012-11-21 23:42:34 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-11-21 23:42:34 +0000 |
commit | bac8ac32dae4049e84f74d276bb5ce83a2a512ac (patch) | |
tree | 8a8f17db52960961d1ba38fe36d116310f729012 /OpenSim/Server/Handlers/Asset | |
parent | If GetAgents() is called with an empty userIDs array then don't bother with a... (diff) | |
download | opensim-SC_OLD-bac8ac32dae4049e84f74d276bb5ce83a2a512ac.zip opensim-SC_OLD-bac8ac32dae4049e84f74d276bb5ce83a2a512ac.tar.gz opensim-SC_OLD-bac8ac32dae4049e84f74d276bb5ce83a2a512ac.tar.bz2 opensim-SC_OLD-bac8ac32dae4049e84f74d276bb5ce83a2a512ac.tar.xz |
Add regression test for a good request made to the asset service post handler.
Adds new OpenSim.Server.Handlers.Tests.dll to test suite
Diffstat (limited to 'OpenSim/Server/Handlers/Asset')
-rw-r--r-- | OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs new file mode 100644 index 0000000..9e82576 --- /dev/null +++ b/OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Text; | ||
31 | using System.Xml; | ||
32 | using System.Xml.Serialization; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Server.Handlers.Asset; | ||
38 | using OpenSim.Services.AssetService; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenSim.Tests.Common; | ||
41 | |||
42 | namespace OpenSim.Server.Handlers.Asset.Test | ||
43 | { | ||
44 | [TestFixture] | ||
45 | public class AssetServerPostHandlerTests : OpenSimTestCase | ||
46 | { | ||
47 | [Test] | ||
48 | public void TestGoodAssetStoreRequest() | ||
49 | { | ||
50 | TestHelpers.InMethod(); | ||
51 | |||
52 | UUID assetId = TestHelpers.ParseTail(0x1); | ||
53 | |||
54 | IConfigSource config = new IniConfigSource(); | ||
55 | config.AddConfig("AssetService"); | ||
56 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | ||
57 | |||
58 | AssetService assetService = new AssetService(config); | ||
59 | |||
60 | AssetServerPostHandler asph = new AssetServerPostHandler(assetService); | ||
61 | |||
62 | AssetBase asset = AssetHelpers.CreateNotecardAsset(assetId, "Hello World"); | ||
63 | |||
64 | MemoryStream buffer = new MemoryStream(); | ||
65 | |||
66 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
67 | settings.Encoding = Encoding.UTF8; | ||
68 | |||
69 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
70 | { | ||
71 | XmlSerializer serializer = new XmlSerializer(typeof(AssetBase)); | ||
72 | serializer.Serialize(writer, asset); | ||
73 | writer.Flush(); | ||
74 | } | ||
75 | |||
76 | buffer.Position = 0; | ||
77 | asph.Handle(null, buffer, null, null); | ||
78 | |||
79 | AssetBase retrievedAsset = assetService.Get(assetId.ToString()); | ||
80 | |||
81 | Assert.That(retrievedAsset, Is.Not.Null); | ||
82 | } | ||
83 | } | ||
84 | } \ No newline at end of file | ||