Пример #1
0
        public void TestProcessorSerialization()
        {
            ConfigurablePofContext ctx = new ConfigurablePofContext("assembly://Coherence.Tests/Tangosol.Resources/s4hc-test-config.xml");

            Assert.IsNotNull(ctx);

            CompositeProcessor   compositeProcessor   = new CompositeProcessor();
            ConditionalProcessor conditionalProcessor = new ConditionalProcessor();
            ConditionalPut       conditionalPut       = new ConditionalPut(AlwaysFilter.Instance, 1);
            ConditionalPutAll    conditionalPutAll    = new ConditionalPutAll(AlwaysFilter.Instance, new Hashtable());
            ConditionalRemove    conditionalRemove    = new ConditionalRemove(AlwaysFilter.Instance, true);
            ExtractorProcessor   extractorProcessor   = new ExtractorProcessor("member1");
            NumberIncrementor    numberIncrementor    = new NumberIncrementor("name1", 5, true);
            NumberMultiplier     numberMultiplier     = new NumberMultiplier("name2", 10, false);
            PreloadRequest       preloadRequest       = new PreloadRequest();
            PriorityProcessor    priorityProcessor    = new PriorityProcessor();
            PropertyManipulator  propertyManipulator  = new PropertyManipulator("name3");
            UpdaterProcessor     updaterProcessor     = new UpdaterProcessor("member2", 20);
            VersionedPut         versionedPut         = new VersionedPut();
            VersionedPutAll      versionedPutAll      = new VersionedPutAll(new Hashtable());

            Stream stream = new MemoryStream();

            ctx.Serialize(new DataWriter(stream), compositeProcessor);
            ctx.Serialize(new DataWriter(stream), conditionalProcessor);
            ctx.Serialize(new DataWriter(stream), conditionalPut);
            ctx.Serialize(new DataWriter(stream), conditionalPutAll);
            ctx.Serialize(new DataWriter(stream), conditionalRemove);
            ctx.Serialize(new DataWriter(stream), extractorProcessor);
            ctx.Serialize(new DataWriter(stream), numberIncrementor);
            ctx.Serialize(new DataWriter(stream), numberMultiplier);
            ctx.Serialize(new DataWriter(stream), preloadRequest);
            ctx.Serialize(new DataWriter(stream), priorityProcessor);
            ctx.Serialize(new DataWriter(stream), propertyManipulator);
            ctx.Serialize(new DataWriter(stream), updaterProcessor);
            ctx.Serialize(new DataWriter(stream), versionedPut);
            ctx.Serialize(new DataWriter(stream), versionedPutAll);

            stream.Position = 0;
            Assert.AreEqual(compositeProcessor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(conditionalProcessor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(conditionalPut, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(conditionalPutAll.GetType(), ctx.Deserialize(new DataReader(stream)).GetType());
            Assert.AreEqual(conditionalRemove, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(extractorProcessor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(numberIncrementor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(numberMultiplier, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(preloadRequest, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(priorityProcessor.GetType(), ctx.Deserialize(new DataReader(stream)).GetType());
            Assert.AreEqual(propertyManipulator, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(updaterProcessor, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(versionedPut, ctx.Deserialize(new DataReader(stream)));
            Assert.AreEqual(versionedPutAll.GetType(), ctx.Deserialize(new DataReader(stream)).GetType());

            stream.Close();
        }
Пример #2
0
 /// <summary>
 /// Compare the <b>VersionedPutAll</b> with another object to
 /// determine equality.
 /// </summary>
 /// <param name="o">
 /// The object to compare with.
 /// </param>
 /// <returns>
 /// <b>true</b> iff this <b>VersionedPutAll</b> and the passed object
 /// are equivalent <b>VersionedPutAll</b>.
 /// </returns>
 public override bool Equals(object o)
 {
     if (o is VersionedPutAll)
     {
         VersionedPutAll that = (VersionedPutAll)o;
         return(Equals(m_map, that.m_map) &&
                m_insert == that.m_insert &&
                m_return == that.m_return);
     }
     return(false);
 }
Пример #3
0
        public void TestVersionPutAll()
        {
            Hashtable ht = new Hashtable();

            ht.Add("noon", new Temperature(100, 'f', 12));
            ht.Add("midnight", new Temperature(25, 'f', 0));
            IEntryProcessor processor  = new VersionedPutAll(ht, true, false);
            IEntryProcessor processor1 = new VersionedPutAll(ht, true, false);

            Assert.AreEqual(processor.ToString(), processor1.ToString());

            Temperature temperature = new Temperature(500, 'C', 1);

            LocalCache.Entry entry = new LocalCache.Entry(new LocalCache(), "morning", temperature);

            processor.Process(entry);

            Temperature entryTemp = entry.Value as Temperature;

            Assert.AreEqual(entryTemp.Grade, temperature.Grade);
            Assert.AreEqual(entryTemp.Value, temperature.Value);

            temperature = new Temperature(500, 'C', 12);
            entry       = new LocalCache.Entry(new LocalCache(), "noon", temperature);

            processor.Process(entry);

            entryTemp = entry.Value as Temperature;
            Assert.AreEqual(entryTemp.Grade, 'F');
            Assert.AreEqual(entryTemp.Value, 100);

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

            cache.Clear();

            Temperature t1 = new Temperature(3, 'c', 8);
            Temperature t2 = new Temperature(24, 'c', 12);
            Temperature t3 = new Temperature(15, 'c', 18);
            Temperature t4 = new Temperature(0, 'c', 0);

            cache.Insert("morning", t1);
            cache.Insert("noon", t2);
            cache.Insert("afternoon", t3);
            cache.Insert("midnight", t4);

            ht = new Hashtable();
            ht.Add("noon", new Temperature(100, 'f', 12));
            ht.Add("midnight", new Temperature(25, 'f', 0));

            processor = new VersionedPutAll(ht, true, false);
            cache.InvokeAll(cache.Keys, processor);

            Temperature after = (Temperature)cache["midnight"];

            Assert.AreEqual(25, after.Value);
            Assert.AreEqual('F', after.Grade);
            Assert.AreEqual(1, after.Version);

            after = (Temperature)cache["noon"];
            Assert.AreEqual(100, after.Value);
            Assert.AreEqual('F', after.Grade);
            Assert.AreEqual(13, after.Version);

            CacheFactory.Shutdown();
        }