protected void TestPutReplaceWithVersion(IRemoteCache <string, string> cache)
        {
            cache.Put(K1, V1);
            IVersionedValue <string> value = cache.GetVersioned(K1);
            ulong version = value.GetVersion();

            cache.ReplaceWithVersion(K1, V2, version);
            value = cache.GetVersioned(K1);
            Assert.AreEqual(V2, value.GetValue());
            Assert.IsTrue(value.GetVersion() != version);
        }
        protected void TestPutReplaceWithVersionAsync(IRemoteCache <string, string> cache)
        {
            cache.Put(K1, V1);
            IVersionedValue <string> value = cache.GetVersioned(K1);
            ulong       version            = value.GetVersion();
            Task <bool> result             = cache.ReplaceWithVersionAsync(K1, V2, version);

            result.Wait(5000);
            value = cache.GetVersioned(K1);
            Assert.AreEqual(V2, value.GetValue());
            Assert.IsTrue(value.GetVersion() != version);
        }
        protected void TestPutRemoveWithVersion(IRemoteCache <string, string> cache)
        {
            cache.Put(K1, V1);
            IVersionedValue <string> value = cache.GetVersioned(K1);
            ulong version = value.GetVersion();

            cache.RemoveWithVersion(K1, version);
            value = cache.GetVersioned(K1);
            if (value != null)
            {
                Assert.AreNotEqual(value.GetVersion(), version);
            }
        }
        protected void TestPutRemoveWithVersionAsync(IRemoteCache <string, string> cache)
        {
            cache.Put(K1, V1);
            IVersionedValue <string> value = cache.GetVersioned(K1);
            ulong       version            = value.GetVersion();
            Task <bool> result             = cache.RemoveWithVersionAsync(K1, version);

            result.Wait(5000);
            value = cache.GetVersioned(K1);
            if (value != null)
            {
                Assert.AreNotEqual(value.GetVersion(), version);
            }
        }
        protected void TestPutGetVersioned(IRemoteCache <string, string> cache)
        {
            cache.Put(K1, V1);
            IVersionedValue <string> value = cache.GetVersioned(K1);

            Assert.AreEqual(V1, value.GetValue());
            Assert.AreNotEqual(0, value.GetVersion());
        }
示例#6
0
        public void ConditionalEventsTest()
        {
            LoggingEventListener <string> listener = new LoggingEventListener <string>();
            IRemoteCache <string, string> cache    = remoteManager.GetCache <string, string>();

            Event.ClientListener <string, string> cl = new Event.ClientListener <string, string>();
            try
            {
                cache.Clear();
                cl.filterFactoryName    = "";
                cl.converterFactoryName = "";
                cl.AddListener(listener.CreatedEventAction);
                cl.AddListener(listener.ModifiedEventAction);
                cl.AddListener(listener.RemovedEventAction);
                cl.AddListener(listener.ExpiredEventAction);
                cl.AddListener(listener.CustomEventAction);
                cache.AddClientListener(cl, new string[] { }, new string[] { }, null);
                AssertNoEvents(listener);
                cache.PutIfAbsent("key1", "value1");
                AssertOnlyCreated("key1", listener);
                cache.PutIfAbsent("key1", "value1again");
                AssertNoEvents(listener);
                cache.Replace("key1", "modified");
                AssertOnlyModified("key1", listener);
                cache.ReplaceWithVersion("key1", "modified", 0);
                AssertNoEvents(listener);
                IVersionedValue <string> versioned = cache.GetVersioned("key1");
                //TODO: this needs conversion from long to ulong (is it a bug?)
                cache.ReplaceWithVersion("key1", "modified", versioned.GetVersion());
                AssertOnlyModified("key1", listener);
                cache.RemoveWithVersion("key1", 0);
                AssertNoEvents(listener);
                versioned = cache.GetVersioned("key1");
                cache.RemoveWithVersion("key1", versioned.GetVersion());
                AssertOnlyRemoved("key1", listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
示例#7
0
        public void GetVersionedTest()
        {
            String key = UniqueKey.NextKey();

            cache.Put(key, "uranium");
            IVersionedValue <String> previous = cache.GetVersioned(key);

            cache.Put(key, "rubidium");

            IVersionedValue <String> current = cache.GetVersioned(key);

            Assert.AreEqual("rubidium", current.GetValue());

            Assert.AreNotEqual(previous.GetVersion(), current.GetVersion());
        }
 protected void TestGetVersioned(IRemoteCache <string, string> cache)
 {
     Assert.IsNull(cache.GetVersioned(NON_EXISTENT_KEY));
 }