@@ -122,6 +122,44 @@ class ContinuousQueryCacheTest : public CxxTest::TestSuite
122
122
}
123
123
};
124
124
125
+ // validating lite cache listener for CQC instance
126
+ class ValidateLiteMapListener : public class_spec <ValidateLiteMapListener,
127
+ extends<Object>, implements<MapListener> >
128
+ {
129
+ friend class factory <ValidateLiteMapListener>;
130
+
131
+ protected:
132
+ ValidateLiteMapListener (bool fLite )
133
+ {
134
+ m_fLite = fLite ;
135
+ }
136
+
137
+ public:
138
+ void entryInserted (MapEvent::View vEvt)
139
+ {
140
+ TS_ASSERT (m_fLite ? vEvt->getNewValue () == NULL : vEvt->getNewValue () != NULL );
141
+ }
142
+
143
+ void entryUpdated (MapEvent::View vEvt)
144
+ {
145
+ TS_ASSERT (m_fLite ? vEvt->getNewValue () == NULL : vEvt->getNewValue () != NULL );
146
+ TS_ASSERT (m_fLite ? vEvt->getOldValue () == NULL : vEvt->getOldValue () != NULL );
147
+ }
148
+
149
+ void entryDeleted (MapEvent::View vEvt)
150
+ {
151
+ TS_ASSERT (m_fLite ? vEvt->getOldValue () == NULL : vEvt->getOldValue () != NULL );
152
+ }
153
+
154
+ // ----- data members -----------------------------------------------
155
+
156
+ protected:
157
+ /* *
158
+ * If true, validate a lite MapListener, get old and new value are NULL.
159
+ */
160
+ bool m_fLite;
161
+ };
162
+
125
163
// ----- local class: TestCQCListener -----------------------------------
126
164
127
165
/* *
@@ -510,7 +548,7 @@ class ContinuousQueryCacheTest : public CxxTest::TestSuite
510
548
511
549
// create CQC
512
550
ContinuousQueryCache::Handle hCqc = ContinuousQueryCache::create (
513
- hCache, AlwaysFilter::create (), false , hMockListener);
551
+ hCache, AlwaysFilter::create (), true , hMockListener);
514
552
515
553
Object::View vKey = String::create (" key1" );
516
554
Object::View vVal = String::create (" val1" );
@@ -1891,6 +1929,49 @@ class ContinuousQueryCacheTest : public CxxTest::TestSuite
1891
1929
hCqc->release ();
1892
1930
}
1893
1931
1932
+ /*
1933
+ * Test for COH-31325
1934
+ */
1935
+ void testCOH31325 ()
1936
+ {
1937
+ NamedCache::Handle hCache = ensureCleanCache (" TestCache" );
1938
+
1939
+ // test fCacheValues of false and lite map listener
1940
+ ContinuousQueryCache::Handle hCqc = ContinuousQueryCache::create (
1941
+ hCache, AlwaysFilter::create (), false , ValidateLiteMapListener::create (true ));
1942
+ TS_ASSERT (!hCqc->isCacheValues ());
1943
+ hCache->put (String::create (" Key31325" ), String::create (" Value31325" ));
1944
+ hCache->put (String::create (" Key31325" ), String::create (" UpdateValue31325" ));
1945
+ hCache->remove (String::create (" Key31325" ));
1946
+ TS_ASSERT (!hCqc->isCacheValues ());
1947
+ hCqc->release ();
1948
+
1949
+ // test fCacheValues of false initially with map listener, first non-lite listener converts isCacheValues to true
1950
+ hCqc = ContinuousQueryCache::create (
1951
+ hCache, AlwaysFilter::create (), false , SampleMapListener::create ());
1952
+ TS_ASSERT (!hCqc->isCacheValues ());
1953
+ hCache->put (String::create (" Key31325" ), String::create (" Value31325" ));
1954
+ hCache->put (String::create (" Key31325" ), String::create (" UpdateValue31325" ));
1955
+ hCache->remove (String::create (" Key31325" ));
1956
+ TS_ASSERT (!hCqc->isCacheValues ());
1957
+ // add a standard listener and verify isCacheValues after
1958
+ hCqc->addFilterListener (ValidateLiteMapListener::create (false ), AlwaysFilter::create (), false );
1959
+ hCache->put (String::create (" Key31325" ), String::create (" SecondUpdateValue31325" ));
1960
+ TS_ASSERT (hCqc->isCacheValues ());
1961
+ hCqc->release ();
1962
+
1963
+ // validate standard listener when fCacheValues is true
1964
+ hCache = ensureCleanCache (" TestCache" );
1965
+ hCqc = ContinuousQueryCache::create (
1966
+ hCache, AlwaysFilter::create (), true , ValidateLiteMapListener::create (false ));
1967
+ TS_ASSERT (hCqc->isCacheValues ());
1968
+ hCache->put (String::create (" Key31325" ), String::create (" Value31325" ));
1969
+ hCache->put (String::create (" Key31325" ), String::create (" UpdateValue31325" ));
1970
+ hCache->remove (String::create (" Key31325" ));
1971
+ TS_ASSERT (hCqc->isCacheValues ());
1972
+ hCqc->release ();
1973
+ }
1974
+
1894
1975
/*
1895
1976
* Test for COH-10013
1896
1977
*/
0 commit comments