diff options
author | Justin Clark-Casey (justincc) | 2011-04-15 01:23:26 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-04-15 01:23:26 +0100 |
commit | 54e885581989ddfaf525753ede12c4d4d797cba0 (patch) | |
tree | 93ebf52a5eed5d0ce12a7a804b4f4a07d0ee4d77 /OpenSim/Tests/Common | |
parent | Remove the mock inventory service for tests and just use the real one all the... (diff) | |
download | opensim-SC-54e885581989ddfaf525753ede12c4d4d797cba0.zip opensim-SC-54e885581989ddfaf525753ede12c4d4d797cba0.tar.gz opensim-SC-54e885581989ddfaf525753ede12c4d4d797cba0.tar.bz2 opensim-SC-54e885581989ddfaf525753ede12c4d4d797cba0.tar.xz |
remove mock asset service for tests in favour of always using the real one
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockAssetService.cs | 123 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 14 |
2 files changed, 5 insertions, 132 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 | ||
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 97d4ace..484a97d 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -132,7 +132,7 @@ namespace OpenSim.Tests.Common.Setup | |||
132 | testScene.AddModule(godsModule.Name, godsModule); | 132 | testScene.AddModule(godsModule.Name, godsModule); |
133 | realServices = realServices.ToLower(); | 133 | realServices = realServices.ToLower(); |
134 | 134 | ||
135 | LocalAssetServicesConnector assetService = StartAssetService(testScene, realServices.Contains("asset")); | 135 | LocalAssetServicesConnector assetService = StartAssetService(testScene); |
136 | 136 | ||
137 | // For now, always started a 'real' authentication service | 137 | // For now, always started a 'real' authentication service |
138 | StartAuthenticationService(testScene, true); | 138 | StartAuthenticationService(testScene, true); |
@@ -164,19 +164,15 @@ namespace OpenSim.Tests.Common.Setup | |||
164 | return testScene; | 164 | return testScene; |
165 | } | 165 | } |
166 | 166 | ||
167 | private static LocalAssetServicesConnector StartAssetService(Scene testScene, bool real) | 167 | private static LocalAssetServicesConnector StartAssetService(Scene testScene) |
168 | { | 168 | { |
169 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); | 169 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); |
170 | IConfigSource config = new IniConfigSource(); | 170 | IConfigSource config = new IniConfigSource(); |
171 | config.AddConfig("Modules"); | ||
172 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); | ||
173 | 171 | ||
172 | config.AddConfig("Modules"); | ||
173 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); | ||
174 | config.AddConfig("AssetService"); | 174 | config.AddConfig("AssetService"); |
175 | if (real) | 175 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
176 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | ||
177 | else | ||
178 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService"); | ||
179 | |||
180 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 176 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
181 | 177 | ||
182 | assetService.Initialise(config); | 178 | assetService.Initialise(config); |