Esempio n. 1
0
        public void IncludeCurrentStateEventTest()
        {
            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();
                cache.Put("key1", "value1");
                cl.filterFactoryName    = "";
                cl.converterFactoryName = "";
                cl.includeCurrentState  = true;
                cl.AddListener(listener.CreatedEventAction);
                AssertNoEvents(listener);
                cache.AddClientListener(cl, new string[] { }, new string[] { }, null);
                AssertOnlyCreated("key1", listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
Esempio n. 2
0
        public void CustomEventsTest()
        {
            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.converterFactoryName = "to-string-converter-factory";
                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);
                cache.Put("key1", "value1");
                AssertOnlyCustom("custom event: key1 value1", listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
        protected void TestAddRemoveListener(IRemoteCache <string, string> cache)
        {
            LoggingEventListener <string> listener = new LoggingEventListener <string>();

            Event.ClientListener <string, string> cl = new Event.ClientListener <string, string>();
            try
            {
                cache.Remove(K1);
                cache.Remove(K2);
                cl.filterFactoryName    = "";
                cl.converterFactoryName = "";
                cl.AddListener(listener.CreatedEventAction);
                cache.AddClientListener(cl, new string[] { }, new string[] { }, null);
                cache.Put(K1, V1);
                var remoteEvent = listener.PollCreatedEvent();
                Assert.AreEqual(K1, remoteEvent.GetKey());
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
0
        public void FilterEventsTest()
        {
            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    = "string-is-equal-filter-factory";
                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[] { "wantedkeyprefix" }, new string[] { }, null);
                AssertNoEvents(listener);
                cache.Put("key1", "value1");
                cache.Put("wantedkeyprefix_key1", "value2");
                //only one received; one is ignored
                AssertOnlyCreated("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
                cache.Replace("key1", "modified");
                cache.Replace("wantedkeyprefix_key1", "modified");
                AssertOnlyModified("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
                cache.Remove("key1");
                cache.Remove("wantedkeyprefix_key1");
                AssertOnlyRemoved("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
Esempio n. 6
0
        public void BasicEventsTest()
        {
            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.Put("key1", "value1");
                AssertOnlyCreated("key1", listener);
                cache.Put("key1", "value1bis");
                AssertOnlyModified("key1", listener);
                cache.Remove("key1");
                AssertOnlyRemoved("key1", listener);
                cache.Put("key1", "value1", 100, TimeUnit.MILLISECONDS);
                AssertOnlyCreated("key1", listener);
                TimeUtils.WaitFor(() => { return(cache.Get("key1") == null); });
                AssertOnlyExpired("key1", listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }