public void TestLocking() { IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory; IXmlDocument config = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-local-cache-config.xml"); ccf.Config = config; INamedCache cache = CacheFactory.GetCache("local-default"); Assert.IsTrue(cache is LocalNamedCache); LocalNamedCache localNamedCache = cache as LocalNamedCache; Assert.IsNotNull(localNamedCache); Hashtable ht = new Hashtable(); ht.Add("key1", 435); ht.Add("key2", 253); ht.Add("key3", 3); ht.Add("key4", 200); localNamedCache.InsertAll(ht); localNamedCache.Lock("key2"); localNamedCache.Lock("key2", 1000); localNamedCache.Unlock("key2"); GreaterFilter filter = new GreaterFilter(IdentityExtractor.Instance, 280); object[] results = localNamedCache.GetValues(filter, null); Assert.AreEqual(1, results.Length); Assert.AreEqual(435, results[0]); results = localNamedCache.GetEntries(filter, null); Assert.AreEqual(1, results.Length); Assert.AreEqual(435, ((ICacheEntry)results[0]).Value); CacheFactory.Shutdown(); }
public void TestEntries() { IConfigurableCacheFactory ccf = CacheFactory.ConfigurableCacheFactory; IXmlDocument config = XmlHelper.LoadXml("assembly://Coherence.Tests/Tangosol.Resources/s4hc-local-cache-config.xml"); ccf.Config = config; INamedCache cache = CacheFactory.GetCache("local-default"); Assert.IsTrue(cache is LocalNamedCache); LocalNamedCache localNamedCache = cache as LocalNamedCache; Assert.IsNotNull(localNamedCache); Hashtable ht = new Hashtable(); ht.Add("key1", 435); ht.Add("key2", 253); ht.Add("key3", 3); ht.Add("key4", 200); localNamedCache.InsertAll(ht); ICollection result = localNamedCache.Entries; Assert.IsNotNull(result); Assert.AreEqual(4, result.Count); result = localNamedCache.Values; Assert.IsNotNull(result); Assert.AreEqual(4, result.Count); int[] results = new int[localNamedCache.Count]; localNamedCache.CopyTo(results, 0); Assert.AreEqual(localNamedCache.Count, result.Count); CacheFactory.Shutdown(); }