diff options
Diffstat (limited to 'OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs')
-rw-r--r-- | OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs index d3a0368..157a883 100644 --- a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs +++ b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs | |||
@@ -3,13 +3,17 @@ using System.Collections.Generic; | |||
3 | using System.Text; | 3 | using System.Text; |
4 | using NUnit.Framework; | 4 | using NUnit.Framework; |
5 | using OpenSim.Data; | 5 | using OpenSim.Data; |
6 | using OpenSim.Framework.Servers.HttpServer; | ||
6 | using OpenSim.Tests.Common; | 7 | using OpenSim.Tests.Common; |
7 | 8 | ||
8 | namespace OpenSim.Framework.Servers.Tests | 9 | namespace OpenSim.Framework.Servers.Tests |
9 | { | 10 | { |
10 | [TestFixture] | 11 | [TestFixture] |
11 | public class GetAssetStreamHandlerTests | 12 | public class GetAssetStreamHandlerTests |
12 | { | 13 | { |
14 | private static byte[] EmptyByteArray = new byte[] {}; | ||
15 | private const string ASSETS_PATH = "/assets"; | ||
16 | |||
13 | [Test] | 17 | [Test] |
14 | public void TestConstructor() | 18 | public void TestConstructor() |
15 | { | 19 | { |
@@ -24,18 +28,7 @@ namespace OpenSim.Framework.Servers.Tests | |||
24 | TestHelper.InMethod(); | 28 | TestHelper.InMethod(); |
25 | 29 | ||
26 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | 30 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); |
27 | 31 | BaseRequestHandlerTestHelper.BaseTestGetParams(handler, ASSETS_PATH); | |
28 | Assert.AreEqual("", handler.GetParam(null), "Failed on null path."); | ||
29 | Assert.AreEqual("", handler.GetParam(""), "Failed on empty path."); | ||
30 | Assert.AreEqual("", handler.GetParam("s"), "Failed on short url."); | ||
31 | Assert.AreEqual("", handler.GetParam("corruptUrl"), "Failed on corruptUrl."); | ||
32 | |||
33 | Assert.AreEqual("", handler.GetParam("/assets")); | ||
34 | Assert.AreEqual("/", handler.GetParam("/assets/")); | ||
35 | Assert.AreEqual("/a", handler.GetParam("/assets/a")); | ||
36 | Assert.AreEqual("/b/", handler.GetParam("/assets/b/")); | ||
37 | Assert.AreEqual("/c/d", handler.GetParam("/assets/c/d")); | ||
38 | Assert.AreEqual("/e/f/", handler.GetParam("/assets/e/f/")); | ||
39 | } | 32 | } |
40 | 33 | ||
41 | [Test] | 34 | [Test] |
@@ -44,17 +37,7 @@ namespace OpenSim.Framework.Servers.Tests | |||
44 | TestHelper.InMethod(); | 37 | TestHelper.InMethod(); |
45 | 38 | ||
46 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | 39 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); |
47 | 40 | BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, ASSETS_PATH); | |
48 | Assert.AreEqual(new string[] { }, handler.SplitParams(null), "Failed on null."); | ||
49 | Assert.AreEqual(new string[] { }, handler.SplitParams(""), "Failed on empty path."); | ||
50 | Assert.AreEqual(new string[] { }, handler.SplitParams("corruptUrl"), "Failed on corrupt url."); | ||
51 | |||
52 | Assert.AreEqual(new string[] { }, handler.SplitParams("/assets"), "Failed on empty params."); | ||
53 | Assert.AreEqual(new string[] { }, handler.SplitParams("/assets/"), "Failed on single slash."); | ||
54 | Assert.AreEqual(new string[] { "a" }, handler.SplitParams("/assets/a"), "Failed on first segment."); | ||
55 | Assert.AreEqual(new string[] { "b" }, handler.SplitParams("/assets/b/"), "Failed on second slash."); | ||
56 | Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams("/assets/c/d"), "Failed on second segment."); | ||
57 | Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams("/assets/e/f/"), "Failed on trailing slash."); | ||
58 | } | 41 | } |
59 | 42 | ||
60 | [Test] | 43 | [Test] |
@@ -62,11 +45,10 @@ namespace OpenSim.Framework.Servers.Tests | |||
62 | { | 45 | { |
63 | TestHelper.InMethod(); | 46 | TestHelper.InMethod(); |
64 | 47 | ||
65 | byte[] emptyResult = new byte[] {}; | ||
66 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | 48 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); |
67 | 49 | ||
68 | Assert.AreEqual(new string[] { }, handler.Handle("/assets", null, null, null), "Failed on empty params."); | 50 | Assert.AreEqual(EmptyByteArray, handler.Handle(ASSETS_PATH, null, null, null), "Failed on empty params."); |
69 | Assert.AreEqual(new string[] { }, handler.Handle("/assets/", null, null, null ), "Failed on single slash."); | 51 | Assert.AreEqual(EmptyByteArray, handler.Handle(ASSETS_PATH + "/", null, null, null), "Failed on single slash."); |
70 | } | 52 | } |
71 | 53 | ||
72 | [Test] | 54 | [Test] |
@@ -74,10 +56,9 @@ namespace OpenSim.Framework.Servers.Tests | |||
74 | { | 56 | { |
75 | TestHelper.InMethod(); | 57 | TestHelper.InMethod(); |
76 | 58 | ||
77 | byte[] emptyResult = new byte[] {}; | ||
78 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | 59 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); |
79 | 60 | ||
80 | Assert.AreEqual(new string[] {}, handler.Handle("/assets/badGuid", null, null, null), "Failed on bad guid."); | 61 | Assert.AreEqual(EmptyByteArray, handler.Handle(ASSETS_PATH + "/badGuid", null, null, null), "Failed on bad guid."); |
81 | } | 62 | } |
82 | 63 | ||
83 | //[Test] | 64 | //[Test] |