aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorMelanie2009-09-17 23:55:06 +0100
committerMelanie2009-09-17 23:55:06 +0100
commit6461243e7c780d79244184a8d4b100303f4cda27 (patch)
tree53d07ec575ef9ccfa5f3b75cff5236db87738350 /OpenSim/Tests
parentRemove The legacy inventory and asset servers. Bump interface version to 6 (diff)
downloadopensim-SC_OLD-6461243e7c780d79244184a8d4b100303f4cda27.zip
opensim-SC_OLD-6461243e7c780d79244184a8d4b100303f4cda27.tar.gz
opensim-SC_OLD-6461243e7c780d79244184a8d4b100303f4cda27.tar.bz2
opensim-SC_OLD-6461243e7c780d79244184a8d4b100303f4cda27.tar.xz
Remove the methods for full inventory fetch from the connector. Remove tests
for the old, removed asset handlers
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs12
-rw-r--r--OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs122
2 files changed, 1 insertions, 133 deletions
diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
index e858371..eaf8b39 100644
--- a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
+++ b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
@@ -72,15 +72,5 @@ namespace OpenSim.Tests.Common.Setup
72 72
73 public static byte[] EmptyByteArray = new byte[] {}; 73 public static byte[] EmptyByteArray = new byte[] {};
74 74
75 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath)
76 {
77 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params.");
78 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash.");
79 }
80
81 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath)
82 {
83 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid.");
84 }
85 } 75 }
86} \ No newline at end of file 76}
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
deleted file mode 100644
index ffa7283..0000000
--- a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs
+++ /dev/null
@@ -1,122 +0,0 @@
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.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Text;
33using System.Xml;
34using System.Xml.Serialization;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Server.Base;
41using OpenSim.Tests.Common.Mock;
42
43namespace OpenSim.Tests.Common.Setup
44{
45 public class GetAssetStreamHandlerTestHelpers
46 {
47 private const string EXPECTED_CONTENT_TYPE = "application/x-metaverse-callingcard";
48
49 public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
50 {
51 byte[] expected = BaseGetAssetStreamHandler.GetXml(asset);
52
53 byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response);
54
55 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash.");
56 Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash.");
57 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
58
59 actual = handler.Handle("/assets/" + asset.ID + "/", null, null, response);
60 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with trailing slash.");
61 Assert.AreEqual(expected, actual, "Failed on fetching xml with trailing slash.");
62 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
63
64 actual = handler.Handle("/assets/" + asset.ID + "/badData", null, null, response);
65 Assert.Greater(actual.Length, 10, "Too short xml on fetching xml with bad trailing data.");
66 Assert.AreEqual(expected, actual, "Failed on fetching xml with bad trailing trailing slash.");
67 // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
68 }
69
70 public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
71 {
72 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash.");
73 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
74 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
75
76 Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash.");
77 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
78 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
79 }
80
81 public static void BaseFetchExistingAssetMetaDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response)
82 {
83 XmlSerializer xs = new XmlSerializer(typeof(AssetMetadata));
84
85 byte[] expected = ServerUtils.SerializeResult(xs, asset.Metadata);
86
87 Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata", null, null, response), "Failed on fetching data without trailing slash.");
88 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch.");
89 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on first fetch.");
90
91 Assert.AreEqual(expected, handler.Handle("/assets/" + asset.ID + "/metadata/", null, null, response), "Failed on fetching data with trailing slash.");
92 Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch.");
93 Assert.AreEqual(EXPECTED_CONTENT_TYPE, response.ContentType, "Wrong http content type on second fetch.");
94 }
95
96 public static AssetBase CreateCommonTestResources(out OSHttpResponse response)
97 {
98 AssetBase asset = CreateTestAsset();
99 response = new TestOSHttpResponse();
100 return asset;
101 }
102
103 public static AssetBase CreateTestAsset()
104 {
105 byte[] expected = new byte[] { 1,2,3 };
106 AssetBase asset = new AssetBase();
107 asset.ID = Guid.NewGuid().ToString();
108 asset.Data = expected;
109 asset.Type = 2;
110
111 return asset;
112 }
113
114 public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler, OSHttpResponse response)
115 {
116 Assert.AreEqual(
117 BaseRequestHandlerTestHelper.EmptyByteArray,
118 handler.Handle("/assets/" + Guid.NewGuid(), null, null, response), "Failed on bad guid.");
119 Assert.AreEqual((int)HttpStatusCode.NotFound, response.StatusCode, "Response code wrong in BaseFetchMissingAsset");
120 }
121 }
122}