public void TestRemove()
        {
            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");

            cache.Clear();

            Hashtable ht = new Hashtable();

            ht.Add("conditionalPutAllKey1", 435);
            ht.Add("conditionalPutAllKey2", 253);
            ht.Add("conditionalPutAllKey3", 200);
            ht.Add("conditionalPutAllKey4", 333);
            cache.InsertAll(ht);

            IFilter greaterThen300 = new GreaterFilter(IdentityExtractor.Instance, 300);
            IFilter lessThen300    = new LessFilter(IdentityExtractor.Instance, 300);
            IFilter key3           = new LikeFilter(new KeyExtractor(IdentityExtractor.Instance), "%Key3", '\\', false);

            Assert.IsTrue(cache.Count == 4);

            // remove key1 with greaterThen300 filter applied
            ConditionalRemove processor = new ConditionalRemove(greaterThen300, false);

            cache.Invoke("conditionalPutAllKey1", processor);
            Assert.IsTrue(cache.Count == 3);

            // remove all entries that satisfy filter criteria
            processor = new ConditionalRemove(greaterThen300, false);
            cache.InvokeAll(ht.Keys, processor);
            Assert.IsTrue(cache.Count == 2);
            Assert.IsNotNull(cache["conditionalPutAllKey2"]);
            Assert.IsNotNull(cache["conditionalPutAllKey3"]);

            processor = new ConditionalRemove(lessThen300, false);
            cache.InvokeAll(new GreaterFilter(IdentityExtractor.Instance, 200), processor);
            Assert.IsTrue(cache.Count == 1);
            Assert.IsNotNull(cache["conditionalPutAllKey3"]);

            processor = new ConditionalRemove(key3, false);
            cache.InvokeAll(new GreaterFilter(IdentityExtractor.Instance, 100), processor);
            Assert.IsTrue(cache.Count == 0);

            CacheFactory.Shutdown();
        }
        public void TestComposite()
        {
            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");

            cache.Clear();

            Address addr1 = new Address("XI krajiske divizije", "Belgrade", "Serbia", "11000");
            Address addr2 = new Address("Pere Velimirovica", "Belgrade", "Serbia", "11000");
            Address addr3 = new Address("Rige od Fere", "Belgrade", "Serbia", "11000");

            cache.Insert("addr1", addr1);
            cache.Insert("addr2", addr2);

            Assert.IsTrue(cache.Count == 2);

            LikeFilter         likeXI        = new LikeFilter(new ReflectionExtractor("Street"), "XI%", '\\', true);
            ExtractorProcessor extractStreet = new ExtractorProcessor(new ReflectionExtractor("Street"));
            IEntryProcessor    putAddr3      = new ConditionalPut(AlwaysFilter.Instance, addr3);
            IEntryProcessor    removeLikeXI  = new ConditionalRemove(likeXI, false);

            IEntryProcessor[]  processors = new IEntryProcessor[] { extractStreet, removeLikeXI, putAddr3 };
            CompositeProcessor processor  = new CompositeProcessor(processors);

            Object objResult = cache.Invoke("addr1", processor);

            Assert.IsTrue(cache.Count == 2);
            object[] objResultArr = objResult as object[];
            Assert.IsNotNull(objResultArr);
            Assert.AreEqual(addr1.Street, objResultArr[0]);

            Address res = cache["addr1"] as Address;

            Assert.IsNotNull(res);
            Assert.AreEqual(addr3.City, res.City);
            Assert.AreEqual(addr3.State, res.State);
            Assert.AreEqual(addr3.Street, res.Street);
            Assert.AreEqual(addr3.ZIP, res.ZIP);

            res = cache["addr2"] as Address;
            Assert.IsNotNull(res);
            Assert.AreEqual(addr2.City, res.City);
            Assert.AreEqual(addr2.State, res.State);
            Assert.AreEqual(addr2.Street, res.Street);
            Assert.AreEqual(addr2.ZIP, res.ZIP);

            IDictionary dictResult = cache.InvokeAll(new ArrayList(new object[] { "addr1", "addr2" }), processor);

            Assert.IsTrue(cache.Count == 2);
            Address address = cache["addr1"] as Address;

            Assert.IsNotNull(address);
            Assert.AreEqual(addr3.Street, address.Street);
            address = cache["addr2"] as Address;
            Assert.IsNotNull(address);
            Assert.AreEqual(addr3.Street, address.Street);
            object[] objectArr = dictResult["addr1"] as object[];
            Assert.IsNotNull(objectArr);
            Assert.AreEqual(objectArr[0], addr3.Street);
            objectArr = dictResult["addr2"] as object[];
            Assert.IsNotNull(objectArr);
            Assert.AreEqual(objectArr[0], addr2.Street);

            CacheFactory.Shutdown();
        }