diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockAssetService.cs | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/OpenSim/Tests/Common/Mock/MockAssetService.cs b/OpenSim/Tests/Common/Mock/MockAssetService.cs deleted file mode 100644 index 9d7c5e2..0000000 --- a/OpenSim/Tests/Common/Mock/MockAssetService.cs +++ /dev/null | |||
@@ -1,123 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Data; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using Nini.Config; | ||
37 | |||
38 | namespace OpenSim.Tests.Common.Mock | ||
39 | { | ||
40 | public class MockAssetService : IAssetService | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); | ||
45 | |||
46 | public MockAssetService() {} | ||
47 | |||
48 | /// <summary> | ||
49 | /// This constructor is required if the asset service is being created reflectively (which is the case in some | ||
50 | /// tests). | ||
51 | /// </summary> | ||
52 | /// <param name="config"></param> | ||
53 | public MockAssetService(IConfigSource config) {} | ||
54 | |||
55 | public AssetBase Get(string id) | ||
56 | { | ||
57 | // m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); | ||
58 | |||
59 | AssetBase asset; | ||
60 | if (Assets.ContainsKey(id)) | ||
61 | { | ||
62 | asset = Assets[id]; | ||
63 | // m_log.DebugFormat( | ||
64 | // "[MOCK ASSET SERVICE]: Got asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length); | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | asset = null; | ||
69 | } | ||
70 | |||
71 | return asset; | ||
72 | } | ||
73 | |||
74 | public AssetBase GetCached(string id) | ||
75 | { | ||
76 | return Get(id); | ||
77 | } | ||
78 | |||
79 | public AssetMetadata GetMetadata(string id) | ||
80 | { | ||
81 | throw new System.NotImplementedException(); | ||
82 | } | ||
83 | |||
84 | public byte[] GetData(string id) | ||
85 | { | ||
86 | // m_log.DebugFormat("[MOCK ASSET SERVICE]: Requesting data for asset {0}", id); | ||
87 | |||
88 | AssetBase asset = Get(id); | ||
89 | |||
90 | if (asset == null) | ||
91 | return null; | ||
92 | else | ||
93 | return asset.Data; | ||
94 | } | ||
95 | |||
96 | public bool Get(string id, object sender, AssetRetrieved handler) | ||
97 | { | ||
98 | handler(id, sender, Get(id)); | ||
99 | |||
100 | return true; | ||
101 | } | ||
102 | |||
103 | public string Store(AssetBase asset) | ||
104 | { | ||
105 | // m_log.DebugFormat( | ||
106 | // "[MOCK ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length); | ||
107 | |||
108 | Assets[asset.ID] = asset; | ||
109 | |||
110 | return asset.ID; | ||
111 | } | ||
112 | |||
113 | public bool UpdateContent(string id, byte[] data) | ||
114 | { | ||
115 | throw new System.NotImplementedException(); | ||
116 | } | ||
117 | |||
118 | public bool Delete(string id) | ||
119 | { | ||
120 | throw new System.NotImplementedException(); | ||
121 | } | ||
122 | } | ||
123 | } \ No newline at end of file | ||