diff options
author | Justin Clark-Casey (justincc) | 2011-12-05 21:04:17 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-12-05 21:04:17 +0000 |
commit | 319507f5215f5705cbe80d0c468da15ffe778829 (patch) | |
tree | 0362f3d98fb4419c630b6418f2b3a9c8f72d95c7 | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-319507f5215f5705cbe80d0c468da15ffe778829.zip opensim-SC_OLD-319507f5215f5705cbe80d0c468da15ffe778829.tar.gz opensim-SC_OLD-319507f5215f5705cbe80d0c468da15ffe778829.tar.bz2 opensim-SC_OLD-319507f5215f5705cbe80d0c468da15ffe778829.tar.xz |
Add test for not found response from GetTexture cap handler.
Add OpenSim.Region.Capabilities.Handlers.Tests.dll into test suite
Diffstat (limited to '')
-rw-r--r-- | .nant/local.include | 11 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | 63 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs | 179 | ||||
-rw-r--r-- | prebuild.xml | 50 |
4 files changed, 303 insertions, 0 deletions
diff --git a/.nant/local.include b/.nant/local.include index 698af3f..94f510f 100644 --- a/.nant/local.include +++ b/.nant/local.include | |||
@@ -149,6 +149,11 @@ | |||
149 | </exec> | 149 | </exec> |
150 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" /> | 150 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" /> |
151 | 151 | ||
152 | <exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.capabilities.handlers.tests"> | ||
153 | <arg value="./bin/OpenSim.Capabilities.Handlers.Tests.dll" /> | ||
154 | </exec> | ||
155 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" /> | ||
156 | |||
152 | <delete dir="%temp%"/> | 157 | <delete dir="%temp%"/> |
153 | 158 | ||
154 | </target> | 159 | </target> |
@@ -338,6 +343,11 @@ | |||
338 | <arg value="-xml=test-results/OpenSim.Data.Tests.dll-Results.xml" /> | 343 | <arg value="-xml=test-results/OpenSim.Data.Tests.dll-Results.xml" /> |
339 | </exec> | 344 | </exec> |
340 | 345 | ||
346 | <exec program="${nunitcmd}" failonerror="false" resultproperty="testresult.opensim.capabilities.handlers.tests"> | ||
347 | <arg value="./bin/OpenSim.Capabilities.Handlers.Tests.dll" /> | ||
348 | <arg value="-xml=test-results/OpenSim.Capabilities.Handlers.Tests.dll-Results.xml" /> | ||
349 | </exec> | ||
350 | |||
341 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" /> | 351 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests)==0}" /> |
342 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" /> | 352 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.tests)==0}" /> |
343 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" /> | 353 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.framework.servers.tests)==0}" /> |
@@ -347,6 +357,7 @@ | |||
347 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" /> | 357 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.optionalmodules.tests)==0}" /> |
348 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" /> | 358 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.region.framework.tests)==0}" /> |
349 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" /> | 359 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.data.tests)==0}" /> |
360 | <fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.capabilities.handlers.tests)==0}" /> | ||
350 | 361 | ||
351 | </target> | 362 | </target> |
352 | <!-- <exec program="nunit-console.exe" failonerror="false" resultproperty="testresult.acceptancetestassembly"> --> | 363 | <!-- <exec program="nunit-console.exe" failonerror="false" resultproperty="testresult.acceptancetestassembly"> --> |
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs new file mode 100644 index 0000000..fd152c3 --- /dev/null +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | |||
@@ -0,0 +1,63 @@ | |||
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.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using log4net; | ||
32 | using log4net.Config; | ||
33 | using NUnit.Framework; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Capabilities.Handlers; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Tests.Common; | ||
40 | using OpenSim.Tests.Common.Mock; | ||
41 | |||
42 | namespace OpenSim.Capabilities.Handlers.GetTexture.Tests | ||
43 | { | ||
44 | [TestFixture] | ||
45 | public class GetTextureHandlerTests | ||
46 | { | ||
47 | [Test] | ||
48 | public void TestTextureNotFound() | ||
49 | { | ||
50 | TestHelpers.InMethod(); | ||
51 | |||
52 | // Overkill - we only really need the asset service, not a whole scene. | ||
53 | Scene scene = SceneHelpers.SetupScene(); | ||
54 | |||
55 | GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService); | ||
56 | TestOSHttpRequest req = new TestOSHttpRequest(); | ||
57 | TestOSHttpResponse resp = new TestOSHttpResponse(); | ||
58 | req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012"); | ||
59 | handler.Handle(null, null, req, resp); | ||
60 | Assert.That(resp.StatusCode, Is.EqualTo((int)System.Net.HttpStatusCode.NotFound)); | ||
61 | } | ||
62 | } | ||
63 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs new file mode 100644 index 0000000..e769d30 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestOSHttpRequest.cs | |||
@@ -0,0 +1,179 @@ | |||
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.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Collections.Specialized; | ||
32 | using System.IO; | ||
33 | using System.Net; | ||
34 | using System.Text; | ||
35 | using System.Web; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | |||
38 | namespace OpenSim.Tests.Common.Mock | ||
39 | { | ||
40 | public class TestOSHttpRequest : IOSHttpRequest | ||
41 | { | ||
42 | public string[] AcceptTypes | ||
43 | { | ||
44 | get | ||
45 | { | ||
46 | throw new NotImplementedException (); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | public Encoding ContentEncoding | ||
51 | { | ||
52 | get | ||
53 | { | ||
54 | throw new NotImplementedException (); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public long ContentLength | ||
59 | { | ||
60 | get | ||
61 | { | ||
62 | throw new NotImplementedException (); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | public long ContentLength64 | ||
67 | { | ||
68 | get | ||
69 | { | ||
70 | throw new NotImplementedException (); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | public string ContentType | ||
75 | { | ||
76 | get | ||
77 | { | ||
78 | throw new NotImplementedException (); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | public HttpCookieCollection Cookies | ||
83 | { | ||
84 | get | ||
85 | { | ||
86 | throw new NotImplementedException (); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | public bool HasEntityBody | ||
91 | { | ||
92 | get | ||
93 | { | ||
94 | throw new NotImplementedException (); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public NameValueCollection Headers { get; set; } | ||
99 | |||
100 | public string HttpMethod | ||
101 | { | ||
102 | get | ||
103 | { | ||
104 | throw new NotImplementedException (); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public Stream InputStream | ||
109 | { | ||
110 | get | ||
111 | { | ||
112 | throw new NotImplementedException (); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | public bool IsSecured | ||
117 | { | ||
118 | get | ||
119 | { | ||
120 | throw new NotImplementedException (); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public bool KeepAlive | ||
125 | { | ||
126 | get | ||
127 | { | ||
128 | throw new NotImplementedException (); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | public NameValueCollection QueryString | ||
133 | { | ||
134 | get | ||
135 | { | ||
136 | throw new NotImplementedException (); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | public Hashtable Query | ||
141 | { | ||
142 | get | ||
143 | { | ||
144 | throw new NotImplementedException (); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | public string RawUrl | ||
149 | { | ||
150 | get | ||
151 | { | ||
152 | throw new NotImplementedException (); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | public IPEndPoint RemoteIPEndPoint | ||
157 | { | ||
158 | get | ||
159 | { | ||
160 | throw new NotImplementedException (); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | public Uri Url { get; set; } | ||
165 | |||
166 | public string UserAgent | ||
167 | { | ||
168 | get | ||
169 | { | ||
170 | throw new NotImplementedException (); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | public TestOSHttpRequest() | ||
175 | { | ||
176 | Headers = new NameValueCollection(); | ||
177 | } | ||
178 | } | ||
179 | } \ No newline at end of file | ||
diff --git a/prebuild.xml b/prebuild.xml index 05d9545..e951187 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2729,6 +2729,56 @@ | |||
2729 | </Project> | 2729 | </Project> |
2730 | 2730 | ||
2731 | 2731 | ||
2732 | <Project frameworkVersion="v3_5" name="OpenSim.Capabilities.Handlers.Tests" path="OpenSim/Capabilities/Handlers" type="Library"> | ||
2733 | <Configuration name="Debug"> | ||
2734 | <Options> | ||
2735 | <OutputPath>../../../bin/</OutputPath> | ||
2736 | </Options> | ||
2737 | </Configuration> | ||
2738 | <Configuration name="Release"> | ||
2739 | <Options> | ||
2740 | <OutputPath>../../../bin/</OutputPath> | ||
2741 | </Options> | ||
2742 | </Configuration> | ||
2743 | |||
2744 | <ReferencePath>../../../bin/</ReferencePath> | ||
2745 | <Reference name="System"/> | ||
2746 | <Reference name="System.Core"/> | ||
2747 | <Reference name="System.Drawing"/> | ||
2748 | <Reference name="System.Xml"/> | ||
2749 | <Reference name="System.Web"/> | ||
2750 | <Reference name="nunit.framework" path="../../../bin/"/> | ||
2751 | <Reference name="OpenMetaverse" path="../../../bin/"/> | ||
2752 | <Reference name="OpenMetaverseTypes" path="../../../bin/"/> | ||
2753 | <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/> | ||
2754 | <Reference name="OpenSim.Capabilities"/> | ||
2755 | <Reference name="OpenSim.Capabilities.Handlers"/> | ||
2756 | <Reference name="OpenSim.Framework"/> | ||
2757 | <Reference name="OpenSim.Framework.Console"/> | ||
2758 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | ||
2759 | <Reference name="OpenSim.Region.Framework"/> | ||
2760 | <Reference name="OpenSim.Server.Base"/> | ||
2761 | <Reference name="OpenSim.Server.Handlers"/> | ||
2762 | <Reference name="OpenSim.Services.Base"/> | ||
2763 | <Reference name="OpenSim.Services.Interfaces"/> | ||
2764 | <Reference name="OpenSim.Tests.Common"/> | ||
2765 | <Reference name="Nini" path="../../../bin/"/> | ||
2766 | <Reference name="log4net" path="../../../bin/"/> | ||
2767 | <Reference name="DotNetOpenId" path="../../../bin/"/> | ||
2768 | |||
2769 | <!-- | ||
2770 | TODO: this is kind of lame, we basically build a duplicate | ||
2771 | assembly but with tests added in, just so that we don't | ||
2772 | need to hard code in a bunch of Test directories here. If | ||
2773 | pattern="Tests/*.cs" worked, we wouldn't need this. | ||
2774 | --> | ||
2775 | <Files> | ||
2776 | <!-- SADLY the way this works means you need to keep adding these paths --> | ||
2777 | <Match path="GetTexture/Tests" pattern="*.cs" recurse="true"/> | ||
2778 | </Files> | ||
2779 | </Project> | ||
2780 | |||
2781 | |||
2732 | <Project frameworkVersion="v3_5" name="OpenSim.Data.Tests" path="OpenSim/Data/Tests" type="Library"> | 2782 | <Project frameworkVersion="v3_5" name="OpenSim.Data.Tests" path="OpenSim/Data/Tests" type="Library"> |
2733 | <Configuration name="Debug"> | 2783 | <Configuration name="Debug"> |
2734 | <Options> | 2784 | <Options> |