aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJeff Ames2009-05-11 15:14:15 +0000
committerJeff Ames2009-05-11 15:14:15 +0000
commit516440367680ce43417442bbf9570eaadd503235 (patch)
tree30f84174c08638681d4926a0e7773e572ec645f2
parentadding code to check for old-style responses ("True") (diff)
downloadopensim-SC-516440367680ce43417442bbf9570eaadd503235.zip
opensim-SC-516440367680ce43417442bbf9570eaadd503235.tar.gz
opensim-SC-516440367680ce43417442bbf9570eaadd503235.tar.bz2
opensim-SC-516440367680ce43417442bbf9570eaadd503235.tar.xz
Update svn properties.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs392
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs86
-rw-r--r--OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs144
-rw-r--r--OpenSim/Region/ReplaceableModules/README.txt8
-rw-r--r--OpenSim/Tests/Common/BaseRequestHandlerTestHelper.cs114
5 files changed, 372 insertions, 372 deletions
diff --git a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs
index 6e03ea8..fc4eed7 100644
--- a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs
+++ b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs
@@ -1,196 +1,196 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Text; 33using System.Text;
34using System.Text.RegularExpressions; 34using System.Text.RegularExpressions;
35using System.Xml; 35using System.Xml;
36using System.Xml.Serialization; 36using System.Xml.Serialization;
37using log4net; 37using log4net;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Framework.Statistics; 40using OpenSim.Framework.Statistics;
41 41
42namespace OpenSim.Framework.Servers 42namespace OpenSim.Framework.Servers
43{ 43{
44 public abstract class BaseGetAssetStreamHandler : BaseStreamHandler 44 public abstract class BaseGetAssetStreamHandler : BaseStreamHandler
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path) 48 protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path)
49 { 49 {
50 } 50 }
51 51
52 protected abstract AssetBase GetAsset(UUID assetID); 52 protected abstract AssetBase GetAsset(UUID assetID);
53 53
54 public override byte[] Handle(string path, Stream request, 54 public override byte[] Handle(string path, Stream request,
55 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 55 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
56 { 56 {
57 byte[] result = new byte[] { }; 57 byte[] result = new byte[] { };
58 58
59 string[] p = SplitParams(path); 59 string[] p = SplitParams(path);
60 60
61 if (p.Length > 0) 61 if (p.Length > 0)
62 { 62 {
63 UUID assetID = UUID.Zero; 63 UUID assetID = UUID.Zero;
64 64
65 if (!UUID.TryParse(p[0], out assetID)) 65 if (!UUID.TryParse(p[0], out assetID))
66 { 66 {
67 m_log.InfoFormat( 67 m_log.InfoFormat(
68 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); 68 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
69 return result; 69 return result;
70 } 70 }
71 71
72 if (StatsManager.AssetStats != null) 72 if (StatsManager.AssetStats != null)
73 StatsManager.AssetStats.AddRequest(); 73 StatsManager.AssetStats.AddRequest();
74 74
75 AssetBase asset = GetAsset(assetID); 75 AssetBase asset = GetAsset(assetID);
76 76
77 if (asset != null) 77 if (asset != null)
78 { 78 {
79// if (asset.ContainsReferences) 79// if (asset.ContainsReferences)
80// { 80// {
81// asset.Data = ProcessOutgoingAssetData(asset.Data); 81// asset.Data = ProcessOutgoingAssetData(asset.Data);
82// } 82// }
83 if (p.Length > 1 && p[1] == "data") 83 if (p.Length > 1 && p[1] == "data")
84 { 84 {
85 httpResponse.StatusCode = (int)HttpStatusCode.OK; 85 httpResponse.StatusCode = (int)HttpStatusCode.OK;
86 httpResponse.ContentType = SLAssetTypeToContentType(asset.Type); 86 httpResponse.ContentType = SLAssetTypeToContentType(asset.Type);
87 result = asset.Data; 87 result = asset.Data;
88 } 88 }
89 else 89 else
90 { 90 {
91 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 91 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
92 MemoryStream ms = new MemoryStream(); 92 MemoryStream ms = new MemoryStream();
93 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); 93 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
94 xw.Formatting = Formatting.Indented; 94 xw.Formatting = Formatting.Indented;
95 xs.Serialize(xw, asset); 95 xs.Serialize(xw, asset);
96 xw.Flush(); 96 xw.Flush();
97 97
98 ms.Seek(0, SeekOrigin.Begin); 98 ms.Seek(0, SeekOrigin.Begin);
99 //StreamReader sr = new StreamReader(ms); 99 //StreamReader sr = new StreamReader(ms);
100 100
101 result = ms.GetBuffer(); 101 result = ms.GetBuffer();
102 102
103 Array.Resize<byte>(ref result, (int)ms.Length); 103 Array.Resize<byte>(ref result, (int)ms.Length);
104 } 104 }
105 } 105 }
106 else 106 else
107 { 107 {
108 if (StatsManager.AssetStats != null) 108 if (StatsManager.AssetStats != null)
109 StatsManager.AssetStats.AddNotFoundRequest(); 109 StatsManager.AssetStats.AddNotFoundRequest();
110 110
111 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); 111 m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID);
112 } 112 }
113 } 113 }
114 114
115 return result; 115 return result;
116 } 116 }
117 117
118 public string ProcessAssetDataString(string data) 118 public string ProcessAssetDataString(string data)
119 { 119 {
120 Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)"); 120 Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
121 121
122 // IUserService userService = null; 122 // IUserService userService = null;
123 123
124 data = regex.Replace(data, delegate(Match m) 124 data = regex.Replace(data, delegate(Match m)
125 { 125 {
126 string result = String.Empty; 126 string result = String.Empty;
127 127
128// string key = m.Groups[1].Captures[0].Value; 128// string key = m.Groups[1].Captures[0].Value;
129// 129//
130// string value = m.Groups[2].Captures[0].Value; 130// string value = m.Groups[2].Captures[0].Value;
131// 131//
132// Guid userUri; 132// Guid userUri;
133// 133//
134// switch (key) 134// switch (key)
135// { 135// {
136// case "creator_id": 136// case "creator_id":
137// userUri = new Guid(value); 137// userUri = new Guid(value);
138// // result = "creator_url " + userService(userService, userUri); 138// // result = "creator_url " + userService(userService, userUri);
139// break; 139// break;
140// 140//
141// case "owner_id": 141// case "owner_id":
142// userUri = new Guid(value); 142// userUri = new Guid(value);
143// // result = "owner_url " + ResolveUserUri(userService, userUri); 143// // result = "owner_url " + ResolveUserUri(userService, userUri);
144// break; 144// break;
145// } 145// }
146 146
147 return result; 147 return result;
148 }); 148 });
149 149
150 return data; 150 return data;
151 } 151 }
152 152
153 private string SLAssetTypeToContentType(int assetType) 153 private string SLAssetTypeToContentType(int assetType)
154 { 154 {
155 switch (assetType) 155 switch (assetType)
156 { 156 {
157 case 0: 157 case 0:
158 return "image/jp2"; 158 return "image/jp2";
159 case 1: 159 case 1:
160 return "application/ogg"; 160 return "application/ogg";
161 case 2: 161 case 2:
162 return "application/x-metaverse-callingcard"; 162 return "application/x-metaverse-callingcard";
163 case 3: 163 case 3:
164 return "application/x-metaverse-landmark"; 164 return "application/x-metaverse-landmark";
165 case 5: 165 case 5:
166 return "application/x-metaverse-clothing"; 166 return "application/x-metaverse-clothing";
167 case 6: 167 case 6:
168 return "application/x-metaverse-primitive"; 168 return "application/x-metaverse-primitive";
169 case 7: 169 case 7:
170 return "application/x-metaverse-notecard"; 170 return "application/x-metaverse-notecard";
171 case 8: 171 case 8:
172 return "application/x-metaverse-folder"; 172 return "application/x-metaverse-folder";
173 case 10: 173 case 10:
174 return "application/x-metaverse-lsl"; 174 return "application/x-metaverse-lsl";
175 case 11: 175 case 11:
176 return "application/x-metaverse-lso"; 176 return "application/x-metaverse-lso";
177 case 12: 177 case 12:
178 return "image/tga"; 178 return "image/tga";
179 case 13: 179 case 13:
180 return "application/x-metaverse-bodypart"; 180 return "application/x-metaverse-bodypart";
181 case 17: 181 case 17:
182 return "audio/x-wav"; 182 return "audio/x-wav";
183 case 19: 183 case 19:
184 return "image/jpeg"; 184 return "image/jpeg";
185 case 20: 185 case 20:
186 return "application/x-metaverse-animation"; 186 return "application/x-metaverse-animation";
187 case 21: 187 case 21:
188 return "application/x-metaverse-gesture"; 188 return "application/x-metaverse-gesture";
189 case 22: 189 case 22:
190 return "application/x-metaverse-simstate"; 190 return "application/x-metaverse-simstate";
191 default: 191 default:
192 return "application/octet-stream"; 192 return "application/octet-stream";
193 } 193 }
194 } 194 }
195 } 195 }
196} 196}
diff --git a/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs b/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs
index 14998c5..b9ce430 100644
--- a/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs
@@ -1,43 +1,43 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using NUnit.Framework; 4using NUnit.Framework;
5using OpenSim.Tests.Common; 5using OpenSim.Tests.Common;
6 6
7namespace OpenSim.Framework.Servers.HttpServer.Tests 7namespace OpenSim.Framework.Servers.HttpServer.Tests
8{ 8{
9 [TestFixture] 9 [TestFixture]
10 public class BaseRequestHandlerTests 10 public class BaseRequestHandlerTests
11 { 11 {
12 private const string BASE_PATH = "/testpath"; 12 private const string BASE_PATH = "/testpath";
13 13
14 private class BaseRequestHandlerImpl : BaseRequestHandler 14 private class BaseRequestHandlerImpl : BaseRequestHandler
15 { 15 {
16 public BaseRequestHandlerImpl(string httpMethod, string path) : base(httpMethod, path) 16 public BaseRequestHandlerImpl(string httpMethod, string path) : base(httpMethod, path)
17 { 17 {
18 } 18 }
19 } 19 }
20 20
21 [Test] 21 [Test]
22 public void TestConstructor() 22 public void TestConstructor()
23 { 23 {
24 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl( null, null ); 24 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl( null, null );
25 } 25 }
26 26
27 [Test] 27 [Test]
28 public void TestGetParams() 28 public void TestGetParams()
29 { 29 {
30 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH); 30 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH);
31 31
32 BaseRequestHandlerTestHelper.BaseTestGetParams(handler, BASE_PATH); 32 BaseRequestHandlerTestHelper.BaseTestGetParams(handler, BASE_PATH);
33 } 33 }
34 34
35 [Test] 35 [Test]
36 public void TestSplitParams() 36 public void TestSplitParams()
37 { 37 {
38 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH); 38 BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH);
39 39
40 BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, BASE_PATH); 40 BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, BASE_PATH);
41 } 41 }
42 } 42 }
43} 43}
diff --git a/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
index aa97f62..dbb877d 100644
--- a/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
+++ b/OpenSim/Framework/Servers/Tests/CachedGetAssetStreamHandlerTests.cs
@@ -1,72 +1,72 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using NUnit.Framework; 4using NUnit.Framework;
5using OpenSim.Data; 5using OpenSim.Data;
6using OpenSim.Framework.Servers.HttpServer; 6using OpenSim.Framework.Servers.HttpServer;
7using OpenSim.Tests.Common; 7using OpenSim.Tests.Common;
8 8
9namespace OpenSim.Framework.Servers.Tests 9namespace OpenSim.Framework.Servers.Tests
10{ 10{
11 [TestFixture] 11 [TestFixture]
12 public class CachedGetAssetStreamHandlerTests 12 public class CachedGetAssetStreamHandlerTests
13 { 13 {
14 private const string ASSETS_PATH = "/assets"; 14 private const string ASSETS_PATH = "/assets";
15 15
16 [Test] 16 [Test]
17 public void TestConstructor() 17 public void TestConstructor()
18 { 18 {
19 TestHelper.InMethod(); 19 TestHelper.InMethod();
20 20
21 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 21 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
22 } 22 }
23 23
24 [Test] 24 [Test]
25 public void TestGetParams() 25 public void TestGetParams()
26 { 26 {
27 TestHelper.InMethod(); 27 TestHelper.InMethod();
28 28
29 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 29 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
30 BaseRequestHandlerTestHelper.BaseTestGetParams(handler, ASSETS_PATH); 30 BaseRequestHandlerTestHelper.BaseTestGetParams(handler, ASSETS_PATH);
31 } 31 }
32 32
33 [Test] 33 [Test]
34 public void TestSplitParams() 34 public void TestSplitParams()
35 { 35 {
36 TestHelper.InMethod(); 36 TestHelper.InMethod();
37 37
38 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 38 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
39 BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, ASSETS_PATH); 39 BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, ASSETS_PATH);
40 } 40 }
41 41
42 [Test] 42 [Test]
43 public void TestHandleNoParams() 43 public void TestHandleNoParams()
44 { 44 {
45 TestHelper.InMethod(); 45 TestHelper.InMethod();
46 46
47 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 47 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
48 48
49 BaseRequestHandlerTestHelper.BaseTestHandleNoParams(handler, ASSETS_PATH); 49 BaseRequestHandlerTestHelper.BaseTestHandleNoParams(handler, ASSETS_PATH);
50 } 50 }
51 51
52 [Test] 52 [Test]
53 public void TestHandleMalformedGuid() 53 public void TestHandleMalformedGuid()
54 { 54 {
55 TestHelper.InMethod(); 55 TestHelper.InMethod();
56 56
57 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 57 CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
58 58
59 BaseRequestHandlerTestHelper.BaseTestHandleMalformedGuid(handler, ASSETS_PATH); 59 BaseRequestHandlerTestHelper.BaseTestHandleMalformedGuid(handler, ASSETS_PATH);
60 } 60 }
61 61
62 //[Test] 62 //[Test]
63 //public void TestHandleFetchMissingAsset() 63 //public void TestHandleFetchMissingAsset()
64 //{ 64 //{
65 65
66 // byte[] emptyResult = new byte[] { }; 66 // byte[] emptyResult = new byte[] { };
67 // CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null); 67 // CachedGetAssetStreamHandler handler = new CachedGetAssetStreamHandler(null);
68 68
69 // Assert.AreEqual(new string[] { }, handler.Handle("/assets/badGuid", null, null, null), "Failed on bad guid."); 69 // Assert.AreEqual(new string[] { }, handler.Handle("/assets/badGuid", null, null, null), "Failed on bad guid.");
70 //} 70 //}
71 } 71 }
72} 72}
diff --git a/OpenSim/Region/ReplaceableModules/README.txt b/OpenSim/Region/ReplaceableModules/README.txt
index e8e759b..55b7157 100644
--- a/OpenSim/Region/ReplaceableModules/README.txt
+++ b/OpenSim/Region/ReplaceableModules/README.txt
@@ -1,5 +1,5 @@
1This folder is for modules that we intend to let users and system admins replace. 1This folder is for modules that we intend to let users and system admins replace.
2 2
3This folder should never end up a project. Only subfolders should end up as a project. The idea here is that each folder 3This folder should never end up a project. Only subfolders should end up as a project. The idea here is that each folder
4will produce a project and a separate .dll assembly for the module that will get picked up by the module loader. 4will produce a project and a separate .dll assembly for the module that will get picked up by the module loader.
5To replace the functionality, you simply replace the .dll with a different one. \ No newline at end of file 5To replace the functionality, you simply replace the .dll with a different one. \ No newline at end of file
diff --git a/OpenSim/Tests/Common/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/BaseRequestHandlerTestHelper.cs
index 7e91fde..8f96fb3 100644
--- a/OpenSim/Tests/Common/BaseRequestHandlerTestHelper.cs
+++ b/OpenSim/Tests/Common/BaseRequestHandlerTestHelper.cs
@@ -1,57 +1,57 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using NUnit.Framework; 4using NUnit.Framework;
5using OpenSim.Framework.Servers; 5using OpenSim.Framework.Servers;
6using OpenSim.Framework.Servers.HttpServer; 6using OpenSim.Framework.Servers.HttpServer;
7 7
8namespace OpenSim.Tests.Common 8namespace OpenSim.Tests.Common
9{ 9{
10 public class BaseRequestHandlerTestHelper 10 public class BaseRequestHandlerTestHelper
11 { 11 {
12 private static string[] m_emptyStringArray = new string[] { }; 12 private static string[] m_emptyStringArray = new string[] { };
13 13
14 public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath) 14 public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath)
15 { 15 {
16 Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path."); 16 Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path.");
17 Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path."); 17 Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path.");
18 Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url."); 18 Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url.");
19 Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl."); 19 Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl.");
20 20
21 Assert.AreEqual(String.Empty, handler.GetParam(assetsPath)); 21 Assert.AreEqual(String.Empty, handler.GetParam(assetsPath));
22 Assert.AreEqual("/", handler.GetParam(assetsPath + "/")); 22 Assert.AreEqual("/", handler.GetParam(assetsPath + "/"));
23 Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a")); 23 Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a"));
24 Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/")); 24 Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/"));
25 Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d")); 25 Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d"));
26 Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/")); 26 Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/"));
27 } 27 }
28 28
29 public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath) 29 public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath)
30 { 30 {
31 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null."); 31 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null.");
32 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path."); 32 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path.");
33 Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); 33 Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url.");
34 34
35 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params."); 35 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params.");
36 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash."); 36 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash.");
37 37
38 Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment."); 38 Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment.");
39 Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash."); 39 Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash.");
40 Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment."); 40 Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment.");
41 Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash."); 41 Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash.");
42 } 42 }
43 43
44 public static byte[] EmptyByteArray = new byte[] {}; 44 public static byte[] EmptyByteArray = new byte[] {};
45 45
46 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath) 46 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath)
47 { 47 {
48 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params."); 48 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params.");
49 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash."); 49 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash.");
50 } 50 }
51 51
52 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath) 52 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath)
53 { 53 {
54 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid."); 54 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid.");
55 } 55 }
56 } 56 }
57} 57}