public void TestExtractorSerialization()
        {
            ConfigurablePofContext ctx = new ConfigurablePofContext("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-config.xml");

            Assert.IsNotNull(ctx);

            ChainedExtractor         chainedExtractor         = new ChainedExtractor("member1");
            ComparisonValueExtractor comparisonValueExtractor = new ComparisonValueExtractor("member2", "member3");
            IdentityExtractor        identityExtractor        = new IdentityExtractor();
            KeyExtractor             keyExtractor             = new KeyExtractor("member4");
            MultiExtractor           multiExtractor           = new MultiExtractor("member5,member6,member7");
            ReflectionExtractor      reflectionExtractor      = new ReflectionExtractor("member8");

            Stream stream = new MemoryStream();

            ctx.Serialize(new DataWriter(stream), chainedExtractor);
            ctx.Serialize(new DataWriter(stream), comparisonValueExtractor);
            ctx.Serialize(new DataWriter(stream), identityExtractor);
            ctx.Serialize(new DataWriter(stream), keyExtractor);
            ctx.Serialize(new DataWriter(stream), multiExtractor);
            ctx.Serialize(new DataWriter(stream), reflectionExtractor);

            stream.Position = 0;
            Assert.AreEqual(chainedExtractor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(comparisonValueExtractor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(identityExtractor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(keyExtractor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(multiExtractor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(reflectionExtractor, ctx.Deserialize(new DataReader(stream)));

            stream.Close();
        }
        public void TestIdentityExtractor()
        {
            IValueExtractor extractor  = IdentityExtractor.Instance;
            IValueExtractor extractor1 = IdentityExtractor.Instance;

            Assert.IsNotNull(extractor);
            Assert.AreEqual(extractor, extractor1);
            Assert.AreEqual(extractor.ToString(), extractor1.ToString());
            Assert.AreEqual(extractor.GetHashCode(), extractor1.GetHashCode());

            object o  = new DictionaryEntry("key", "value");
            object o1 = extractor.Extract(o);

            Assert.AreEqual(o, o1);

            IdentityExtractor ie = extractor as IdentityExtractor;

            Assert.AreEqual(ie.Compare("ana", "cikic"), -1);

            TestQueryCacheEntry entry1 = new TestQueryCacheEntry("1", 1);
            TestQueryCacheEntry entry2 = new TestQueryCacheEntry("2", 2);

            Assert.AreEqual(ie.CompareEntries(entry2, entry1), 1);

            //testing on remote cache
            INamedCache cache = CacheFactory.GetCache(CacheName);

            cache.Clear();

            Hashtable ht = new Hashtable();

            ht.Add("identityExtractorKey1", 435);
            ht.Add("identityExtractorKey2", 253);
            ht.Add("identityExtractorKey3", 3);
            ht.Add("identityExtractorKey4", null);
            ht.Add("identityExtractorKey5", -3);
            cache.InsertAll(ht);

            IFilter     filter = new EqualsFilter(extractor, 253);
            ICollection keys   = cache.GetKeys(filter);

            Assert.Contains("identityExtractorKey2", (IList)keys);
            Assert.AreEqual(keys.Count, 1);

            CacheFactory.Shutdown();
        }
        public void TestCreateIndex()
        {
            IValueExtractor extractor = new IdentityExtractor();
            IFilter         filter    = new GreaterFilter(extractor, 5);
            IDictionary     map       = new HashDictionary();

            var condExtractor = new ConditionalExtractor(filter, extractor, true);

            var index = condExtractor.CreateIndex(false, null, map);

            Assert.IsTrue(index is ConditionalIndex);
            Assert.AreEqual(filter, ((ConditionalIndex)index).Filter);
            Assert.AreEqual(extractor, index.ValueExtractor);

            // make sure that the index map has been updated with the created
            // index
            var index2 = map[extractor] as ICacheIndex;

            Assert.IsNotNull(index2);
            Assert.AreEqual(index, index2);
        }
        public void TestDestroyIndex()
        {
            IValueExtractor extractor = new IdentityExtractor();
            IFilter         filter    = new GreaterFilter(extractor, 5);
            IDictionary     map       = new HashDictionary();

            var condExtractor = new ConditionalExtractor(filter, extractor, true);

            var index = condExtractor.CreateIndex(false, null, map);

            // make sure that the index map has been updated with the created
            // index
            var index2 = map[extractor] as ICacheIndex;

            Assert.IsNotNull(index2);
            Assert.AreEqual(index, index2);

            condExtractor.DestroyIndex(map);

            // make sure that the index has been removed from the index map
            Assert.IsNull(map[extractor]);
        }