aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-21 23:42:34 +0000
committerJustin Clark-Casey (justincc)2012-11-21 23:42:34 +0000
commitbac8ac32dae4049e84f74d276bb5ce83a2a512ac (patch)
tree8a8f17db52960961d1ba38fe36d116310f729012
parentIf GetAgents() is called with an empty userIDs array then don't bother with a... (diff)
downloadopensim-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 '')
-rw-r--r--.nant/local.include10
-rw-r--r--OpenSim/Server/Handlers/Asset/Tests/AssetServerPostHandlerTests.cs84
-rw-r--r--prebuild.xml46
3 files changed, 140 insertions, 0 deletions
diff --git a/.nant/local.include b/.nant/local.include
index 9c9aa28..5185717 100644
--- a/.nant/local.include
+++ b/.nant/local.include
@@ -132,6 +132,11 @@
132 </exec> 132 </exec>
133 <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" /> 133 <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" />
134 134
135 <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.server.handlers.tests">
136 <arg value="./bin/OpenSim.Server.Handlers.Tests.dll" />
137 </exec>
138 <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.server.handlers.tests)==0}" />
139
135 <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.services.inventoryservice.tests"> 140 <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.services.inventoryservice.tests">
136 <arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" /> 141 <arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" />
137 </exec> 142 </exec>
@@ -240,6 +245,11 @@
240 <arg value="-xml=test-results/OpenSim.Capabilities.Handlers.Tests.dll-Results.xml" /> 245 <arg value="-xml=test-results/OpenSim.Capabilities.Handlers.Tests.dll-Results.xml" />
241 </exec> 246 </exec>
242 247
248 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.server.handlers.tests">
249 <arg value="./bin/OpenSim.Server.Handlers.Tests.dll" />
250 <arg value="-xml=test-results/OpenSim.Server.Handlers.Tests.dll-Results.xml" />
251 </exec>
252
243 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.services.inventoryservice.tests"> 253 <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.services.inventoryservice.tests">
244 <arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" /> 254 <arg value="./bin/OpenSim.Services.InventoryService.Tests.dll" />
245 <arg value="-xml=test-results/OpenSim.Services.InventoryService.Tests.dll-Results.xml" /> 255 <arg value="-xml=test-results/OpenSim.Services.InventoryService.Tests.dll-Results.xml" />
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
28using System;
29using System.IO;
30using System.Text;
31using System.Xml;
32using System.Xml.Serialization;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Server.Handlers.Asset;
38using OpenSim.Services.AssetService;
39using OpenSim.Services.Interfaces;
40using OpenSim.Tests.Common;
41
42namespace 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
diff --git a/prebuild.xml b/prebuild.xml
index 7694861..bb9d80c 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3297,6 +3297,52 @@
3297 </Files> 3297 </Files>
3298 </Project> 3298 </Project>
3299 3299
3300 <Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers.Tests" path="OpenSim/Server/Handlers" type="Library">
3301 <Configuration name="Debug">
3302 <Options>
3303 <OutputPath>../../../bin/</OutputPath>
3304 </Options>
3305 </Configuration>
3306 <Configuration name="Release">
3307 <Options>
3308 <OutputPath>../../../bin/</OutputPath>
3309 </Options>
3310 </Configuration>
3311
3312 <ReferencePath>../../../bin/</ReferencePath>
3313 <Reference name="System"/>
3314 <Reference name="System.Xml"/>
3315 <Reference name="System.Web"/>
3316 <Reference name="log4net" path="../../../bin/"/>
3317 <Reference name="Nini" path="../../../bin/"/>
3318 <Reference name="nunit.framework" path="../../../bin/"/>
3319 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
3320 <Reference name="OpenMetaverse" path="../../../bin/"/>
3321 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
3322 <Reference name="XMLRPC" path="../../../bin/"/>
3323 <Reference name="OpenSim.Framework"/>
3324 <Reference name="OpenSim.Framework.Console"/>
3325 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
3326 <Reference name="OpenSim.Server.Base"/>
3327 <Reference name="OpenSim.Server.Handlers"/>
3328 <Reference name="OpenSim.Services.AssetService"/>
3329 <Reference name="OpenSim.Services.Base"/>
3330 <Reference name="OpenSim.Services.Interfaces"/>
3331 <Reference name="OpenSim.Services.UserAccountService"/>
3332 <Reference name="OpenSim.Tests.Common"/>
3333
3334 <!--
3335 TODO: this is kind of lame, we basically build a duplicate
3336 assembly but with tests added in, just so that we don't
3337 need to hard code in a bunch of Test directories here. If
3338 pattern="Tests/*.cs" worked, we wouldn't need this.
3339 -->
3340 <Files>
3341 <!-- SADLY the way this works means you need to keep adding these paths -->
3342 <Match path="Asset/Tests" pattern="*.cs" recurse="true"/>
3343 </Files>
3344 </Project>
3345
3300 <Project frameworkVersion="v3_5" name="OpenSim.Tests.Stress" path="OpenSim/Tests/Stress" type="Library"> 3346 <Project frameworkVersion="v3_5" name="OpenSim.Tests.Stress" path="OpenSim/Tests/Stress" type="Library">
3301 <Configuration name="Debug"> 3347 <Configuration name="Debug">
3302 <Options> 3348 <Options>