diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r-- | OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | 34 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetCache.cs | 92 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs | 27 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetService.cs | 78 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | 13 |
5 files changed, 218 insertions, 26 deletions
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs new file mode 100644 index 0000000..acfe4fe --- /dev/null +++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | |||
@@ -0,0 +1,34 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using OpenMetaverse; | ||
3 | using OpenSim.Framework; | ||
4 | |||
5 | namespace OpenSim.Tests.Common.Mock | ||
6 | { | ||
7 | public class BaseAssetRepository | ||
8 | { | ||
9 | protected Dictionary<UUID, AssetBase> Assets = new Dictionary<UUID, AssetBase>(); | ||
10 | |||
11 | public AssetBase FetchAsset(UUID uuid) | ||
12 | { | ||
13 | if (ExistsAsset(uuid)) | ||
14 | return Assets[uuid]; | ||
15 | else | ||
16 | return null; | ||
17 | } | ||
18 | |||
19 | public void CreateAsset(AssetBase asset) | ||
20 | { | ||
21 | Assets[asset.FullID] = asset; | ||
22 | } | ||
23 | |||
24 | public void UpdateAsset(AssetBase asset) | ||
25 | { | ||
26 | CreateAsset(asset); | ||
27 | } | ||
28 | |||
29 | public bool ExistsAsset(UUID uuid) | ||
30 | { | ||
31 | return Assets.ContainsKey(uuid); | ||
32 | } | ||
33 | } | ||
34 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestAssetCache.cs b/OpenSim/Tests/Common/Mock/TestAssetCache.cs new file mode 100644 index 0000000..d621763 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestAssetCache.cs | |||
@@ -0,0 +1,92 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenMetaverse; | ||
5 | using OpenMetaverse.Packets; | ||
6 | using OpenSim.Framework; | ||
7 | |||
8 | namespace OpenSim.Tests.Common.Mock | ||
9 | { | ||
10 | public class TestAssetCache : BaseAssetRepository, IAssetCache | ||
11 | { | ||
12 | public void AssetReceived(AssetBase asset, bool IsTexture) | ||
13 | { | ||
14 | throw new NotImplementedException(); | ||
15 | } | ||
16 | |||
17 | public void AssetNotFound(UUID assetID, bool IsTexture) | ||
18 | { | ||
19 | throw new NotImplementedException(); | ||
20 | } | ||
21 | |||
22 | public void Dispose() | ||
23 | { | ||
24 | throw new NotImplementedException(); | ||
25 | } | ||
26 | |||
27 | public string Version | ||
28 | { | ||
29 | get { throw new NotImplementedException(); } | ||
30 | } | ||
31 | |||
32 | public string Name | ||
33 | { | ||
34 | get { throw new NotImplementedException(); } | ||
35 | } | ||
36 | |||
37 | public void Initialise() | ||
38 | { | ||
39 | throw new NotImplementedException(); | ||
40 | } | ||
41 | |||
42 | public IAssetServer AssetServer | ||
43 | { | ||
44 | get { throw new NotImplementedException(); } | ||
45 | } | ||
46 | |||
47 | public void Initialise(ConfigSettings cs, IAssetServer server) | ||
48 | { | ||
49 | throw new NotImplementedException(); | ||
50 | } | ||
51 | |||
52 | public void ShowState() | ||
53 | { | ||
54 | throw new NotImplementedException(); | ||
55 | } | ||
56 | |||
57 | public void Clear() | ||
58 | { | ||
59 | throw new NotImplementedException(); | ||
60 | } | ||
61 | |||
62 | public bool TryGetCachedAsset(UUID assetID, out AssetBase asset) | ||
63 | { | ||
64 | throw new NotImplementedException(); | ||
65 | } | ||
66 | |||
67 | public void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture) | ||
68 | { | ||
69 | throw new NotImplementedException(); | ||
70 | } | ||
71 | |||
72 | public AssetBase GetAsset(UUID assetID, bool isTexture) | ||
73 | { | ||
74 | return FetchAsset(assetID); | ||
75 | } | ||
76 | |||
77 | public void AddAsset(AssetBase asset) | ||
78 | { | ||
79 | CreateAsset( asset ); | ||
80 | } | ||
81 | |||
82 | public void ExpireAsset(UUID assetID) | ||
83 | { | ||
84 | throw new NotImplementedException(); | ||
85 | } | ||
86 | |||
87 | public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) | ||
88 | { | ||
89 | throw new NotImplementedException(); | ||
90 | } | ||
91 | } | ||
92 | } | ||
diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs index 80b9ae3..b639cc9 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs | |||
@@ -37,40 +37,15 @@ namespace OpenSim.Tests.Common.Mock | |||
37 | /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit | 37 | /// mono addin plugin system starts co-operating with the unit test system. Currently no locking since unit |
38 | /// tests are single threaded. | 38 | /// tests are single threaded. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class TestAssetDataPlugin : IAssetDataPlugin | 40 | public class TestAssetDataPlugin : BaseAssetRepository, IAssetDataPlugin |
41 | { | 41 | { |
42 | public string Version { get { return "0"; } } | 42 | public string Version { get { return "0"; } } |
43 | public string Name { get { return "TestAssetDataPlugin"; } } | 43 | public string Name { get { return "TestAssetDataPlugin"; } } |
44 | |||
45 | protected Dictionary<UUID, AssetBase> Assets = new Dictionary<UUID, AssetBase>(); | ||
46 | 44 | ||
47 | public void Initialise() {} | 45 | public void Initialise() {} |
48 | public void Initialise(string connect) {} | 46 | public void Initialise(string connect) {} |
49 | public void Dispose() {} | 47 | public void Dispose() {} |
50 | 48 | ||
51 | public AssetBase FetchAsset(UUID uuid) | ||
52 | { | ||
53 | if (ExistsAsset(uuid)) | ||
54 | return Assets[uuid]; | ||
55 | else | ||
56 | return null; | ||
57 | } | ||
58 | |||
59 | public void CreateAsset(AssetBase asset) | ||
60 | { | ||
61 | Assets[asset.FullID] = asset; | ||
62 | } | ||
63 | |||
64 | public void UpdateAsset(AssetBase asset) | ||
65 | { | ||
66 | CreateAsset(asset); | ||
67 | } | ||
68 | |||
69 | public bool ExistsAsset(UUID uuid) | ||
70 | { | ||
71 | return Assets.ContainsKey(uuid); | ||
72 | } | ||
73 | |||
74 | public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } | 49 | public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } |
75 | } | 50 | } |
76 | } \ No newline at end of file | 51 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs new file mode 100644 index 0000000..23a1137 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs | |||
@@ -0,0 +1,78 @@ | |||
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 OpenSim 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 OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Data; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | namespace OpenSim.Tests.Common.Mock | ||
36 | { | ||
37 | public class TestAssetService : IAssetService | ||
38 | { | ||
39 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); | ||
40 | |||
41 | public AssetBase Get(string id) | ||
42 | { | ||
43 | return Assets[ id ]; | ||
44 | } | ||
45 | |||
46 | public AssetMetadata GetMetadata(string id) | ||
47 | { | ||
48 | throw new System.NotImplementedException(); | ||
49 | } | ||
50 | |||
51 | public byte[] GetData(string id) | ||
52 | { | ||
53 | throw new System.NotImplementedException(); | ||
54 | } | ||
55 | |||
56 | public bool Get(string id, object sender, AssetRetrieved handler) | ||
57 | { | ||
58 | throw new NotImplementedException(); | ||
59 | } | ||
60 | |||
61 | public string Store(AssetBase asset) | ||
62 | { | ||
63 | Assets[asset.ID] = asset; | ||
64 | |||
65 | return asset.ID; | ||
66 | } | ||
67 | |||
68 | public bool UpdateContent(string id, byte[] data) | ||
69 | { | ||
70 | throw new System.NotImplementedException(); | ||
71 | } | ||
72 | |||
73 | public bool Delete(string id) | ||
74 | { | ||
75 | throw new System.NotImplementedException(); | ||
76 | } | ||
77 | } | ||
78 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs new file mode 100644 index 0000000..d9c96f4 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | |||
@@ -0,0 +1,13 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework.Servers.HttpServer; | ||
5 | |||
6 | namespace OpenSim.Tests.Common.Mock | ||
7 | { | ||
8 | public class TestOSHttpResponse : OSHttpResponse | ||
9 | { | ||
10 | public override int StatusCode { get; set; } | ||
11 | public override string ContentType { get; set; } | ||
12 | } | ||
13 | } | ||