aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Tests/CacheTests.cs
diff options
context:
space:
mode:
authorMelanie2010-09-21 04:02:50 +0100
committerMelanie2010-09-21 04:02:50 +0100
commit2b8c99c2fbbd377cb270087531385bc753932555 (patch)
treee0509ae1a72ae1155032241965e4a77c89e5c6f8 /OpenSim/Framework/Tests/CacheTests.cs
parentFix a typo (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.zip
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.gz
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.bz2
opensim-SC_OLD-2b8c99c2fbbd377cb270087531385bc753932555.tar.xz
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Tests/CacheTests.cs')
-rw-r--r--OpenSim/Framework/Tests/CacheTests.cs46
1 files changed, 33 insertions, 13 deletions
diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs
index 32c0c95..c3613e6 100644
--- a/OpenSim/Framework/Tests/CacheTests.cs
+++ b/OpenSim/Framework/Tests/CacheTests.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Framework.Tests
40 public void Build() 40 public void Build()
41 { 41 {
42 cache = new Cache(); 42 cache = new Cache();
43 cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate);
43 cacheItemUUID = UUID.Random(); 44 cacheItemUUID = UUID.Random();
44 MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); 45 MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1));
45 byte[] foo = new byte[1]; 46 byte[] foo = new byte[1];
@@ -68,36 +69,55 @@ namespace OpenSim.Framework.Tests
68 Assert.That(citem == null, "Item should not be in Cache"); 69 Assert.That(citem == null, "Item should not be in Cache");
69 } 70 }
70 71
71 //NOTE: Test Case disabled until Cache is fixed 72
72 [Test] 73 [Test]
73 public void TestTTLExpiredEntry() 74 public void ExpireItemManually()
74 { 75 {
75 UUID ImmediateExpiryUUID = UUID.Random(); 76 UUID ImmediateExpiryUUID = UUID.Random();
76 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); 77 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1));
77 byte[] foo = new byte[1]; 78 byte[] foo = new byte[1];
78 foo[0] = 1; 79 foo[0] = 1;
79 cachedItem.Store(foo); 80 cachedItem.Store(foo);
80 cache.Store(cacheItemUUID.ToString(), cachedItem); 81 cache.Store(cacheItemUUID.ToString(), cachedItem);
81 82 cache.Invalidate(cacheItemUUID.ToString());
82 cache.Get(cacheItemUUID.ToString()); 83 cache.Get(cacheItemUUID.ToString());
83 //object citem = cache.Get(cacheItemUUID.ToString()); 84 object citem = cache.Get(cacheItemUUID.ToString());
84 //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); 85 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
85 } 86 }
86 87
87 //NOTE: Test Case disabled until Cache is fixed
88 [Test] 88 [Test]
89 public void ExpireItemManually() 89 public void ClearCacheTest()
90 { 90 {
91 UUID ImmediateExpiryUUID = UUID.Random(); 91 UUID ImmediateExpiryUUID = UUID.Random();
92 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); 92 MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), DateTime.Now - TimeSpan.FromDays(1));
93 byte[] foo = new byte[1]; 93 byte[] foo = new byte[1];
94 foo[0] = 1; 94 foo[0] = 1;
95 cachedItem.Store(foo); 95 cachedItem.Store(foo);
96 cache.Store(cacheItemUUID.ToString(), cachedItem); 96 cache.Store(cacheItemUUID.ToString(), cachedItem);
97 cache.Invalidate(ImmediateExpiryUUID.ToString()); 97 cache.Clear();
98 cache.Get(cacheItemUUID.ToString()); 98
99 //object citem = cache.Get(cacheItemUUID.ToString()); 99 object citem = cache.Get(cacheItemUUID.ToString());
100 //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); 100 Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
101 }
102
103 [Test]
104 public void CacheItemMundane()
105 {
106 UUID Random1 = UUID.Random();
107 UUID Random2 = UUID.Random();
108 byte[] data = new byte[0];
109 CacheItemBase cb1 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1));
110 CacheItemBase cb2 = new CacheItemBase(Random2.ToString(), DateTime.Now + TimeSpan.FromDays(1));
111 CacheItemBase cb3 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1));
112
113 cb1.Store(data);
114
115 Assert.That(cb1.Equals(cb3), "cb1 should equal cb3, their uuids are the same");
116 Assert.That(!cb2.Equals(cb1), "cb2 should not equal cb1, their uuids are NOT the same");
117 Assert.That(cb1.IsLocked() == false, "CacheItemBase default is false");
118 Assert.That(cb1.Retrieve() == null, "Virtual Retrieve method should return null");
119
120
101 } 121 }
102 122
103 } 123 }