aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Tests
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-09 19:40:32 +0000
committerJustin Clarke Casey2009-03-09 19:40:32 +0000
commitae759f2d060bc53cc0b372d5584fcd4ffdd963b4 (patch)
tree304c4c40fa8be68943a3b5cad0b22a19769b2cf9 /OpenSim/Framework/Communications/Tests
parent* Move method documentation from AssetCache up to IAssetCache (diff)
downloadopensim-SC_OLD-ae759f2d060bc53cc0b372d5584fcd4ffdd963b4.zip
opensim-SC_OLD-ae759f2d060bc53cc0b372d5584fcd4ffdd963b4.tar.gz
opensim-SC_OLD-ae759f2d060bc53cc0b372d5584fcd4ffdd963b4.tar.bz2
opensim-SC_OLD-ae759f2d060bc53cc0b372d5584fcd4ffdd963b4.tar.xz
* Add basic asset cache get test
Diffstat (limited to 'OpenSim/Framework/Communications/Tests')
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
new file mode 100644
index 0000000..34193b5
--- /dev/null
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -0,0 +1,88 @@
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
28using System.Threading;
29using NUnit.Framework;
30using NUnit.Framework.SyntaxHelpers;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Tests.Common.Mock;
35
36namespace OpenSim.Framework.Communications.Tests
37{
38 /// <summary>
39 /// Asset cache tests
40 /// </summary>
41 [TestFixture]
42 public class AssetCacheTests
43 {
44 protected UUID m_assetIdReceived;
45 protected AssetBase m_assetReceived;
46
47 [Test]
48 /// <summary>
49 /// Test the 'asynchronous' get asset mechanism (though this won't be done asynchronously within this test)
50 /// </summary>
51 public void TestGetAsset()
52 {
53 UUID assetId = UUID.Parse("00000000-0000-0000-0000-000000000001");
54 byte[] assetData = new byte[] { 3, 2, 1 };
55
56 AssetBase asset = new AssetBase();
57 asset.FullID = assetId;
58 asset.Data = assetData;
59
60 TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin();
61 assetPlugin.CreateAsset(asset);
62
63 IAssetCache assetCache = new AssetCache(new SQLAssetServer(assetPlugin));
64
65 lock (this)
66 {
67 assetCache.GetAsset(assetId, AssetRequestCallback, false);
68 Monitor.Wait(this, 60000);
69 }
70
71 Assert.That(
72 assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received");
73 Assert.That(
74 assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received");
75 }
76
77 private void AssetRequestCallback(UUID assetId, AssetBase asset)
78 {
79 m_assetIdReceived = assetId;
80 m_assetReceived = asset;
81
82 lock (this)
83 {
84 Monitor.PulseAll(this);
85 }
86 }
87 }
88}